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) {
234 line = line.split("\\/\\*")[0];
237 line = line.split("\\/\\*")[0];
240 if (line.contains("*/")) {
243 line = line.split("\\*\\/")[1].replace("*/", "");
244 } catch (Exception e) {
252 params = params + line;
254 if (line.contains("declare Params")) {
255 params = params + line;
258 if (line.contains("end") && flag) {
262 params = params.replace("declare Params", "").replace("end", "")
263 .replaceAll("\\s+", "");
264 String[] components = params.split(":");
266 for (int i = 0; i < components.length; i++) {
269 caption = components[i];
271 if(caption.equals("")){
274 String nextComponent = "";
276 nextComponent = components[i + 1];
277 } catch (Exception e) {
278 nextComponent = components[i];
280 //If the type is of type String then we add the UI Item and type to the map.
281 if (nextComponent.startsWith("String")) {
283 mapFieldType.put(caption, type);
284 caption = nextComponent.replace("String", "");
285 } else if (nextComponent.startsWith("int")) {
287 mapFieldType.put(caption, type);
288 caption = nextComponent.replace("int", "");
291 } catch (Exception e) {
292 PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "CreateBrmsParamPolicy", "Exception parsing file in findType");
298 // This is the method for preparing the policy for saving. We have broken it
300 // separately because the fully configured policy is used for multiple
303 public boolean prepareToSave() throws Exception {
305 if (isPreparedToSave()) {
306 // we have already done this
311 String policyID = policyAdapter.getPolicyID();
312 version = policyAdapter.getHighestVersion();
314 // Create the Instance for pojo, PolicyType object is used in
316 if (policyAdapter.getPolicyType().equals("Config")) {
317 PolicyType policyConfig = new PolicyType();
319 policyConfig.setVersion(Integer.toString(version));
320 policyConfig.setPolicyId(policyID);
321 policyConfig.setTarget(new TargetType());
322 policyAdapter.setData(policyConfig);
325 policyName = policyAdapter.getNewFileName();
327 if (policyAdapter.getData() != null) {
328 Map<String,String> ruleAndUIValue= policyAdapter.getBrmsParamBody();
329 String tempateValue= ruleAndUIValue.get("templateName");
330 String valueFromDictionary= getValueFromDictionary(tempateValue);
332 //Get the type of the UI Fields.
333 Map<String,String> typeOfUIField=findType(valueFromDictionary);
334 String generatedRule=null;
340 body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
341 "<$%BRMSParamTemplate=" + tempateValue + "%$> \n */ \n";
342 body = body + valueFromDictionary + "\n";
343 generatedRule = "rule \"" +policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")) +".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();";
345 //We first read the map data structure(ruleAndUIValue) received from the PAP-ADMIN
346 //We ignore if the key is "templateName as we are interested only in the UI fields and its value.
347 //We have one more map data structure(typeOfUIField) created by parsing the Drools rule.
348 //From the type of the UI field(String/int) we structure whether to put the "" or not.
349 for (Map.Entry<String, String> entry : ruleAndUIValue.entrySet()) {
350 if(entry.getKey()!="templateName")
352 for(Map.Entry<String, String> fieldType:typeOfUIField.entrySet())
354 if(fieldType.getKey().equalsIgnoreCase(entry.getKey()))
356 String key = entry.getKey().substring(0, 1).toUpperCase() + entry.getKey().substring(1);
357 if(fieldType.getValue()=="String")
360 generatedRule = generatedRule + "\n\t\tparams.set"
362 + entry.getValue() + "\");";
365 generatedRule = generatedRule + "\n\t\tparams.set"
367 + entry.getValue() + ");";
374 generatedRule = generatedRule
375 + "\n\t\tinsert(params);\nend";
376 LOGGER.info("New rule generated with :" + generatedRule);
377 body = body + generatedRule;
378 } catch (Exception e) {
379 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
382 catch (Exception e) {
383 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
386 saveConfigurations(policyName,body);
388 // Make sure the filename ends with an extension
389 if (policyName.endsWith(".xml") == false) {
390 policyName = policyName + ".xml";
393 PolicyType configPolicy = (PolicyType) policyAdapter.getData();
395 configPolicy.setDescription(policyAdapter.getPolicyDescription());
397 configPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
399 AllOfType allOfOne = new AllOfType();
401 String fileName = policyAdapter.getNewFileName();
402 String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
403 if ((name == null) || (name.equals(""))) {
404 name = fileName.substring(fileName.lastIndexOf("/") + 1,
407 allOfOne.getMatch().add(createMatch("PolicyName", name));
410 AllOfType allOf = new AllOfType();
412 // Match for ONAPName
413 allOf.getMatch().add(createMatch("ONAPName", policyAdapter.getOnapName()));
414 allOf.getMatch().add(createMatch("ConfigName", policyAdapter.getConfigName()));
415 // Match for riskType
416 allOf.getMatch().add(createDynamicMatch("RiskType", policyAdapter.getRiskType()));
417 // Match for riskLevel
418 allOf.getMatch().add(createDynamicMatch("RiskLevel", String.valueOf(policyAdapter.getRiskLevel())));
419 // Match for riskguard
420 allOf.getMatch().add(createDynamicMatch("guard", policyAdapter.getGuard()));
422 allOf.getMatch().add(createDynamicMatch("TTLDate", policyAdapter.getTtlDate()));
423 AnyOfType anyOf = new AnyOfType();
424 anyOf.getAllOf().add(allOfOne);
425 anyOf.getAllOf().add(allOf);
427 TargetType target = new TargetType();
428 ((TargetType) target).getAnyOf().add(anyOf);
430 // Adding the target to the policy element
431 configPolicy.setTarget((TargetType) target);
433 RuleType rule = new RuleType();
434 rule.setRuleId(policyAdapter.getRuleID());
436 rule.setEffect(EffectType.PERMIT);
438 // Create Target in Rule
439 AllOfType allOfInRule = new AllOfType();
441 // Creating match for ACCESS in rule target
442 MatchType accessMatch = new MatchType();
443 AttributeValueType accessAttributeValue = new AttributeValueType();
444 accessAttributeValue.setDataType(STRING_DATATYPE);
445 accessAttributeValue.getContent().add("ACCESS");
446 accessMatch.setAttributeValue(accessAttributeValue);
447 AttributeDesignatorType accessAttributeDesignator = new AttributeDesignatorType();
448 URI accessURI = null;
450 accessURI = new URI(ACTION_ID);
451 } catch (URISyntaxException e) {
452 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating ACCESS URI");
454 accessAttributeDesignator.setCategory(CATEGORY_ACTION);
455 accessAttributeDesignator.setDataType(STRING_DATATYPE);
456 accessAttributeDesignator.setAttributeId(new IdentifierImpl(
457 accessURI).stringValue());
458 accessMatch.setAttributeDesignator(accessAttributeDesignator);
459 accessMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
461 // Creating Config Match in rule Target
462 MatchType configMatch = new MatchType();
463 AttributeValueType configAttributeValue = new AttributeValueType();
464 configAttributeValue.setDataType(STRING_DATATYPE);
466 configAttributeValue.getContent().add("Config");
468 configMatch.setAttributeValue(configAttributeValue);
469 AttributeDesignatorType configAttributeDesignator = new AttributeDesignatorType();
470 URI configURI = null;
472 configURI = new URI(RESOURCE_ID);
473 } catch (URISyntaxException e) {
474 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating Config URI");
477 configAttributeDesignator.setCategory(CATEGORY_RESOURCE);
478 configAttributeDesignator.setDataType(STRING_DATATYPE);
479 configAttributeDesignator.setAttributeId(new IdentifierImpl(configURI).stringValue());
480 configMatch.setAttributeDesignator(configAttributeDesignator);
481 configMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
483 allOfInRule.getMatch().add(accessMatch);
484 allOfInRule.getMatch().add(configMatch);
486 AnyOfType anyOfInRule = new AnyOfType();
487 anyOfInRule.getAllOf().add(allOfInRule);
489 TargetType targetInRule = new TargetType();
490 targetInRule.getAnyOf().add(anyOfInRule);
492 rule.setTarget(targetInRule);
493 rule.setAdviceExpressions(getAdviceExpressions(version, policyName));
496 .getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()
498 policyAdapter.setPolicyData(configPolicy);
501 PolicyLogger.error("Unsupported data object."
502 + policyAdapter.getData().getClass().getCanonicalName());
504 setPreparedToSave(true);
508 // Data required for Advice part is setting here.
509 private AdviceExpressionsType getAdviceExpressions(int version,
512 //Policy Config ID Assignment
513 AdviceExpressionsType advices = new AdviceExpressionsType();
514 AdviceExpressionType advice = new AdviceExpressionType();
515 advice.setAdviceId("BRMSPARAMID");
516 advice.setAppliesTo(EffectType.PERMIT);
518 AttributeAssignmentExpressionType assignment1 = new AttributeAssignmentExpressionType();
519 assignment1.setAttributeId("type");
520 assignment1.setCategory(CATEGORY_RESOURCE);
521 assignment1.setIssuer("");
522 AttributeValueType configNameAttributeValue = new AttributeValueType();
523 configNameAttributeValue.setDataType(STRING_DATATYPE);
524 configNameAttributeValue.getContent().add("Configuration");
525 assignment1.setExpression(new ObjectFactory()
526 .createAttributeValue(configNameAttributeValue));
527 advice.getAttributeAssignmentExpression().add(assignment1);
529 // For Config file Url if configurations are provided.
531 AttributeAssignmentExpressionType assignment2 = new AttributeAssignmentExpressionType();
532 assignment2.setAttributeId("URLID");
533 assignment2.setCategory(CATEGORY_RESOURCE);
534 assignment2.setIssuer("");
535 AttributeValueType AttributeValue = new AttributeValueType();
536 AttributeValue.setDataType(URI_DATATYPE);
538 String content = CONFIG_URL + "/Config/"+ getConfigFile(policyName);
540 AttributeValue.getContent().add(content);
541 assignment2.setExpression(new ObjectFactory()
542 .createAttributeValue(AttributeValue));
543 advice.getAttributeAssignmentExpression().add(assignment2);
545 // Policy Name Assignment
546 AttributeAssignmentExpressionType assignment3 = new AttributeAssignmentExpressionType();
547 assignment3.setAttributeId("PolicyName");
548 assignment3.setCategory(CATEGORY_RESOURCE);
549 assignment3.setIssuer("");
550 AttributeValueType attributeValue3 = new AttributeValueType();
551 attributeValue3.setDataType(STRING_DATATYPE);
552 fileName = FilenameUtils.removeExtension(fileName);
553 fileName = fileName + ".xml";
554 String name = fileName.substring(fileName.lastIndexOf("\\") + 1,
556 if ((name == null) || (name.equals(""))) {
557 name = fileName.substring(fileName.lastIndexOf("/") + 1,
560 attributeValue3.getContent().add(name);
561 assignment3.setExpression(new ObjectFactory()
562 .createAttributeValue(attributeValue3));
563 advice.getAttributeAssignmentExpression().add(assignment3);
565 // Version Number Assignment
566 AttributeAssignmentExpressionType assignment4 = new AttributeAssignmentExpressionType();
567 assignment4.setAttributeId("VersionNumber");
568 assignment4.setCategory(CATEGORY_RESOURCE);
569 assignment4.setIssuer("");
570 AttributeValueType configNameAttributeValue4 = new AttributeValueType();
571 configNameAttributeValue4.setDataType(STRING_DATATYPE);
572 configNameAttributeValue4.getContent().add(Integer.toString(version));
573 assignment4.setExpression(new ObjectFactory()
574 .createAttributeValue(configNameAttributeValue4));
575 advice.getAttributeAssignmentExpression().add(assignment4);
577 // Onap Name Assignment
578 AttributeAssignmentExpressionType assignment5 = new AttributeAssignmentExpressionType();
579 assignment5.setAttributeId("matching:" + ONAPID);
580 assignment5.setCategory(CATEGORY_RESOURCE);
581 assignment5.setIssuer("");
582 AttributeValueType configNameAttributeValue5 = new AttributeValueType();
583 configNameAttributeValue5.setDataType(STRING_DATATYPE);
584 configNameAttributeValue5.getContent().add(policyAdapter.getOnapName());
585 assignment5.setExpression(new ObjectFactory()
586 .createAttributeValue(configNameAttributeValue5));
587 advice.getAttributeAssignmentExpression().add(assignment5);
590 //Config Name Assignment
591 AttributeAssignmentExpressionType assignment6 = new AttributeAssignmentExpressionType();
592 assignment6.setAttributeId("matching:" +CONFIGID);
593 assignment6.setCategory(CATEGORY_RESOURCE);
594 assignment6.setIssuer("");
595 AttributeValueType configNameAttributeValue6 = new AttributeValueType();
596 configNameAttributeValue6.setDataType(STRING_DATATYPE);
597 configNameAttributeValue6.getContent().add(policyAdapter.getConfigName());
598 assignment6.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue6));
599 advice.getAttributeAssignmentExpression().add(assignment6);
600 // Adding Controller Information.
601 if(policyAdapter.getBrmsController()!=null){
602 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
603 advice.getAttributeAssignmentExpression().add(
604 createResponseAttributes("controller:"+ policyAdapter.getBrmsController(),
605 brmsDicitonaryController.getControllerDataByID(policyAdapter.getBrmsController()).getController()));
608 // Adding Dependencies.
609 if(policyAdapter.getBrmsDependency()!=null){
610 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
611 ArrayList<String> dependencies = new ArrayList<>();
612 StringBuilder key = new StringBuilder();
613 for(String dependencyName: policyAdapter.getBrmsDependency()){
614 dependencies.add(brmsDicitonaryController.getDependencyDataByID(dependencyName).getDependency());
615 key.append(dependencyName + ",");
617 advice.getAttributeAssignmentExpression().add(
618 createResponseAttributes("dependencies:"+key.toString(), dependencies.toString()));
621 // Dynamic Field Config Attributes.
622 Map<String, String> dynamicFieldConfigAttributes = policyAdapter.getDynamicFieldConfigAttributes();
623 for (String keyField : dynamicFieldConfigAttributes.keySet()) {
624 advice.getAttributeAssignmentExpression().add(createResponseAttributes("key:"+keyField, dynamicFieldConfigAttributes.get(keyField)));
628 AttributeAssignmentExpressionType assignment8 = new AttributeAssignmentExpressionType();
629 assignment8.setAttributeId("RiskType");
630 assignment8.setCategory(CATEGORY_RESOURCE);
631 assignment8.setIssuer("");
633 AttributeValueType configNameAttributeValue8 = new AttributeValueType();
634 configNameAttributeValue8.setDataType(STRING_DATATYPE);
635 configNameAttributeValue8.getContent().add(policyAdapter.getRiskType());
636 assignment8.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue8));
638 advice.getAttributeAssignmentExpression().add(assignment8);
640 AttributeAssignmentExpressionType assignment9 = new AttributeAssignmentExpressionType();
641 assignment9.setAttributeId("RiskLevel");
642 assignment9.setCategory(CATEGORY_RESOURCE);
643 assignment9.setIssuer("");
645 AttributeValueType configNameAttributeValue9 = new AttributeValueType();
646 configNameAttributeValue9.setDataType(STRING_DATATYPE);
647 configNameAttributeValue9.getContent().add(policyAdapter.getRiskLevel());
648 assignment9.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue9));
650 advice.getAttributeAssignmentExpression().add(assignment9);
652 AttributeAssignmentExpressionType assignment10 = new AttributeAssignmentExpressionType();
653 assignment10.setAttributeId("guard");
654 assignment10.setCategory(CATEGORY_RESOURCE);
655 assignment10.setIssuer("");
657 AttributeValueType configNameAttributeValue10 = new AttributeValueType();
658 configNameAttributeValue10.setDataType(STRING_DATATYPE);
659 configNameAttributeValue10.getContent().add(policyAdapter.getGuard());
660 assignment10.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue10));
662 advice.getAttributeAssignmentExpression().add(assignment10);
664 AttributeAssignmentExpressionType assignment11 = new AttributeAssignmentExpressionType();
665 assignment11.setAttributeId("TTLDate");
666 assignment11.setCategory(CATEGORY_RESOURCE);
667 assignment11.setIssuer("");
669 AttributeValueType configNameAttributeValue11 = new AttributeValueType();
670 configNameAttributeValue11.setDataType(STRING_DATATYPE);
671 configNameAttributeValue11.getContent().add(policyAdapter.getTtlDate());
672 assignment11.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue11));
674 advice.getAttributeAssignmentExpression().add(assignment11);
676 advices.getAdviceExpression().add(advice);
681 public Object getCorrectPolicyDataObject() {
682 return policyAdapter.getData();
685 private AttributeAssignmentExpressionType createResponseAttributes(String key, String value){
686 AttributeAssignmentExpressionType assignment7 = new AttributeAssignmentExpressionType();
687 assignment7.setAttributeId(key);
688 assignment7.setCategory(CATEGORY_RESOURCE);
689 assignment7.setIssuer("");
690 AttributeValueType configNameAttributeValue7 = new AttributeValueType();
691 configNameAttributeValue7.setDataType(STRING_DATATYPE);
692 configNameAttributeValue7.getContent().add(value);
693 assignment7.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue7));