Class TrsService

java.lang.Object
com.sodius.oslc.server.trs.services.TrsService

public abstract class TrsService extends Object
Abstract TRS service implementation.
Since:
1.10.0
  • Field Details

    • MAX_CHANGELOG_SIZE

      public static final int MAX_CHANGELOG_SIZE
      Maximum size of ChangeLog before re-computing the base.
      See Also:
    • MAX_PAGE_SIZE

      public static final int MAX_PAGE_SIZE
      Maximum size of a page.
      See Also:
    • DEFAULT_PAGE_SIZE

      public static final int DEFAULT_PAGE_SIZE
      Default size of a page.
      See Also:
    • DEFAULT_START_INDEX_PARAM_NAME

      public static final String DEFAULT_START_INDEX_PARAM_NAME
      Default name for the startIndex parameter.
      See Also:
    • DEFAULT_PAGE_SIZE_PARAM_NAME

      public static final String DEFAULT_PAGE_SIZE_PARAM_NAME
      Default name for the pageSize parameter.
      See Also:
    • DEFAULT_DAYS_KEEPING_CHANGE_EVENTS

      public static final int DEFAULT_DAYS_KEEPING_CHANGE_EVENTS
      Default number of days keeping change events. Those events older than these days will be removed.
      See Also:
  • Constructor Details

    • TrsService

      public TrsService()
  • Method Details

    • createTrsFeedController

      protected abstract TrsFeedController createTrsFeedController()
      Creates the TrsFeedController associated to this service. This method is called only once for this class, the first time the store is being requested.
      Returns:
      the TrsFeedController associated to this service.
      Since:
      3.3.0
    • getSeedsUriFactory

      protected abstract Function<ResourceSeed,URI> getSeedsUriFactory(HttpServletRequest request)
      Returns a function that can associate a URI to the resource wrapped by a ResourceSeed.
      Parameters:
      request - the current HTTP request.
      Returns:
      a function to compute URIs.
    • getDefaultPageSize

      protected int getDefaultPageSize()
      Gets the default page size. Subclasses may override this method to handle something different from DEFAULT_PAGE_SIZE.
      Returns:
      the DEFAULT_PAGE_SIZE.
    • getStartIndexParamName

      protected String getStartIndexParamName()
      Gets the name for getting the startIndex parameter. Subclasses may override this method to handle something different from DEFAULT_START_INDEX_PARAM_NAME.
      Returns:
      the DEFAULT_START_INDEX_PARAM_NAME.
    • getPageSizeParamName

      protected String getPageSizeParamName()
      Gets the name for getting the pageSize parameter. Subclasses may override this method to handle something different from DEFAULT_PAGE_SIZE_PARAM_NAME.
      Returns:
      the DEFAULT_PAGE_SIZE_PARAM_NAME.
    • getDeletingChangeEventsDate

      protected final Date getDeletingChangeEventsDate()
      Gets the starting date from which older change events will be removed when trs:Base be recomputed.
      Returns:
      starting date from which older change events will be removed.
    • getDaysKeepingChangeEvents

      protected int getDaysKeepingChangeEvents()
      Gives a change to override the DEFAULT_DAYS_KEEPING_CHANGE_EVENTS parameter.
      Returns:
      the number of days to keep change events.
    • getTrackedResourceSet

      @GET @Produces({"text/xml","application/xml","application/rdf+xml","text/turtle"}) public Response getTrackedResourceSet(@QueryParam("oslc.pageSize") Integer pageSize)
      Returns a Tracked Resource Set response. This method refreshes the Base resource if it is outdated and recomputes the change log using the underlying TrackedResourceSetCollector.
      Parameters:
      pageSize - used for pagination, indicates the page size if present; otherwise default page size is used.
      Returns:
      the response contained a Tracked Resource Set resource.
      Throws:
      OslcWebApplicationException - (BAD_REQUEST) if page size is present and less than 1.
    • getChangeLog

      @GET @Path("changeLog") @Produces({"text/xml","application/xml","application/rdf+xml","text/turtle"}) public Response getChangeLog(@QueryParam("startIndex") Long startingOrderId, @QueryParam("oslc.pageSize") Integer pageSize)
      Returns a Change Log response.

      It is required the end-point path for the Change Log is the end point path of the Tracked Resource Set concatenated with "/changeLog" (e.g. https://server/app/trs implies https://server/app/trs/changeLog).

      Parameters:
      startingOrderId - used for pagination, indicates the starting change order on the page.
      pageSize - used for pagination, indicates the page size if present; otherwise default page size is used.
      Returns:
      the response contained a Change Log resource.
      Throws:
      OslcWebApplicationException - (BAD_REQUEST) if page size is present and less than 1.
      Since:
      4.0.0
    • getBase

      @GET @Path("base") @Produces({"text/xml","application/xml","application/rdf+xml","text/turtle"}) public Response getBase(@QueryParam("startIndex") Long startMemberId, @QueryParam("oslc.pageSize") Integer pageSize)
      Returns the Base resource. This method computes the Base resource if it has never been computed.

      It is required the end-point path for the Base is the end point path of the Tracked Resource Set concatenated with "/base" (e.g. https://server/app/trs implies https://server/app/trs/base).

      Parameters:
      startMemberId - used for pagination, indicates the starting member on the page if present; otherwise means to retrieve the first page.
      pageSize - used for pagination, indicates the page size if present; otherwise default page size is used.
      Returns:
      the Base resource.
      Throws:
      OslcWebApplicationException - (BAD_REQUEST) if page size is present and less than 1.
    • downloadFeed

      @Path("download") @GET @Produces({"application/zip","text/html"}) public Response downloadFeed()
    • isBaseOutdated

      protected boolean isBaseOutdated(TrsServiceControl control)
      Determines whether the Base needs to be recomputed because its data is considered outdated. If the Base is considered outdated, all events of the ChangeLog are transfered to the Base and the ChangeLog becomes empty. The default strategy is to recompute the Base on a daily basis.
      Parameters:
      control - the control variables.
      Returns:
      true if the Base is outdated and needs to be recomputed; false otherwise.