Class QueryParameters

java.lang.Object
com.sodius.oslc.server.process.query.QueryParameters

public class QueryParameters extends Object
OSLC query parameters parsed from an HTTP request.
Since:
3.6.0
  • Method Details

    • from

      Creates a builder to parse OSLC query parameters, controlled by the given scope.

      The given array of parameters is to restrict which ones are parsed from the HTTP request. Any parameter not listed here is ignored, i.e. the parameter is not parsed from the HTTP request even if present. If the array is empty, all known parameters are parsed.

      To use only selective properties for a GET end-point, you may prefer using applySelectedProperties(HttpServletRequest, Class). To use only selective properties for a PUT end-point, you may prefer using OslcProperties.of(HttpServletRequest).

      Parameters:
      request - the HTTP request
      scope - the OSLC query parameters to parse
      Returns:
      a new builder instance
      Throws:
      NullPointerException - if request is null
    • applySelectedProperties

      public static void applySelectedProperties(HttpServletRequest request, Class<?> resourceShape)
      Configures the request to support selective properties, to enable clients to retrieve only selected property values. This method shall be called on a GET end-point before responding with a given resource.

      This method parses the oslc.select and oslc.prefix parameters and sets the "org.eclipse.lyo.oslc4j.selected.properties" attribute on the request. This makes the XML and JSON serializers to respond only with properties that match the selected ones.

      The prefixes used in the oslc.select expression are resolved to namespaces using the oslc.prefix parameter, if any, but also with ones defined on the OslcSchema of the given resource shape and, last, with well known OSLC prefixes (RDF, OSLC Core, etc.).

      Parameters:
      request - the HTTP request
      resourceShape - the type of resource responded by the GET end-point, to determine the OSLC prefixes that can be used
      Throws:
      NullPointerException - if request or resourceShape is null
    • getPrefixes

      public Map<String,String> getPrefixes()
      Returns the map of prefix/namespace mappings defined in the oslc.prefix parameter, or an empty map if absent.
      Returns:
      an unmodifiable map of prefix/namespace mappings
    • getWhere

      public Optional<WhereClause> getWhere()
      Returns the where clause parsed from the oslc.where parameter, or an empty optional if absent.

      The where clause can then be processed using a QueryWhereHandler.

      Returns:
      the parsed where clause
      See Also:
    • getSearchTerm

      public Optional<SearchTermsClause> getSearchTerm()
      Returns the search terms clause parsed from the oslc.searchTerms parameter, or an empty optional if absent.
      Returns:
      the parsed search terms clause
    • getOrderBy

      public Optional<OrderByClause> getOrderBy()
      Returns the order by clause parsed from the oslc.orderBy parameter, or an empty optional if absent.
      Returns:
      the parsed order by clause
    • getProperties

      public Optional<PropertiesClause> getProperties()
      Returns the properties clause parsed from the oslc.properties parameter, or an empty optional if absent.
      Returns:
      the parsed properties clause
    • getPropertiesPredicate

      public Predicate<Object> getPropertiesPredicate()
      Returns a predicate to test whether a given property is part of the ones set in the oslc.properties parameter. If the parameter is absent or is a wildcard ("*"), the predicate returns true.

      The property used as predicate argument can be either:

      • a URI - the namespace and local part of a property (e.g. http://purl.org/dc/terms/title)
      • a String - either a URI string (e.g. http://purl.org/dc/terms/title) or prefixed name (e.g. dcterms:title)
      • a javax.xml.namespace.QName - either a namespace and local part (e.g. http://purl.org/dc/terms/title) or prefix and local part (e.g. dcterms:title)
      Any other type of argument is rejected.
      Returns:
      a predicate to test whether a given property is accepted
    • getSelect

      public Optional<SelectClause> getSelect()
      Returns the select clause parsed from the oslc.select parameter, or an empty optional if absent.
      Returns:
      the parsed select clause
    • getSelectInvertedProperties

      public Map<String,Object> getSelectInvertedProperties()
      Returns the selected properties, as found on the oslc.select parameter. The returned map can be set either:
      Returns:
      the selected properties found on the oslc.select parameter
    • getSelectPredicate

      public Predicate<Object> getSelectPredicate()
      Returns a predicate to test whether a given property is part of the ones set in the oslc.select parameter. If the parameter is absent or is a wildcard ("*"), the predicate returns true.

      The property used as predicate argument can be either:

      • a URI - the namespace and local part of a property (e.g. http://purl.org/dc/terms/title)
      • a String - either a URI string (e.g. http://purl.org/dc/terms/title) or prefixed name (e.g. dcterms:title)
      • a javax.xml.namespace.QName - either a namespace and local part (e.g. http://purl.org/dc/terms/title) or prefix and local part (e.g. dcterms:title)
      Any other type of argument is rejected.
      Returns:
      a predicate to test whether a given property is accepted
    • isPaging

      public boolean isPaging()
      Returns the oslc.paging parameter, or false if absent
      Returns:
      the oslc.paging parameter
    • getPageSize

      public Optional<Integer> getPageSize()
      Returns the oslc.pageSize parameter, or an empty optional if absent.
      Returns:
      the oslc.pageSize parameter