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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPolicy(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.PolicygetPolicy(String policyId)Fetches the given policy artifact on the registry.PolicynewPolicy(byte[] content)Create a new Schema based on content either embedded or passed to a service.PolicynewPolicy(byte[] content, String name)Create a new Schema based on content either embedded or passed to a service.PolicynewPolicy(String url)Creates a new policy artifact from the given URL.voidremovePolicy(String policyId)Removes the given policy artifact from the registry.protected voidsetContent(Policy policy, org.wso2.carbon.registry.core.Resource policyResource)Sets content of the given policy artifact to the given resource on the registry.voidupdatePolicy(Policy policy)Updates the given policy artifact on 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 contentname- 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.
-
-