Class OSLC4JUtils

java.lang.Object
org.eclipse.lyo.oslc4j.core.OSLC4JUtils

public class OSLC4JUtils extends Object
  • Constructor Details

    • OSLC4JUtils

      public OSLC4JUtils()
  • Method Details

    • useStrictDatatypes

      public static boolean useStrictDatatypes()
    • alwaysAbbrevXML

      public static boolean alwaysAbbrevXML()
    • relativeURIsAreDisabled

      public static boolean relativeURIsAreDisabled()
      Returns the boolean value of org.eclipse.lyo.oslc4j.disableRelativeURIs Default is true if not set or invalid (relative URIs will not be allowed)
      Returns:
      true if relative URIs are disabled, or if the property is not set or invalid.
    • getValueBasedOnResourceShapeType

      public static Object getValueBasedOnResourceShapeType(HashSet<String> rdfTypesList, QName propertyQName, Object originalValue) throws DatatypeConfigurationException, IllegalArgumentException, InstantiationException
      This method receives the property name and the property value and tries to infer the property type from the pre-defined list of Resource Shapes. Then returns the corresponding java object for the given object value. Returns a null object when it was not possible to infer the property type from the list of Resource Shapes.
      Parameters:
      propertyQName - Property information
      originalValue - Property value
      Returns:
      Java object related to the Resource Shape type.
      Throws:
      DatatypeConfigurationException - , IllegalArgumentException, InstantiationException, InvocationTargetException on
      IllegalArgumentException
      InstantiationException
    • getPublicURI

      public static String getPublicURI()
      Returns the value of org.eclipse.lyo.oslc4j.publicURI or null if not set.
      Returns:
      Public URI, or null if not set
    • setPublicURI

      public static void setPublicURI(String newPublicURI) throws MalformedURLException
      Sets the value of org.eclipse.lyo.oslc4j.publicURI
      Parameters:
      newPublicURI - The new public URI to use.
      Throws:
      MalformedURLException
    • getServletPath

      public static String getServletPath()
      Return the servlet path value.
      Returns:
      Servlet Path, or its default "services/" if not set.
    • resolveURI

      @Deprecated public static String resolveURI(jakarta.servlet.http.HttpServletRequest request, boolean includePath)
      Deprecated.
      Resolve a URI (usually a resource subject or info URI) based on the settings of org.eclipse.lyo.oslc4j.publicURI and org.eclipse.lyo.oslc4j.disableHostResolution. If the publicURI property is set, it takes precedence and is used to build the full URI. If the disableHostResolution property is false or not set, resolution of the local hostname is attempted. If the disableHostResolution property is true or resolution has failed, the hostname is retrieved from the request. Query parameters from the request are not copied to the resolved URI.
      Parameters:
      request - - request to base resolved URI on
      includePath - - if the path (after the context root) should be included in the resolved URI
      Returns:
      String containing the resolved URI
    • getServletURI

      public static String getServletURI()
      Return the public URI including the servlet path. Typically, this would be something like "localhost:8080/adaptor-webapp/services", whereas the publicURI would typically be the base "localhost:8080/adaptor-webapp"
    • useBeanClassForParsing

      public static boolean useBeanClassForParsing()
    • getUseBeanClassForParsing

      public static String getUseBeanClassForParsing()
    • getShapes

      public static List<ResourceShape> getShapes()
      Returns a list of Resource Shapes to be used when inferring a property type from the Resource Shape. This method should only be used when the property inferTypeFromShape is set to true.
      Returns:
      List of Resource Shapes
    • inferTypeFromShape

      public static boolean inferTypeFromShape()
    • getInferTypeFromShape

      public static String getInferTypeFromShape()
    • setShapes

      public static void setShapes(List<ResourceShape> shapes)
      Sets a list of Resource Shapes to be used when inferring a property type from the Resource Shape. This method should only be used when the property inferTypeFromShape is set to true.
      Parameters:
      shapes - List of Resource Shapes
    • isHostResolutionDisabled

      public static boolean isHostResolutionDisabled()
      Returns the boolean value of org.eclipse.lyo.oslc4j.disableHostResolution Default is false if not set or invalid (hostname resolution will take place)
      Returns:
      true if host resolution is disabled, false if not set or invalid
    • isQueryResultListAsContainer

      public static boolean isQueryResultListAsContainer()
      Return if the query result list type will be http://www.w3.org/2000/01/rdf-schema#Container or there will be no type. Default is no type.
    • setUseBeanClassForParsing

      public static void setUseBeanClassForParsing(String useBeanClassForParsing)
    • setHostResolutionDisabled

      public static void setHostResolutionDisabled(boolean hostResDisabled)
    • resolveFullUri

      public static String resolveFullUri(jakarta.servlet.http.HttpServletRequest request)
      Resolve a full request URI (usually a resource subject or info URI) based on the settings of org.eclipse.lyo.oslc4j.publicURI and org.eclipse.lyo.oslc4j.disableHostResolution. If the publicURI property is set, it takes precedence and is used to build the full URI. If the servletPath property is set, it takes precedence and is used to build the full URI. If the disableHostResolution property is false or not set, resolution of the local hostname is attempted. If the disableHostResolution property is true or resolution has failed, the hostname is retrieved from the request. Query parameters from the request are not copied to the resolved URI.
      Parameters:
      request - - request to base resolved URI on
      Returns:
      String containing the resolved URI
    • resolveServletUri

      public static String resolveServletUri(jakarta.servlet.http.HttpServletRequest request)
      Resolve a servlet URI based on the settings of org.eclipse.lyo.oslc4j.publicURI and org.eclipse.lyo.oslc4j.disableHostResolution. If the publicURI property is set, it takes precedence and is used to build the full URI. If the servletPath property is set, it takes precedence and is used to build the full URI. If the disableHostResolution property is false or not set, resolution of the local hostname is attempted. If the disableHostResolution property is true or resolution has failed, the hostname is retrieved from the request. Query parameters from the request are not copied to the resolved URI.
      Parameters:
      request - - request to base resolved URI on
      Returns:
      String containing the resolved URI
    • setServletPath

      public static void setServletPath(String newServletPath)
      Sets the value of the servlet path. This method also sets the resulting value of the servletURI (combining the publicURI with the servlet path). This requires publicURI to be configured beforehand.
      Parameters:
      newServletPath - New servlet path to set or NULL to reset it.
    • setInferTypeFromShape

      public static void setInferTypeFromShape(String inferTypeFromShape)
    • getDataTypeBasedOnResourceShapeType

      public static RDFDatatype getDataTypeBasedOnResourceShapeType(HashSet<String> rdfTypesList, Property property)
      This method receives the property name and the property value and tries to infer the property Data Type from the pre-defined list of Resource Shapes. Returns a null object when it was not possible to infer the property Data Type from the list of Resource Shapes.
      Parameters:
      rdfTypesList - List of rdf:types
      property - Property information
      Returns:
      Java object related to the Resource Shape type.
    • isLyoStorePagingUnsafe

      public static boolean isLyoStorePagingUnsafe()
      Returns:
      the boolean value of org.eclipse.lyo.oslc4j.unsafePaging Default is false if not set.
      See Also:
    • setLyoStorePagingUnsafe

      public static void setLyoStorePagingUnsafe(boolean value)
    • hasLyoStorePagingPreciseLimit

      public static boolean hasLyoStorePagingPreciseLimit()
      Returns:
      the boolean value of org.eclipse.lyo.oslc4j.unsafePaging Default is true if not set.
      See Also:
    • setLyoStorePagingPreciseLimit

      public static void setLyoStorePagingPreciseLimit(boolean value)
    • isWellFormed

      public static boolean isWellFormed(String xmlLiteral)
    • isWellFormed

      public static boolean isWellFormed(XMLLiteral literal)