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 Summary
Fields Modifier and Type Field Description static int
DEFAULT_DAYS_KEEPING_CHANGE_EVENTS
Default number of days keeping change events.static int
DEFAULT_PAGE_SIZE
Default size of a page.static String
DEFAULT_PAGE_SIZE_PARAM_NAME
Default name for the pageSize parameter.static String
DEFAULT_START_INDEX_PARAM_NAME
Default name for thestartIndex
parameter.static int
MAX_CHANGELOG_SIZE
Maximum size of ChangeLog before re-computing the base.static int
MAX_PAGE_SIZE
Maximum size of a page.
-
Constructor Summary
Constructors Constructor Description TrsService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TrsFeedController
createTrsFeedController()
Creates theTrsFeedController
associated to this service.protected Response
getBase(Optional<Long> startingMemberId, Optional<Integer> size)
Returns the Base resource.protected Response
getChangeLog(int startingOrderId, Optional<Integer> size)
Returns a Change Log response.protected int
getDaysKeepingChangeEvents()
Gives a change to override theDEFAULT_DAYS_KEEPING_CHANGE_EVENTS
parameter.protected int
getDefaultPageSize()
Gets the default page size.protected Date
getDeletingChangeEventsDate()
Gets the starting date from which older change events will be removed when trs:Base be recomputed.protected String
getPageSizeParamName()
Gets the name for getting the pageSize parameter.protected abstract Function<ResourceSeed,URI>
getSeedsUriFactory(HttpServletRequest request)
Returns a function that can associate a URI to the resource wrapped by aResourceSeed
.protected String
getStartIndexParamName()
Gets the name for getting the startIndex parameter.protected Response
getTrackedResourceSet(Optional<Integer> size)
Returns a Tracked Resource Set response.protected boolean
isBaseOutdated(TrsServiceControl control)
Determines whether the Base needs to be recomputed because its data is considered outdated.
-
-
-
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 thestartIndex
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
-
-
Method Detail
-
createTrsFeedController
protected abstract TrsFeedController createTrsFeedController()
Creates theTrsFeedController
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 aResourceSeed
.- 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 fromDEFAULT_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 fromDEFAULT_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 fromDEFAULT_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 theDEFAULT_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; otherwisedefault 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
implieshttps://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; otherwisedefault 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
implieshttps://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; otherwisedefault 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.
-
-