Here is some JCN code that gets a policy type/name and interates through the properties and adds them to the Environment tree. Not the REST API but shows how to do it is Java using IntegrationAPI. Note this changed between IIB and ACE.
You can pass in the policy type/name to get the properties for via the LocalEnvironment or UDPs...
HTH
Regards
public class GetPolicyProperties extends
MbJavaComputeNode {
private final static String POLICY_TYPE = "policyType";
private final static String POLICY_NAME = "policyName";
public void evaluate(MbMessageAssembly assembly) throws MbException {
String policyType, policyName;
boolean processUDCS = true;
MbOutputTerminal out = getOutputTerminal("out");
//Get the environment
MbMessage env = assembly.getGlobalEnvironment();
//Get the local environment
MbMessage le = assembly.getLocalEnvironment();
MbElement typeElement = le.getRootElement().getFirstElementByPath("Variables/Input/policyType");
if (typeElement == null) {
//get the policy type and name from UDPs defined in flow
policyType = (String)getUserDefinedAttribute(POLICY_TYPE);
if (policyType == null) {
MbService.logWarning(this,
"UDP_Error",
ErrorMessages.MESSAGE_SOURCE,
ErrorMessages.POLICY_TYPE_ERROR,
"",
null);
processUDCS = false;
}
}
else {
policyType = typeElement.getValueAsString();
}
MbElement nameElement = le.getRootElement().getFirstElementByPath("Variables/Input/policyName");
if (nameElement == null) {
policyName = (String)getUserDefinedAttribute(POLICY_NAME);
if (policyName == null) {
MbService.logWarning(this,
"UDP_Error",
ErrorMessages.MESSAGE_SOURCE,
ErrorMessages.POLICY_NAME_ERROR,
"",
null);
processUDCS = false;
}
}
else {
policyName = nameElement.getValueAsString();
}
if (processUDCS) {
try {
MbElement geRoot = env.getRootElement();
MbElement var = geRoot.createElementAsLastChild(MbElement.TYPE_NAME,"Variables",null);
MbElement pol = var.createElementAsLastChild(MbElement.TYPE_NAME,"Policy",null);
MbPolicy policy = getPolicy(policyType, policyName);
//String polType = policy.getType().toString();
Collection<MbProperty> policyProperties = policy.getProperties();
Iterator<MbProperty> iterator = policyProperties.iterator();
// while loop
while (iterator.hasNext()) {
MbProperty policyProperty = iterator.next();
String name = policyProperty.name().toString();
String value = policyProperty.value().toString(); //keys.nextElement().toString();
MbElement ele = pol.createElementAsFirstChild(MbElement.TYPE_NAME,"Property",null);
ele.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "Value", value);
ele.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "Key", name);
}
pol.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE,"Type",policyType);
pol.createElementAsFirstChild(MbXMLNSC.ATTRIBUTE, "Name", policyName);
}
catch (Exception e) {
}
}
// The following should only be changed
// if not propagating message to the 'out' terminal
out.propagate(assembly);
}
public static class ErrorMessages extends ListResourceBundle
{
public static final String MESSAGE_SOURCE = ErrorMessages.class.getName();
public final static String POLICY_TYPE_ERROR = "Error with policyType UDP";
public final static String POLICY_NAME_ERROR = "Error with policyName UDP";
private Object[][] messages =
{
{POLICY_TYPE_ERROR,
"Check definition for: " + POLICY_TYPE
},
{POLICY_NAME_ERROR,
"Check definition for: " + POLICY_NAME
}
};
public Object[][] getContents()
{
return messages;
}
}