Class ProcessSchemePolicySet

java.lang.Object
com.sodius.oslc.server.process.scheme.model.ProcessSchemePolicySet

public class ProcessSchemePolicySet extends Object
Provides facilities to lookup existing scheme policies from the store and to perform updates. Developer is recommended to use this class whenever possible, rather than interacting with the lower level ProcessSchemePolicyStore.
Since:
3.5.0
  • Method Details

    • fromStore

      public static ProcessSchemePolicySet fromStore(String schemeIdentifier, ProcessSchemePolicyStore store) throws ProcessSchemeStoreException
      Reads existing policies from the store for a given scheme.
      Parameters:
      schemeIdentifier - the identifier of the scheme of interest.
      store - the scheme policy store.
      Returns:
      the existing scheme policies.
      Throws:
      ProcessSchemeStoreException - if the policies cannot be read from the store.
    • onProcessSchemePolicyChangeSet

      public static void onProcessSchemePolicyChangeSet(Consumer<ProcessSchemePolicyChangeSet> action)
      Registers an action to get executed when a process scheme policy changes.

      Changes that occurred before the registration are not notified, registrations should be done at application startup. All actions will be executed on a dedicated thread and no exceptions must be thrown but handled internally.

      Actions are all automatically unregistered when the application is disposed.

      Parameters:
      action - the action to execute.
      Since:
      3.9.0
    • offProcessSchemePolicyChangeSet

      public static void offProcessSchemePolicyChangeSet(Consumer<ProcessSchemePolicyChangeSet> action)
      Removes an action from being notified when a process scheme policy changes.

      Actions are all automatically unregistered when the application is disposed.

      Parameters:
      action - the action to execute.
      Since:
      3.9.0
    • isEmpty

      public boolean isEmpty()
      Returns true if there's no policies in the store for the underlying scheme.
      Returns:
      true if there's no policies in the store for the underlying scheme.
    • getSchemePolicy

      public Optional<ProcessSchemePolicy> getSchemePolicy()
      Returns the existing policy for the scheme, if any.
      Returns:
      the existing policy for the scheme, an empty Optional if none.
    • getFriendPolicy

      public Optional<FriendPolicy> getFriendPolicy(Friend friend)
      Returns the existing policy for a friend, if any.
      Parameters:
      friend - the friend application.
      Returns:
      the existing policy for a friend, an empty Optional if none.
    • getResourceTypePolicy

      public Optional<ResourceTypePolicy> getResourceTypePolicy(Friend friend, URI resourceType)
      Returns the existing policy for the given resource type, if any.
      Parameters:
      friend - the friend application.
      resourceType - the resource type
      Returns:
      the existing policy for the given resource type, an empty Optional if none.
    • getLinkTypePolicy

      public Optional<LinkTypePolicy> getLinkTypePolicy(Friend friend, URI resourceType, URI linkType)
      Returns the existing policy for the given link type, if any.
      Parameters:
      friend - the friend application.
      resourceType - the resource type
      linkType - the link type
      Returns:
      the existing policy for the given link type, an empty Optional if none.
    • storeUpdater

      Returns a ProcessSchemePolicySet.PolicyStoreUpdater to perform updates in the store. The same unique updater instance is returned for each call of this method.
      Returns:
      the associated updater instance.
    • updateTo

      public void updateTo(String newSchemeId, Map<ProcessSchemePolicyStore.PolicyKey,String> newPolicies, List<String> projectAreas)
      Updates this policy set to a new scheme policies.

      This is an in-memory update, the store is not affected.

      Parameters:
      newSchemeId - the new scheme identifier.
      newPolicies - the new scheme policies.
      projectAreas - the impacted project areas.
      Since:
      3.9.0