From 2109c70f872134fe8ba67b194f8b2e65ebd7990a Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Wed, 9 Oct 2013 12:52:05 -0400 Subject: [PATCH] update to check if uri valid property uri before checking it exists as property --- .../mannlib/vitro/webapp/utils/jena/URIUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/URIUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/URIUtils.java index 618751696..9628c661a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/URIUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/jena/URIUtils.java @@ -21,8 +21,14 @@ public class URIUtils { boolean existingURI = false; ontModel.enterCriticalSection(Lock.READ); try { + boolean validPropertyURI = true; + String localName = uriStr.substring(uriStr.lastIndexOf("/") + 1); + //if local name is only numbers, this is not a valid uri for a property + if(localName.matches("\\d+")) { + validPropertyURI = false; + } Resource newURIAsRes = ResourceFactory.createResource(uriStr); - Property newURIAsProp = ResourceFactory.createProperty(uriStr); + StmtIterator closeIt = ontModel.listStatements( newURIAsRes, null, (RDFNode)null); if (closeIt.hasNext()) { @@ -37,7 +43,8 @@ public class URIUtils { } } //Check for property - if (!existingURI) { + if (validPropertyURI && !existingURI) { + Property newURIAsProp = ResourceFactory.createProperty(uriStr); closeIt = ontModel.listStatements( null, newURIAsProp, (RDFNode)null); if (closeIt.hasNext()) {