From be14c875cb15d0e06ac8026d44759ff42391b6d1 Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Thu, 1 May 2014 09:54:35 +0200 Subject: [PATCH] Invalid subjects and properties are not variables. --- src/org/linkeddatafragments/servlet/BasicLdfServlet.java | 8 +++----- src/org/linkeddatafragments/util/CommonResources.java | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/org/linkeddatafragments/servlet/BasicLdfServlet.java b/src/org/linkeddatafragments/servlet/BasicLdfServlet.java index 31aa57e..10ea9dc 100644 --- a/src/org/linkeddatafragments/servlet/BasicLdfServlet.java +++ b/src/org/linkeddatafragments/servlet/BasicLdfServlet.java @@ -166,7 +166,7 @@ private int parseAsInteger(String value) { */ private Resource parseAsResource(String value) { final RDFNode subject = parseAsNode(value); - return subject instanceof Resource ? (Resource)subject : null; + return subject == null || subject instanceof Resource ? (Resource)subject : INVALID_URI; } /** @@ -178,11 +178,9 @@ private Property parseAsProperty(String value) { final RDFNode predicateNode = parseAsNode(value); if (predicateNode instanceof Resource) { try { return ResourceFactory.createProperty(((Resource)predicateNode).getURI()); } - catch (InvalidPropertyURIException ex) { - return ResourceFactory.createProperty("urn:invalid-predicate-uri"); - } + catch (InvalidPropertyURIException ex) { return INVALID_URI; } } - return null; + return predicateNode == null ? null : INVALID_URI; } /** diff --git a/src/org/linkeddatafragments/util/CommonResources.java b/src/org/linkeddatafragments/util/CommonResources.java index 2d1a164..fbd58af 100644 --- a/src/org/linkeddatafragments/util/CommonResources.java +++ b/src/org/linkeddatafragments/util/CommonResources.java @@ -31,6 +31,8 @@ public class CommonResources { public final static Property HYDRA_NEXTPAGE = createProperty(HYDRA + "nextPage"); public final static Property HYDRA_PREVIOUSPAGE = createProperty(HYDRA + "previousPage"); + public final static Property INVALID_URI = createProperty("urn:invalid"); + private final static Property createProperty(String uri) { return ResourceFactory.createProperty(uri); }