Class PolicyManager

java.lang.Object
org.wso2.carbon.governance.api.policies.PolicyManager

public class PolicyManager extends Object
This provides the management functionality for policy artifacts stored on the registry.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PolicyManager(org.wso2.carbon.registry.core.Registry registry)
    Constructor accepting an instance of the registry to use.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addPolicy(Policy policy)
    Adds the given policy artifact to the registry.
    Finds all policy artifacts matching the given filter criteria.
    Finds all policy artifacts on the registry.
    getPolicy(String policyId)
    Fetches the given policy artifact on the registry.
    newPolicy(byte[] content)
    Create a new Schema based on content either embedded or passed to a service.
    newPolicy(byte[] content, String name)
    Create a new Schema based on content either embedded or passed to a service.
    Creates a new policy artifact from the given URL.
    void
    removePolicy(String policyId)
    Removes the given policy artifact from the registry.
    protected void
    setContent(Policy policy, org.wso2.carbon.registry.core.Resource policyResource)
    Sets content of the given policy artifact to the given resource on the registry.
    void
    Updates the given policy artifact on the registry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PolicyManager

      public PolicyManager(org.wso2.carbon.registry.core.Registry registry)
      Constructor accepting an instance of the registry to use.
      Parameters:
      registry - the instance of the registry.
  • Method Details

    • newPolicy

      public Policy newPolicy(byte[] content) throws org.wso2.carbon.registry.core.exceptions.RegistryException
      Create a new Schema based on content either embedded or passed to a service.
      Parameters:
      content - the schema content
      Returns:
      the artifact added.
      Throws:
      GovernanceException - if the operation failed.
      org.wso2.carbon.registry.core.exceptions.RegistryException
    • newPolicy

      public Policy newPolicy(byte[] content, String name) throws org.wso2.carbon.registry.core.exceptions.RegistryException
      Create a new Schema based on content either embedded or passed to a service.
      Parameters:
      content - the schema content
      name - the schema name
      Returns:
      the artifact added.
      Throws:
      GovernanceException - if the operation failed.
      org.wso2.carbon.registry.core.exceptions.RegistryException
    • newPolicy

      public Policy newPolicy(String url) throws GovernanceException
      Creates a new policy artifact from the given URL.
      Parameters:
      url - the given URL.
      Returns:
      the artifact added.
      Throws:
      GovernanceException - if the operation failed.
    • addPolicy

      public void addPolicy(Policy policy) throws GovernanceException
      Adds the given policy artifact to the registry. Please do not use this method to update an existing artifact use the update method instead. If this method is used to update an existing artifact, all existing properties (such as lifecycle details) will be removed from the existing artifact.
      Parameters:
      policy - the policy artifact.
      Throws:
      GovernanceException - if the operation failed.
    • updatePolicy

      public void updatePolicy(Policy policy) throws GovernanceException
      Updates the given policy artifact on the registry.
      Parameters:
      policy - the policy artifact.
      Throws:
      GovernanceException - if the operation failed.
    • getPolicy

      public Policy getPolicy(String policyId) throws GovernanceException
      Fetches the given policy artifact on the registry.
      Parameters:
      policyId - the identifier of the policy artifact.
      Returns:
      the policy artifact.
      Throws:
      GovernanceException - if the operation failed.
    • removePolicy

      public void removePolicy(String policyId) throws GovernanceException
      Removes the given policy artifact from the registry.
      Parameters:
      policyId - the identifier of the policy artifact.
      Throws:
      GovernanceException - if the operation failed.
    • setContent

      protected void setContent(Policy policy, org.wso2.carbon.registry.core.Resource policyResource) throws GovernanceException
      Sets content of the given policy artifact to the given resource on the registry.
      Parameters:
      policy - the policy artifact.
      policyResource - the content resource.
      Throws:
      GovernanceException - if the operation failed.
    • findPolicies

      public Policy[] findPolicies(PolicyFilter criteria) throws GovernanceException
      Finds all policy artifacts matching the given filter criteria.
      Parameters:
      criteria - the filter criteria to be matched.
      Returns:
      the policy artifacts that match.
      Throws:
      GovernanceException - if the operation failed.
    • getAllPolicies

      public Policy[] getAllPolicies() throws GovernanceException
      Finds all policy artifacts on the registry.
      Returns:
      all policy artifacts on the registry.
      Throws:
      GovernanceException - if the operation failed.