Class TrsService


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

      • MAX_CHANGELOG_SIZE

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

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

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

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

        public static final String DEFAULT_PAGE_SIZE_PARAM_NAME
        Default name for the pageSize parameter.
        See Also:
        Constant Field Values
      • 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:
        Constant Field Values
    • Constructor Detail

      • TrsService

        public TrsService()
    • Method Detail

      • 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.
      • 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

        protected Response getTrackedResourceSet​(Optional<Integer> size)
        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:
        size - 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

        protected Response getChangeLog​(int startingOrderId,
                                        Optional<Integer> size)
        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.
        size - 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:
        1.10.1
      • getBase

        protected Response getBase​(Optional<Long> startingMemberId,
                                   Optional<Integer> size)
        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:
        startingMemberId - used for pagination, indicates the starting member on the page if present; otherwise means to retrieve the first page.
        size - 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.
      • 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.