Policy governor samples

You can use the sample policy governor to create custom review policies. For instructions to create policies, see Creating custom policies by using the custom policy review API.
You can find custom policy examples in the sample policy governor in WebServerPath/extensionExamples/customPolicyGovernor/SampleGovernor.jar, where WebServerPath is the web server path of your Rational® Asset Manager repository.
The policy Java archive file, CustomPolicyAPI.jar, is in the same folder. Its specific location is WebServerPath/extensionExamples/customPolicyGovernor/CustomPolicyAPI.jar.
package com.ibm.ram.extension.demo.policy;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.ibm.ram.extension.PolicyGovernor;
import com.ibm.ram.policy.AssetPolicy;
import com.ibm.ram.policy.Policy;

To map a governor to Rational Asset Manager, see Defining external policy governors

The following code is a sample Rational Asset Manager policy governor:
public class MyGovernor extends PolicyGovernor {
Note: Policies are stored in a map. To retrieve a policy from the map, enter the policy ID in the getPolicies().get(id) method.

The following code returns a list of all asset policies that are available in the policy governor:

public AssetPolicy[] getAssetPolicies() { 		
	Collection policiesCollection = getPolicies().values(); 		 		
	AssetPolicy[] policies = (AssetPolicy[])policiesCollection.toArray(new
	AssetPolicy[policiesCollection.size()]);
	return policies; 
}

The following method returns the display name for the policy governor:

public String getDescription() {
 	return "A sample governor with a few policies.";
}

The following method returns a single policy by using the policy ID:

public Policy getPolicy(String id) {
 	return (Policy)getPolicies().get(id);
}

The following method returns the private policy store. This return value is an array that lists all of the available policies defined in the governor. The policies are stored in a map; you can retrieve policies by using the getPolicies().get(id) method.

private Map getPolicies(){
 	if(policies == null){
 		initPolicies();
 	}
	return policies; 
}

The governor consists of the following policies:

//Policy = Set up policy store
private synchronized void initPolicies(){
 	policies = new HashMap();

//Policy = My XML Policy
Policy policy = new MyPolicy(this);
 	policies.put(policy.getID(), policy);

//Policy = Odd MinutePolicy
policy = new OddMinutePolicy(this);
 	policies.put(policy.getID(), policy);

//Policy = Asset Level Messages Policy
policy = new AssetMessagesPolicy(this);
 	policies.put(policy.getID(), policy);

//Policy = Artifact Level Messages Policy
policy = new ArtifactMessagesPolicy(this);
 	policies.put(policy.getID(), policy);

//WS-I WSDL Policy
policy = new WSIPolicy(this);
 	policies.put(policy.getID(), policy); 	
}

Feedback