Class OslcProperties


  • public class OslcProperties
    extends Object
    Provides support for selective property values through the "oslc.properties" query parameter of a servlet request.

    This class defines methods to determine whether a specific OSLC property is to include in a GET response, to obtain a partial resource retrieval. It is also used to determine if such property is to include when a PUT request is received, to support a partial resource update.

    The "oslc.properties" query parameter is a comma separated list of prefixed properties, e.g. oslc.properties=dcterms:title,oslc:details.

    The "oslc.prefix" query parameter, if any, is a comma separated list of namespaces associated to prefixes, e.g. oslc.prefix=dc=<http://purl.org/dc/terms/>,foaf=<http://xmlns.com/foaf/0.1/>. If not present, the following well known prefixes are supported: rdf, rdfs, foaf, oslc, oslc_am, oslc_cm, oslc_qm, oslc_rm.

    Note that if the "oslc.properties" is absent or its value is *, the contains() methods always return true.

    This class does not support nested properties, i.e. OSLC properties for nested resources defined with '{' and '}' characters in the "oslc.properties" query parameter.

    Typical usage is:

     OslcProperties properties = OslcProperties.of(request);
     if (properties.contains("dcterms:title")) {
         ...
     }
     
    or
     OslcProperties properties = OslcProperties.of(request);
     if (properties.contains(Dcterms.PROPERTY_TITLE)) {
     ...
     }
     
    Since:
    1.5.0
    • Method Detail

      • of

        public static OslcProperties of​(HttpServletRequest request)
        Returns an instance that wraps the specified servlet request.
        Parameters:
        request - a servlet request.
        Returns:
        a new OslcProperties instance.
        Throws:
        WebApplicationException - if the "oslc.prefix" query parameter is present and its value has syntax issues.
      • contains

        public boolean contains​(String property)
        Determines if the specified property is included in the "oslc.properties" query parameter. The property may be a prefixed name (e.g. "dcterms:title") or a full name (e.g. "http://purl.org/dc/terms/title").
        Parameters:
        property - the property to test, which may be a prefixed name (e.g. "dcterms:title") or a full name (e.g. "http://purl.org/dc/terms/title").
        Returns:
        true if the specified property is included in the "oslc.properties" query parameter or if "oslc.properties" is not set, false otherwise.
      • contains

        public boolean contains​(QName property)
        Determines if the specified property is included in the "oslc.properties" query parameter.
        Parameters:
        property - the property to test.
        Returns:
        true if the specified property is included in the "oslc.properties" query parameter or if "oslc.properties" is not set, false otherwise.
      • contains

        public boolean contains​(URI property)
        Determines if the specified property is included in the "oslc.properties" query parameter.
        Parameters:
        property - the property to test.
        Returns:
        true if the specified property is included in the "oslc.properties" query parameter or if "oslc.properties" is not set, false otherwise.