- logger.debug("createPolicy(PolicyRestAdapter policy, String username) as createPolicy("+policy+","+username+") called");
- String policyScope = policy.policyAdapter.getDomainDir().replace(File.separator, ".");
- //Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
- //and this transaction is intercepted up stream.
- InputStream policyXmlStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType)policy.getCorrectPolicyDataObject());
- String policyDataString;
- try {
- policyDataString = IOUtils.toString(policyXmlStream);
- } catch (IOException e) {
- policyDataString = "could not read";
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught IOException on IOUtils.toString("+policyXmlStream+")");
- throw new IllegalArgumentException("Cannot parse the policy xml from the PolicyRestAdapter.");
- }
- IOUtils.closeQuietly(policyXmlStream);
- String configPath = "";
- if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
- configPath = evaluateXPath("/Policy/Rule/AdviceExpressions/AdviceExpression[contains(@AdviceId,'ID')]/AttributeAssignmentExpression[@AttributeId='URLID']/AttributeValue/text()", policyDataString);
- } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Action")) {
- configPath = evaluateXPath("/Policy/Rule/ObligationExpressions/ObligationExpression[contains(@ObligationId, " +policy.policyAdapter.getActionAttribute()+ ")]/AttributeAssignmentExpression[@AttributeId='body']/AttributeValue/text()", policyDataString);
- }
-
- String prefix = null;
- if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
-
- prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.indexOf(policy.policyAdapter.getPolicyName()));
- if(isNullOrEmpty(policy.policyAdapter.getConfigBodyData())){
- String configData = "";
- try{
- String newConfigPath = configPath;
+ InputStream policyXmlStream = null;
+ try{
+ logger.debug("createPolicy(PolicyRestAdapter policy, String username) as createPolicy("+policy+","+username+") called");
+ String policyScope = policy.policyAdapter.getDomainDir().replace(File.separator, ".");
+ //Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
+ //and this transaction is intercepted up stream.
+ String policyDataString;
+ try {
+ policyXmlStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType)policy.getCorrectPolicyDataObject());
+ policyDataString = IOUtils.toString(policyXmlStream);
+ } catch (IOException e) {
+ policyDataString = "could not read";
+ PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught IOException on IOUtils.toString("+policyXmlStream+")");
+ throw new IllegalArgumentException("Cannot parse the policy xml from the PolicyRestAdapter.");
+ }
+ IOUtils.closeQuietly(policyXmlStream);
+ String configPath = "";
+ if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
+ configPath = evaluateXPath("/Policy/Rule/AdviceExpressions/AdviceExpression[contains(@AdviceId,'ID')]/AttributeAssignmentExpression[@AttributeId='URLID']/AttributeValue/text()", policyDataString);
+ } else if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Action")) {
+ configPath = evaluateXPath("/Policy/Rule/ObligationExpressions/ObligationExpression[contains(@ObligationId, " +policy.policyAdapter.getActionAttribute()+ ")]/AttributeAssignmentExpression[@AttributeId='body']/AttributeValue/text()", policyDataString);
+ }
+
+ String prefix = null;
+ if (policy.policyAdapter.getPolicyType().equalsIgnoreCase("Config")) {
+
+ prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.indexOf(policy.policyAdapter.getPolicyName()));
+ if(isNullOrEmpty(policy.policyAdapter.getConfigBodyData())){
+ String configData = "";