Class PolicyManager


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

      • 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 Detail

      • 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
      • 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.