summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-02-13 10:53:21 (EST)
committer David Terry2013-02-13 10:53:21 (EST)
commit7321f8e255d9cdc04b8fd2df6341d18ab1d05c14 (patch)
tree5610d777561537da216260fbfb829b9d484df03a
parent1ef39cd2bf5597548a1225e1b7207bcd20640826 (diff)
downloadorg.eclipse.lyo.core-7321f8e255d9cdc04b8fd2df6341d18ab1d05c14.zip
org.eclipse.lyo.core-7321f8e255d9cdc04b8fd2df6341d18ab1d05c14.tar.gz
org.eclipse.lyo.core-7321f8e255d9cdc04b8fd2df6341d18ab1d05c14.tar.bz2
bug 399764 allow relative URIsrefs/changes/44/10344/1
Signed-off-by: David Terry <dgterry@us.ibm.com> Change-Id: Ib9374a90be8ef00cdb33be91fc633271cb88ee08
-rw-r--r--OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JConstants.java1
-rw-r--r--OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java18
-rw-r--r--OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java5
-rw-r--r--OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java5
4 files changed, 24 insertions, 5 deletions
diff --git a/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JConstants.java b/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JConstants.java
index 4f3c62b..52c018e 100644
--- a/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JConstants.java
+++ b/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JConstants.java
@@ -23,6 +23,7 @@ public interface OSLC4JConstants {
public static String OSLC4J_PUBLIC_URI = "org.eclipse.lyo.oslc4j.publicURI";
public static String OSLC4J_DISABLE_HOST_RESOLUTION = "org.eclipse.lyo.oslc4j.disableHostResolution";
+ public static String OSLC4J_DISABLE_RELATIVE_URIS = "org.eclipse.lyo.oslc4j.disableRelativeURIs";
public static final Map<String, Object> OSL4J_PROPERTY_SINGLETON =
new HashMap<String, Object>(0);
diff --git a/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java b/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java
index cf32810..455902d 100644
--- a/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java
+++ b/OSLC4J/src/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java
@@ -159,5 +159,21 @@ public class OSLC4JUtils {
return resolvedURI.toString();
}
-
+
+ /**
+ * Returns the boolean value of org.eclipse.lyo.oslc4j.disableRelativeURIs
+ * Default is false if not set or invalid (relative URIs will be allowed)
+ * @return
+ */
+ public static boolean relativeURIsAreDisabled()
+ {
+ boolean retVal = false;
+
+ String relURIsDisabledProp = System.getProperty(OSLC4JConstants.OSLC4J_DISABLE_RELATIVE_URIS);
+ if (relURIsDisabledProp !=null)
+ {
+ retVal = Boolean.parseBoolean(relURIsDisabledProp);
+ }
+ return retVal;
+ }
}
diff --git a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
index 8f399b0..d1ad856 100644
--- a/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
+++ b/OSLC4JJenaProvider/src/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java
@@ -63,6 +63,7 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.lyo.oslc4j.core.NestedWildcardProperties;
import org.eclipse.lyo.oslc4j.core.OSLC4JConstants;
+import org.eclipse.lyo.oslc4j.core.OSLC4JUtils;
import org.eclipse.lyo.oslc4j.core.SingletonWildcardProperties;
import org.eclipse.lyo.oslc4j.core.annotation.OslcName;
import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespaceDefinition;
@@ -257,7 +258,7 @@ public final class JenaModelHelper
final Resource mainResource;
if (aboutURI != null)
{
- if (!aboutURI.isAbsolute())
+ if (OSLC4JUtils.relativeURIsAreDisabled() && !aboutURI.isAbsolute())
{
throw new OslcCoreRelativeURIException(objectClass,
"getAbout",
@@ -1561,7 +1562,7 @@ public final class JenaModelHelper
final URI uri = (URI) value;
- if (!uri.isAbsolute())
+ if (OSLC4JUtils.relativeURIsAreDisabled() && !uri.isAbsolute())
{
throw new OslcCoreRelativeURIException(resourceClass,
(method == null) ? "<none>" : method.getName(),
diff --git a/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java b/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
index 6eb5255..c387400 100644
--- a/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
+++ b/OSLC4JJson4JProvider/src/org/eclipse/lyo/oslc4j/provider/json4j/JsonHelper.java
@@ -59,6 +59,7 @@ import org.apache.wink.json4j.JSONException;
import org.apache.wink.json4j.JSONObject;
import org.eclipse.lyo.oslc4j.core.NestedWildcardProperties;
import org.eclipse.lyo.oslc4j.core.OSLC4JConstants;
+import org.eclipse.lyo.oslc4j.core.OSLC4JUtils;
import org.eclipse.lyo.oslc4j.core.SingletonWildcardProperties;
import org.eclipse.lyo.oslc4j.core.annotation.OslcName;
import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespaceDefinition;
@@ -1059,7 +1060,7 @@ final class JsonHelper
throws OslcCoreRelativeURIException,
JSONException
{
- if (!uri.isAbsolute())
+ if (OSLC4JUtils.relativeURIsAreDisabled() && !uri.isAbsolute())
{
throw new OslcCoreRelativeURIException(resourceClass,
(method == null) ? "<none>" : method.getName(),
@@ -1132,7 +1133,7 @@ final class JsonHelper
{
if (aboutURI != null)
{
- if (!aboutURI.isAbsolute())
+ if (OSLC4JUtils.relativeURIsAreDisabled() && !aboutURI.isAbsolute())
{
throw new OslcCoreRelativeURIException(objectClass,
"getAbout",