2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.pap.xacml.rest.components;
24 import java.io.IOException;
25 import java.io.PrintWriter;
27 import java.net.URISyntaxException;
28 import java.nio.charset.Charset;
29 import java.nio.file.Files;
30 import java.nio.file.Path;
31 import java.nio.file.Paths;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.Iterator;
35 import java.util.List;
37 import java.util.UUID;
38 import java.util.regex.Matcher;
39 import java.util.regex.Pattern;
41 import javax.script.SimpleBindings;
43 import org.apache.commons.io.FilenameUtils;
44 import org.onap.policy.common.logging.eelf.MessageCodes;
45 import org.onap.policy.common.logging.eelf.PolicyLogger;
46 import org.onap.policy.common.logging.flexlogger.FlexLogger;
47 import org.onap.policy.common.logging.flexlogger.Logger;
48 import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
49 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
50 import org.onap.policy.rest.adapter.PolicyRestAdapter;
51 import org.onap.policy.rest.jpa.BRMSParamTemplate;
53 import com.att.research.xacml.std.IdentifierImpl;
55 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
56 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
57 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
58 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
59 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
60 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
61 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
62 import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
63 import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
64 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
65 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
66 import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
67 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
69 public class CreateBrmsParamPolicy extends Policy {
71 private static final Logger LOGGER = FlexLogger.getLogger(CreateBrmsParamPolicy.class);
73 public CreateBrmsParamPolicy() {
77 public CreateBrmsParamPolicy(PolicyRestAdapter policyAdapter) {
78 this.policyAdapter = policyAdapter;
79 this.policyAdapter.setConfigType(policyAdapter.getConfigType());
83 public String expandConfigBody(String ruleContents, Map<String, String> brmsParamBody) {
85 Map<String,String> copyMap=new HashMap<>();
86 copyMap.putAll(brmsParamBody);
87 copyMap.put("policyName", policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")));
88 copyMap.put("policyScope", policyAdapter.getDomainDir());
89 copyMap.put("policyVersion",policyAdapter.getHighestVersion().toString());
90 copyMap.put("unique", ("p"+policyName+UUID.randomUUID().toString()).replaceAll("[^A-Za-z0-9]", ""));
92 //Finding all the keys in the Map data-structure.
93 Iterator<String> iterator = copyMap.keySet().iterator();
96 while(iterator.hasNext()) {
97 //Converting the first character of the key into a lower case.
98 String input= iterator.next();
99 String output = Character.toLowerCase(input.charAt(0)) +
100 (input.length() > 1 ? input.substring(1) : "");
101 //Searching for a pattern in the String using the key.
102 p=Pattern.compile("\\$\\{"+output+"\\}");
103 m=p.matcher(ruleContents);
104 //Replacing the value with the inputs provided by the user in the editor.
105 String finalInput = copyMap.get(input);
106 if(finalInput.contains("$")){
107 finalInput = finalInput.replace("$", "\\$");
109 ruleContents=m.replaceAll(finalInput);
116 // Utility to read json data from the existing file to a string
117 static String readFile(String path, Charset encoding) throws IOException {
119 byte[] encoded = Files.readAllBytes(Paths.get(path));
120 return new String(encoded, encoding);
124 // Saving the Configurations file at server location for config policy.
125 protected void saveConfigurations(String policyName, String ruleBody) {
127 if (policyName.endsWith(".xml")) {
128 policyName = policyName.substring(0,
129 policyName.lastIndexOf(".xml"));
131 PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName + ".txt");
132 String expandedBody=expandConfigBody(ruleBody,policyAdapter.getBrmsParamBody());
133 out.println(expandedBody);
134 policyAdapter.setJsonBody(expandedBody);
135 policyAdapter.setConfigBodyData(expandedBody);
139 } catch (Exception e) {
140 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving configuration file");
145 // Here we are adding the extension for the configurations file based on the
146 // config type selection for saving.
147 private String getConfigFile(String filename) {
148 filename = FilenameUtils.removeExtension(filename);
149 if (filename.endsWith(".txt")) {
150 filename = filename.substring(0, filename.length() - 3);
153 filename = filename + ".txt";
157 // Validations for Config form
158 public boolean validateConfigForm() {
160 // Validating mandatory Fields.
167 public Map<String, String> savePolicies() throws Exception {
169 Map<String, String> successMap = new HashMap<>();
170 if(isPolicyExists()){
171 successMap.put("EXISTS", "This Policy already exist on the PAP");
175 if (!isPreparedToSave()) {
178 // Until here we prepared the data and here calling the method to create
180 Path newPolicyPath = null;
181 newPolicyPath = Paths.get(policyAdapter.getNewFileName());
182 successMap = createPolicy(newPolicyPath,getCorrectPolicyDataObject());
183 if(successMap == null){
184 successMap = new HashMap<>();
185 PolicyLogger.error("Failed to Update the Database Dictionary Tables.");
186 successMap.put("error", "DB UPDATE");
191 private String getValueFromDictionary(String templateName){
192 String ruleTemplate = null;
193 CommonClassDaoImpl dbConnection = new CommonClassDaoImpl();
194 String queryString="from BRMSParamTemplate where param_template_name= :templateName";
195 SimpleBindings params = new SimpleBindings();
196 params.put("templateName", templateName);
197 List<Object> result = dbConnection.getDataByQuery(queryString, params);
198 if(!result.isEmpty()){
199 BRMSParamTemplate template = (BRMSParamTemplate) result.get(0);
200 ruleTemplate = template.getRule();
205 protected Map<String, String> findType(String rule) {
206 Map<String, String> mapFieldType= new HashMap<>();
210 Boolean flag = false;
211 Boolean comment = false;
212 String lines[] = rule.split("\n");
213 for(String line : lines){
214 if (line.isEmpty() || line.startsWith("//")) {
217 if (line.startsWith("/*")) {
221 if (line.contains("//")) {
222 if(!(line.contains("http://") || line.contains("https://"))){
223 line = line.split("\\/\\/")[0];
226 if (line.contains("/*")) {
228 if (line.contains("*/")) {
231 line = line.split("\\/\\*")[0]
232 + line.split("\\*\\/")[1].replace("*/", "");
233 } catch (Exception e) {
235 line = line.split("\\/\\*")[0];
238 line = line.split("\\/\\*")[0];
241 if (line.contains("*/")) {
244 line = line.split("\\*\\/")[1].replace("*/", "");
245 } catch (Exception e) {
254 params = params + line;
256 if (line.contains("declare Params")) {
257 params = params + line;
260 if (line.contains("end") && flag) {
264 params = params.replace("declare Params", "").replace("end", "")
265 .replaceAll("\\s+", "");
266 String[] components = params.split(":");
268 for (int i = 0; i < components.length; i++) {
271 caption = components[i];
273 if(caption.equals("")){
276 String nextComponent = "";
278 nextComponent = components[i + 1];
279 } catch (Exception e) {
281 nextComponent = components[i];
283 //If the type is of type String then we add the UI Item and type to the map.
284 if (nextComponent.startsWith("String")) {
286 mapFieldType.put(caption, type);
287 caption = nextComponent.replace("String", "");
288 } else if (nextComponent.startsWith("int")) {
290 mapFieldType.put(caption, type);
291 caption = nextComponent.replace("int", "");
294 } catch (Exception e) {
295 PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "CreateBrmsParamPolicy", "Exception parsing file in findType");
301 // This is the method for preparing the policy for saving. We have broken it
303 // separately because the fully configured policy is used for multiple
306 public boolean prepareToSave() throws Exception {
308 if (isPreparedToSave()) {
309 // we have already done this
314 String policyID = policyAdapter.getPolicyID();
315 version = policyAdapter.getHighestVersion();
317 // Create the Instance for pojo, PolicyType object is used in
319 if (policyAdapter.getPolicyType().equals("Config")) {
320 PolicyType policyConfig = new PolicyType();
322 policyConfig.setVersion(Integer.toString(version));
323 policyConfig.setPolicyId(policyID);
324 policyConfig.setTarget(new TargetType());
325 policyAdapter.setData(policyConfig);
328 policyName = policyAdapter.getNewFileName();
330 if (policyAdapter.getData() != null) {
331 Map<String,String> ruleAndUIValue= policyAdapter.getBrmsParamBody();
332 String tempateValue= ruleAndUIValue.get("templateName");
333 String valueFromDictionary= getValueFromDictionary(tempateValue);
335 //Get the type of the UI Fields.
336 Map<String,String> typeOfUIField=findType(valueFromDictionary);
337 String generatedRule=null;
343 body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
344 "<$%BRMSParamTemplate=" + tempateValue + "%$> \n */ \n";
345 body = body + valueFromDictionary + "\n";
346 generatedRule = "rule \"" +policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")) +".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();";
348 //We first read the map data structure(ruleAndUIValue) received from the PAP-ADMIN
349 //We ignore if the key is "templateName as we are interested only in the UI fields and its value.
350 //We have one more map data structure(typeOfUIField) created by parsing the Drools rule.
351 //From the type of the UI field(String/int) we structure whether to put the "" or not.
352 for (Map.Entry<String, String> entry : ruleAndUIValue.entrySet()) {
353 if(entry.getKey()!="templateName")
355 for(Map.Entry<String, String> fieldType:typeOfUIField.entrySet())
357 if(fieldType.getKey().equalsIgnoreCase(entry.getKey()))
359 String key = entry.getKey().substring(0, 1).toUpperCase() + entry.getKey().substring(1);
360 if(fieldType.getValue()=="String")
363 generatedRule = generatedRule + "\n\t\tparams.set"
365 + entry.getValue() + "\");";
368 generatedRule = generatedRule + "\n\t\tparams.set"
370 + entry.getValue() + ");";
377 generatedRule = generatedRule
378 + "\n\t\tinsert(params);\nend";
379 LOGGER.info("New rule generated with :" + generatedRule);
380 body = body + generatedRule;
381 } catch (Exception e) {
382 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
385 catch (Exception e) {
386 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
389 saveConfigurations(policyName,body);
391 // Make sure the filename ends with an extension
392 if (policyName.endsWith(".xml") == false) {
393 policyName = policyName + ".xml";
396 PolicyType configPolicy = (PolicyType) policyAdapter.getData();
398 configPolicy.setDescription(policyAdapter.getPolicyDescription());
400 configPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
402 AllOfType allOfOne = new AllOfType();
404 String fileName = policyAdapter.getNewFileName();
405 String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
406 if ((name == null) || (name.equals(""))) {
407 name = fileName.substring(fileName.lastIndexOf("/") + 1,
410 allOfOne.getMatch().add(createMatch("PolicyName", name));
413 AllOfType allOf = new AllOfType();
415 // Match for ONAPName
416 allOf.getMatch().add(createMatch("ONAPName", policyAdapter.getOnapName()));
417 allOf.getMatch().add(createMatch("ConfigName", policyAdapter.getConfigName()));
418 // Match for riskType
419 allOf.getMatch().add(createDynamicMatch("RiskType", policyAdapter.getRiskType()));
420 // Match for riskLevel
421 allOf.getMatch().add(createDynamicMatch("RiskLevel", String.valueOf(policyAdapter.getRiskLevel())));
422 // Match for riskguard
423 allOf.getMatch().add(createDynamicMatch("guard", policyAdapter.getGuard()));
425 allOf.getMatch().add(createDynamicMatch("TTLDate", policyAdapter.getTtlDate()));
426 AnyOfType anyOf = new AnyOfType();
427 anyOf.getAllOf().add(allOfOne);
428 anyOf.getAllOf().add(allOf);
430 TargetType target = new TargetType();
431 ((TargetType) target).getAnyOf().add(anyOf);
433 // Adding the target to the policy element
434 configPolicy.setTarget((TargetType) target);
436 RuleType rule = new RuleType();
437 rule.setRuleId(policyAdapter.getRuleID());
439 rule.setEffect(EffectType.PERMIT);
441 // Create Target in Rule
442 AllOfType allOfInRule = new AllOfType();
444 // Creating match for ACCESS in rule target
445 MatchType accessMatch = new MatchType();
446 AttributeValueType accessAttributeValue = new AttributeValueType();
447 accessAttributeValue.setDataType(STRING_DATATYPE);
448 accessAttributeValue.getContent().add("ACCESS");
449 accessMatch.setAttributeValue(accessAttributeValue);
450 AttributeDesignatorType accessAttributeDesignator = new AttributeDesignatorType();
451 URI accessURI = null;
453 accessURI = new URI(ACTION_ID);
454 } catch (URISyntaxException e) {
455 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating ACCESS URI");
457 accessAttributeDesignator.setCategory(CATEGORY_ACTION);
458 accessAttributeDesignator.setDataType(STRING_DATATYPE);
459 accessAttributeDesignator.setAttributeId(new IdentifierImpl(
460 accessURI).stringValue());
461 accessMatch.setAttributeDesignator(accessAttributeDesignator);
462 accessMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
464 // Creating Config Match in rule Target
465 MatchType configMatch = new MatchType();
466 AttributeValueType configAttributeValue = new AttributeValueType();
467 configAttributeValue.setDataType(STRING_DATATYPE);
469 configAttributeValue.getContent().add("Config");
471 configMatch.setAttributeValue(configAttributeValue);
472 AttributeDesignatorType configAttributeDesignator = new AttributeDesignatorType();
473 URI configURI = null;
475 configURI = new URI(RESOURCE_ID);
476 } catch (URISyntaxException e) {
477 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating Config URI");
480 configAttributeDesignator.setCategory(CATEGORY_RESOURCE);
481 configAttributeDesignator.setDataType(STRING_DATATYPE);
482 configAttributeDesignator.setAttributeId(new IdentifierImpl(configURI).stringValue());
483 configMatch.setAttributeDesignator(configAttributeDesignator);
484 configMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
486 allOfInRule.getMatch().add(accessMatch);
487 allOfInRule.getMatch().add(configMatch);
489 AnyOfType anyOfInRule = new AnyOfType();
490 anyOfInRule.getAllOf().add(allOfInRule);
492 TargetType targetInRule = new TargetType();
493 targetInRule.getAnyOf().add(anyOfInRule);
495 rule.setTarget(targetInRule);
496 rule.setAdviceExpressions(getAdviceExpressions(version, policyName));
499 .getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()
501 policyAdapter.setPolicyData(configPolicy);
504 PolicyLogger.error("Unsupported data object."
505 + policyAdapter.getData().getClass().getCanonicalName());
507 setPreparedToSave(true);
511 // Data required for Advice part is setting here.
512 private AdviceExpressionsType getAdviceExpressions(int version,
515 //Policy Config ID Assignment
516 AdviceExpressionsType advices = new AdviceExpressionsType();
517 AdviceExpressionType advice = new AdviceExpressionType();
518 advice.setAdviceId("BRMSPARAMID");
519 advice.setAppliesTo(EffectType.PERMIT);
521 AttributeAssignmentExpressionType assignment1 = new AttributeAssignmentExpressionType();
522 assignment1.setAttributeId("type");
523 assignment1.setCategory(CATEGORY_RESOURCE);
524 assignment1.setIssuer("");
525 AttributeValueType configNameAttributeValue = new AttributeValueType();
526 configNameAttributeValue.setDataType(STRING_DATATYPE);
527 configNameAttributeValue.getContent().add("Configuration");
528 assignment1.setExpression(new ObjectFactory()
529 .createAttributeValue(configNameAttributeValue));
530 advice.getAttributeAssignmentExpression().add(assignment1);
532 // For Config file Url if configurations are provided.
534 AttributeAssignmentExpressionType assignment2 = new AttributeAssignmentExpressionType();
535 assignment2.setAttributeId("URLID");
536 assignment2.setCategory(CATEGORY_RESOURCE);
537 assignment2.setIssuer("");
538 AttributeValueType AttributeValue = new AttributeValueType();
539 AttributeValue.setDataType(URI_DATATYPE);
541 String content = CONFIG_URL + "/Config/"+ getConfigFile(policyName);
543 AttributeValue.getContent().add(content);
544 assignment2.setExpression(new ObjectFactory()
545 .createAttributeValue(AttributeValue));
546 advice.getAttributeAssignmentExpression().add(assignment2);
548 // Policy Name Assignment
549 AttributeAssignmentExpressionType assignment3 = new AttributeAssignmentExpressionType();
550 assignment3.setAttributeId("PolicyName");
551 assignment3.setCategory(CATEGORY_RESOURCE);
552 assignment3.setIssuer("");
553 AttributeValueType attributeValue3 = new AttributeValueType();
554 attributeValue3.setDataType(STRING_DATATYPE);
555 fileName = FilenameUtils.removeExtension(fileName);
556 fileName = fileName + ".xml";
557 String name = fileName.substring(fileName.lastIndexOf("\\") + 1,
559 if ((name == null) || (name.equals(""))) {
560 name = fileName.substring(fileName.lastIndexOf("/") + 1,
563 attributeValue3.getContent().add(name);
564 assignment3.setExpression(new ObjectFactory()
565 .createAttributeValue(attributeValue3));
566 advice.getAttributeAssignmentExpression().add(assignment3);
568 // Version Number Assignment
569 AttributeAssignmentExpressionType assignment4 = new AttributeAssignmentExpressionType();
570 assignment4.setAttributeId("VersionNumber");
571 assignment4.setCategory(CATEGORY_RESOURCE);
572 assignment4.setIssuer("");
573 AttributeValueType configNameAttributeValue4 = new AttributeValueType();
574 configNameAttributeValue4.setDataType(STRING_DATATYPE);
575 configNameAttributeValue4.getContent().add(Integer.toString(version));
576 assignment4.setExpression(new ObjectFactory()
577 .createAttributeValue(configNameAttributeValue4));
578 advice.getAttributeAssignmentExpression().add(assignment4);
580 // Onap Name Assignment
581 AttributeAssignmentExpressionType assignment5 = new AttributeAssignmentExpressionType();
582 assignment5.setAttributeId("matching:" + ONAPID);
583 assignment5.setCategory(CATEGORY_RESOURCE);
584 assignment5.setIssuer("");
585 AttributeValueType configNameAttributeValue5 = new AttributeValueType();
586 configNameAttributeValue5.setDataType(STRING_DATATYPE);
587 configNameAttributeValue5.getContent().add(policyAdapter.getOnapName());
588 assignment5.setExpression(new ObjectFactory()
589 .createAttributeValue(configNameAttributeValue5));
590 advice.getAttributeAssignmentExpression().add(assignment5);
593 //Config Name Assignment
594 AttributeAssignmentExpressionType assignment6 = new AttributeAssignmentExpressionType();
595 assignment6.setAttributeId("matching:" +CONFIGID);
596 assignment6.setCategory(CATEGORY_RESOURCE);
597 assignment6.setIssuer("");
598 AttributeValueType configNameAttributeValue6 = new AttributeValueType();
599 configNameAttributeValue6.setDataType(STRING_DATATYPE);
600 configNameAttributeValue6.getContent().add(policyAdapter.getConfigName());
601 assignment6.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue6));
602 advice.getAttributeAssignmentExpression().add(assignment6);
603 // Adding Controller Information.
604 if(policyAdapter.getBrmsController()!=null){
605 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
606 advice.getAttributeAssignmentExpression().add(
607 createResponseAttributes("controller:"+ policyAdapter.getBrmsController(),
608 brmsDicitonaryController.getControllerDataByID(policyAdapter.getBrmsController()).getController()));
611 // Adding Dependencies.
612 if(policyAdapter.getBrmsDependency()!=null){
613 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
614 ArrayList<String> dependencies = new ArrayList<>();
615 StringBuilder key = new StringBuilder();
616 for(String dependencyName: policyAdapter.getBrmsDependency()){
617 dependencies.add(brmsDicitonaryController.getDependencyDataByID(dependencyName).getDependency());
618 key.append(dependencyName + ",");
620 advice.getAttributeAssignmentExpression().add(
621 createResponseAttributes("dependencies:"+key.toString(), dependencies.toString()));
624 // Dynamic Field Config Attributes.
625 Map<String, String> dynamicFieldConfigAttributes = policyAdapter.getDynamicFieldConfigAttributes();
626 for (String keyField : dynamicFieldConfigAttributes.keySet()) {
627 advice.getAttributeAssignmentExpression().add(createResponseAttributes("key:"+keyField, dynamicFieldConfigAttributes.get(keyField)));
631 AttributeAssignmentExpressionType assignment8 = new AttributeAssignmentExpressionType();
632 assignment8.setAttributeId("RiskType");
633 assignment8.setCategory(CATEGORY_RESOURCE);
634 assignment8.setIssuer("");
636 AttributeValueType configNameAttributeValue8 = new AttributeValueType();
637 configNameAttributeValue8.setDataType(STRING_DATATYPE);
638 configNameAttributeValue8.getContent().add(policyAdapter.getRiskType());
639 assignment8.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue8));
641 advice.getAttributeAssignmentExpression().add(assignment8);
643 AttributeAssignmentExpressionType assignment9 = new AttributeAssignmentExpressionType();
644 assignment9.setAttributeId("RiskLevel");
645 assignment9.setCategory(CATEGORY_RESOURCE);
646 assignment9.setIssuer("");
648 AttributeValueType configNameAttributeValue9 = new AttributeValueType();
649 configNameAttributeValue9.setDataType(STRING_DATATYPE);
650 configNameAttributeValue9.getContent().add(policyAdapter.getRiskLevel());
651 assignment9.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue9));
653 advice.getAttributeAssignmentExpression().add(assignment9);
655 AttributeAssignmentExpressionType assignment10 = new AttributeAssignmentExpressionType();
656 assignment10.setAttributeId("guard");
657 assignment10.setCategory(CATEGORY_RESOURCE);
658 assignment10.setIssuer("");
660 AttributeValueType configNameAttributeValue10 = new AttributeValueType();
661 configNameAttributeValue10.setDataType(STRING_DATATYPE);
662 configNameAttributeValue10.getContent().add(policyAdapter.getGuard());
663 assignment10.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue10));
665 advice.getAttributeAssignmentExpression().add(assignment10);
667 AttributeAssignmentExpressionType assignment11 = new AttributeAssignmentExpressionType();
668 assignment11.setAttributeId("TTLDate");
669 assignment11.setCategory(CATEGORY_RESOURCE);
670 assignment11.setIssuer("");
672 AttributeValueType configNameAttributeValue11 = new AttributeValueType();
673 configNameAttributeValue11.setDataType(STRING_DATATYPE);
674 configNameAttributeValue11.getContent().add(policyAdapter.getTtlDate());
675 assignment11.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue11));
677 advice.getAttributeAssignmentExpression().add(assignment11);
679 advices.getAdviceExpression().add(advice);
684 public Object getCorrectPolicyDataObject() {
685 return policyAdapter.getData();
688 private AttributeAssignmentExpressionType createResponseAttributes(String key, String value){
689 AttributeAssignmentExpressionType assignment7 = new AttributeAssignmentExpressionType();
690 assignment7.setAttributeId(key);
691 assignment7.setCategory(CATEGORY_RESOURCE);
692 assignment7.setIssuer("");
693 AttributeValueType configNameAttributeValue7 = new AttributeValueType();
694 configNameAttributeValue7.setDataType(STRING_DATATYPE);
695 configNameAttributeValue7.getContent().add(value);
696 assignment7.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue7));