org.wso2.carbon.governance.api.policies

## 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 and Description
    `PolicyManager(org.wso2.carbon.registry.core.Registry registry)` Constructor accepting an instance of the registry to use.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPolicy(Policy policy)` Adds the given policy artifact to the registry.
    `Policy[]` | `findPolicies(PolicyFilter criteria)` Finds all policy artifacts matching the given filter criteria.
    `Policy[]` | `getAllPolicies()` Finds all policy artifacts on the registry.
    `Policy` | `getPolicy(String policyId)` Fetches the given policy artifact on the registry.
    `Policy` | `newPolicy(byte[] content)` Create a new Schema based on content either embedded or passed to a service.
    `Policy` | `newPolicy(byte[] content, String name)` Create a new Schema based on content either embedded or passed to a service.
    `Policy` | `newPolicy(String url)` 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` | `updatePolicy(Policy policy)` 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 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`

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

Copyright © 2017 WSO2. All Rights Reserved.