Class TrsFeedManager
- java.lang.Object
-
- com.sodius.oslc.server.trs.services.TrsFeedManager
-
public abstract class TrsFeedManager extends Object
Manages the TRS feeds and functional user. For details onTrsFeedController
registering, seeregisterFeedController(TrsFeedController)
.- Since:
- 3.3.0
-
-
Constructor Summary
Constructors Constructor Description TrsFeedManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Optional<TrsProcess>
abort(String process, String feed, String user)
Aborts a running/completed process.Optional<TrsProcess>
conclude(String process, String feed, String user)
Concludes a completed process.Optional<TrsProcess>
fetch(String process, String feed)
Fetches a running or completed process.TrsProcess
forceUpdate(String feed, Set<String> projectAreasScope, String user)
Starts aforce update
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.Collection<ProjectArea>
getExposedProjectAreas()
Gets all project areas that are currently exposed in the TRS Process feed.TrsFeedController
getFeedController(String feedIdentifer)
Gets theTrsFeedController
for a managed TRS feed.protected abstract URI
getFeedEndpoint(TrsFeed feed)
Gets aTrsFeed
endpoint.Collection<ProjectArea>
getFeedProjectAreas(String feed)
Gets theexposed project areas
with the number of resources on a given feed.Collection<TrsFeed>
getFeeds()
Gets every managedTrsFeed
.Person
getFunctionalUser(boolean includeBoundConsumersCount)
Gets the TRS functional user.static TrsFeedManager
getInstance()
Gets theTrsFeedManager
singleton instance.boolean
isExposedProjectArea(String projectAreaId)
Determines whether the given project is currently exposed in the TRS Process feed.protected boolean
isProjectArea(ResourceSeed resourceSeed)
Determines whether the given resource seed represents aproject area
.void
populateRootServices(RootServices rootServices)
Populates aRootServices
resource with registered TRS feeds.TrsProcess
rebuild(String feed, String user)
Starts arebuild
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.void
registerFeedController(TrsFeedController trsFeedController)
Registers a TRS feed controller.void
removeFunctionalUser()
Removes the current TRS functional user.TrsProcess
repair(String feed, Set<String> projectAreasScope, String user)
Starts arepair
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.Person
setFunctionalUser(String identifier)
Sets the TRS functional user.static void
setInstance(TrsFeedManager trsFeedManager)
Sets theTrsFeedManager
singleton instance.TrsProcess
validate(String feed, Set<String> projectAreasScope, String user)
Starts avalidation
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.
-
-
-
Method Detail
-
setInstance
public static void setInstance(TrsFeedManager trsFeedManager)
Sets theTrsFeedManager
singleton instance.- Parameters:
trsFeedManager
- theTrsFeedManager
to use.
-
getInstance
public static TrsFeedManager getInstance()
Gets theTrsFeedManager
singleton instance.- Returns:
- the
TrsFeedManager
singleton instance. - See Also:
setInstance(TrsFeedManager)
-
registerFeedController
public final void registerFeedController(TrsFeedController trsFeedController)
Registers a TRS feed controller. A TrsFeedController must be registered before any call on theTrsAdminService
or before anyTrsService
using it is registered. Typically, aTrsFeedController
must be registered during the application initialization phase after theTrsFeedManager
is configured.If the
collector strategy
of the feed controller is to always collect resource events or to collect them specifically at startup time, a background thread is started toquery
changes that occurred in the host application since the last TRS refresh, provided TRS content is yet computed.- Parameters:
trsFeedController
- the TRS feed controller.
-
getFeedController
public TrsFeedController getFeedController(String feedIdentifer) throws MissingTrsFeedException
Gets theTrsFeedController
for a managed TRS feed.- Parameters:
feedIdentifer
- the TRS feed identifier.- Returns:
- the TRS feed controller.
- Throws:
MissingTrsFeedException
- if there are no TRS feed identified by feedIdentifier.
-
getFeeds
public Collection<TrsFeed> getFeeds()
Gets every managedTrsFeed
.- Returns:
- a collection of
TrsFeed
.
-
populateRootServices
public void populateRootServices(RootServices rootServices)
Populates aRootServices
resource with registered TRS feeds.- Parameters:
rootServices
- theRootServices
resource to populate.
-
getFunctionalUser
public Person getFunctionalUser(boolean includeBoundConsumersCount) throws MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException
Gets the TRS functional user.- Parameters:
includeBoundConsumersCount
- whether or not to include the bound consumers count.- Returns:
- the TRS functional user as an OSLC
Person
. - Throws:
MissingTrsFunctionalUserException
- if the TRS functional user is not set.UnresolvedTrsFunctionalUserException
- if the TRS functional user can't be resolved.TrsFunctionalUserStoreException
- if an error prevents getting the TRS functional user.
-
setFunctionalUser
public Person setFunctionalUser(String identifier) throws UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException
Sets the TRS functional user. Internally verify the user withPersonStore.getInstance().getPerson(identifier)
.- Parameters:
identifier
- the identifier of the TRS functional user to set.- Returns:
- the new TRS functional user as an OSLC Person.
- Throws:
UnresolvedTrsFunctionalUserException
- if the TRS functional user can't be resolved.TrsFunctionalUserStoreException
- if an error prevents setting the TRS functional user.
-
removeFunctionalUser
public void removeFunctionalUser() throws TrsFunctionalUserStoreException
Removes the current TRS functional user.- Throws:
TrsFunctionalUserStoreException
- if an error prevents the TRS functional user removal.
-
getExposedProjectAreas
public Collection<ProjectArea> getExposedProjectAreas() throws ProjectAreaStoreException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, TrsStoreException
Gets all project areas that are currently exposed in the TRS Process feed. This method is notably useful to determine what should be replied when getting theAccessContextList
resource.This method returns a snapshot of the Process feed current content. Be aware that a project area having project associations is not part of the returned list if no repair process (including the TRS job) has been completed since then to incorporate the project in the feed. The
ProjectAreaStore.getAccessibleOslcProjectAreas(String)
method may be used to know which project areas must eventually be part of the Process feed- Returns:
- all the project areas exposed to TRS feeds.
- Throws:
ProjectAreaStoreException
- if project areas cannot be resolved.MissingTrsFunctionalUserException
- if the TRS functional user is not set.UnresolvedTrsFunctionalUserException
- if the TRS functional user can't be resolved.TrsFunctionalUserStoreException
- if an error prevents getting the TRS functional user.TrsStoreException
- if an error prevents accessing the TRS store.
-
isExposedProjectArea
public boolean isExposedProjectArea(String projectAreaId) throws TrsStoreException
Determines whether the given project is currently exposed in the TRS Process feed.- Parameters:
projectAreaId
- the project identifier.- Returns:
true
if the project is present in Process feed- Throws:
TrsStoreException
- if an error prevents accessing the TRS store.- Since:
- 3.11.0
-
validate
public TrsProcess validate(String feed, Set<String> projectAreasScope, String user) throws MissingTrsFeedException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, ConcurrentTrsProcessException, TrsStoreException, ProjectAreaStoreException
Starts avalidation
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.- Parameters:
feed
- the target feed identifier.projectAreasScope
- optional subset of project areas to validate. Use an empty set to validate all exposed project areas.user
- the executing user, typically the logged-in user.- Returns:
- the validation created process or the previously created process, for the same feed, if one was already running/completed.
- Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.MissingTrsFunctionalUserException
- if the functional user is not set.UnresolvedTrsFunctionalUserException
- if the functional user is not known.TrsFunctionalUserStoreException
- if the functional user cannot be resolved.ConcurrentTrsProcessException
- if another process is already running.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.ProjectAreaStoreException
- if the exposed project areas cannot be resolved.- Since:
- 3.11.0
-
repair
public TrsProcess repair(String feed, Set<String> projectAreasScope, String user) throws MissingTrsFeedException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, ConcurrentTrsProcessException, TrsStoreException, ProjectAreaStoreException
Starts arepair
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.Note: if the feed is not build by the moment this method is called, a rebuild process is started instead.
- Parameters:
feed
- the target feed identifier.projectAreasScope
- optional subset of project areas to repair. Use an empty set to validate all exposed project areas.user
- the executing user, typically the logged-in user.- Returns:
- the repair created process or the previously created process, for the same feed, if one was already running/completed.
- Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.MissingTrsFunctionalUserException
- if the functional user is not set.UnresolvedTrsFunctionalUserException
- if the functional user is not known.TrsFunctionalUserStoreException
- if the functional user cannot be resolved.ConcurrentTrsProcessException
- if another process is already running.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.ProjectAreaStoreException
- if the exposed project areas cannot be resolved.- Since:
- 3.11.0
-
forceUpdate
public TrsProcess forceUpdate(String feed, Set<String> projectAreasScope, String user) throws MissingTrsFeedException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, ConcurrentTrsProcessException, TrsStoreException, ProjectAreaStoreException
Starts aforce update
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.- Parameters:
feed
- the target feed identifier.projectAreasScope
- subset of project areas to validate.user
- the executing user, typically the logged-in user.- Returns:
- the force update created process or the previously created process, for the same feed, if one was already running/completed.
- Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.MissingTrsFunctionalUserException
- if the functional user is not set.UnresolvedTrsFunctionalUserException
- if the functional user is not known.TrsFunctionalUserStoreException
- if the functional user cannot be resolved.ConcurrentTrsProcessException
- if another process is already running.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.ProjectAreaStoreException
- if the exposed project areas cannot be resolved.- Since:
- 3.11.0
-
rebuild
public TrsProcess rebuild(String feed, String user) throws MissingTrsFeedException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, ConcurrentTrsProcessException, TrsStoreException, ProjectAreaStoreException
Starts arebuild
process, on a separate thread, for a given feed if no other process is already running (or completed) for the same target feed.- Parameters:
feed
- the target feed identifier.user
- the executing user, typically the logged-in user.- Returns:
- the rebuilding created process or the previously created process, for the same feed, if one was already running/completed.
- Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.MissingTrsFunctionalUserException
- if the functional user is not set.UnresolvedTrsFunctionalUserException
- if the functional user is not known.TrsFunctionalUserStoreException
- if the functional user cannot be resolved.ConcurrentTrsProcessException
- if another process is already running.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.ProjectAreaStoreException
- if the exposed project areas cannot be resolved.- Since:
- 3.11.0
-
fetch
public Optional<TrsProcess> fetch(String process, String feed) throws MissingTrsFeedException
Fetches a running or completed process.- Parameters:
process
- the process identifier to fetch.feed
- the owner feed.- Returns:
- an empty
Optional
if no process exists; the contained reference otherwise. - Throws:
MissingTrsFeedException
- if nofeed
exists.- Since:
- 3.11.0
-
abort
public Optional<TrsProcess> abort(String process, String feed, String user) throws MissingTrsFeedException, TrsStoreException
Aborts a running/completed process.- Parameters:
process
- the process id to abort.feed
- the feed identifier.user
- the executing user, typically the logged-in user.- Returns:
- an empty
Optional
if no process exists; the contained reference of the aborted process otherwise. - Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.- Since:
- 3.11.0
-
conclude
public Optional<TrsProcess> conclude(String process, String feed, String user) throws MissingTrsFeedException, TrsStoreException
Concludes a completed process.- Parameters:
process
- the completed process id to conclude.feed
- the feed identifier.user
- the executing user, typically the logged-in user.- Returns:
- an empty
Optional
if no process exists; the contained reference of the concluded process otherwise. - Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.TrsStoreException
- if the lock cannot be acquired to avoid concurrency.- Since:
- 3.11.0
-
getFeedProjectAreas
public Collection<ProjectArea> getFeedProjectAreas(String feed) throws MissingTrsFeedException, ProjectAreaStoreException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException, TrsStoreException
Gets theexposed project areas
with the number of resources on a given feed.- Parameters:
feed
- the given feed identifier.- Returns:
- the exposed project areas with the corresponding number of resources on the given feed.
- Throws:
MissingTrsFeedException
- if no feed is registered withfeed
identifier.ProjectAreaStoreException
- if project areas cannot be resolved.MissingTrsFunctionalUserException
- if the TRS functional user is not set.UnresolvedTrsFunctionalUserException
- if the functional user is not known.TrsFunctionalUserStoreException
- if an error prevents getting the TRS functional user.TrsStoreException
- if members cannot be counted.- Since:
- 3.11.0
-
isProjectArea
protected boolean isProjectArea(ResourceSeed resourceSeed)
Determines whether the given resource seed represents aproject area
.Default implementation returns
true
if the resource seed has aproject area id
that is equal to itsid
. Subclasses may override this method if a different strategy should apply.- Parameters:
resourceSeed
- a resource seed- Returns:
true
if the resource seed represents a project area,false
otherwise- Since:
- 3.11.0
-
-