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 Collection<ProjectArea>
getExposedProjectAreas()
Gets all theOSLC project areas exposed
to TRS feeds.TrsFeedController
getFeedController(String feedIdentifer)
Gets theTrsFeedController
for a managed TRS feed.protected abstract URI
getFeedEndpoint(TrsFeed feed)
Gets aTrsFeed
endpoint.Collection<TrsFeed>
getFeeds()
Gets every managedTrsFeed
.Person
getFunctionalUser(boolean includeBoundConsumersCount)
Gets the TRS functional user.Optional<String>
getFunctionalUserIdentifier()
Gets the TRS functional user identifier.static TrsFeedManager
getInstance()
Gets theTrsFeedManager
singleton instance.Collection<ProjectArea>
getNonExposedProjectAreas()
Gets all theOSLC project areas not exposed
to TRS feeds.protected abstract Optional<ResourceSeed>
getProjectAreaSeed(ProjectArea projectArea)
Gets the optionalresource seed
corresponding to a TRS-exposedProjectArea
resource.void
populateRootServices(RootServices rootServices)
Populates aRootServices
resource with registered TRS feeds.void
registerFeedController(TrsFeedController trsFeedController)
Registers a TRS feed controller.void
removeFunctionalUser()
Removes the current TRS functional user.Person
setFunctionalUser(String identifier)
Sets the TRS functional user.static void
setInstance(TrsFeedManager trsFeedManager)
Sets theTrsFeedManager
singleton instance.
-
-
-
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.
-
getFunctionalUserIdentifier
public Optional<String> getFunctionalUserIdentifier() throws TrsFunctionalUserStoreException
Gets the TRS functional user identifier.- Returns:
- the TRS functional user identifier if any.
- Throws:
TrsFunctionalUserStoreException
- if an error prevents getting the TRS functional user identifier
-
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.This action corrupts all the registered TRS feeds to ensure no event is missed while no functional user is assigned.
By corrupting the feeds, a rebuild will be requested when a functional user is reassigned (even if it is the same as before).- Throws:
TrsFunctionalUserStoreException
- if an error prevents the TRS functional user removal.
-
getExposedProjectAreas
public Collection<ProjectArea> getExposedProjectAreas() throws ProjectAreaStoreException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException
Gets all theOSLC project areas exposed
to TRS feeds. This method is a shortcut forProjectAreaStore.getInstance().getAccessibleOslcProjectAreas(getFunctionalUser(false).getIdentifier())
.- Returns:
- all the OSLC 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.
-
getNonExposedProjectAreas
public Collection<ProjectArea> getNonExposedProjectAreas() throws ProjectAreaStoreException, MissingTrsFunctionalUserException, UnresolvedTrsFunctionalUserException, TrsFunctionalUserStoreException
Gets all theOSLC project areas not exposed
to TRS feeds. This method is a shortcut forProjectAreaStore.getInstance().getRestrictedOslcProjectAreas(getFunctionalUser(false).getIdentifier())
.- Returns:
- all the OSLC 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.
-
getProjectAreaSeed
protected abstract Optional<ResourceSeed> getProjectAreaSeed(ProjectArea projectArea)
Gets the optionalresource seed
corresponding to a TRS-exposedProjectArea
resource.Applications must override this method to provide the project area resource seed, if they are providing the
process
feed, to enable the exposed-projects-mismatch checking. The exposed-projects-mismatch checking ensures that all OSLC-enabled projects, to which the TRS functional user has access, are indeed exposed by the TRS feeds; otherwise arebuild hint
isinformed
to the admin user.- Parameters:
projectArea
- the exposed project area- Returns:
- the resource seed corresponding to a TRS-exposed project area resource, or an empty optional.
- Since:
- 3.5.1
-
-