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 intDEFAULT_DAYS_KEEPING_CHANGE_EVENTSDefault number of days keeping change events.static intDEFAULT_PAGE_SIZEDefault size of a page.static StringDEFAULT_PAGE_SIZE_PARAM_NAMEDefault name for the pageSize parameter.static StringDEFAULT_START_INDEX_PARAM_NAMEDefault name for thestartIndexparameter.static intMAX_CHANGELOG_SIZEMaximum size of ChangeLog before re-computing the base.static intMAX_PAGE_SIZEMaximum 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 TrsFeedControllercreateTrsFeedController()Creates theTrsFeedControllerassociated to this service.ResponsedownloadFeed()ResponsegetBase(Long startMemberId, Integer pageSize)Returns the Base resource.ResponsegetChangeLog(Integer startingOrderId, Integer pageSize)Returns a Change Log response.protected intgetDaysKeepingChangeEvents()Gives a change to override theDEFAULT_DAYS_KEEPING_CHANGE_EVENTSparameter.protected intgetDefaultPageSize()Gets the default page size.protected DategetDeletingChangeEventsDate()Gets the starting date from which older change events will be removed when trs:Base be recomputed.protected StringgetPageSizeParamName()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 StringgetStartIndexParamName()Gets the name for getting the startIndex parameter.ResponsegetTrackedResourceSet(Integer pageSize)Returns a Tracked Resource Set response.protected booleanisBaseOutdated(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 thestartIndexparameter.- 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 theTrsFeedControllerassociated to this service. This method is called only once for this class, the first time the store is being requested.- Returns:
- the
TrsFeedControllerassociated 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_EVENTSparameter.- Returns:
- the number of days to keep change events.
-
getTrackedResourceSet
public Response getTrackedResourceSet(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; otherwisedefault page sizeis used.- Returns:
- the response contained a Tracked Resource Set resource.
- Throws:
OslcWebApplicationException- (BAD_REQUEST) if page size is present and less than 1.
-
getChangeLog
public Response getChangeLog(Integer startingOrderId, 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/trsimplieshttps://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; otherwisedefault page sizeis 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
public Response getBase(Long startMemberId, 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/trsimplieshttps://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; otherwisedefault page sizeis used.- Returns:
- the Base resource.
- Throws:
OslcWebApplicationException- (BAD_REQUEST) if page size is present and less than 1.
-
downloadFeed
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:
trueif the Base is outdated and needs to be recomputed;falseotherwise.
-
-