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 org.apache.commons.io.FilenameUtils;
42 import org.onap.policy.common.logging.eelf.MessageCodes;
43 import org.onap.policy.common.logging.eelf.PolicyLogger;
44 import org.onap.policy.common.logging.flexlogger.FlexLogger;
45 import org.onap.policy.common.logging.flexlogger.Logger;
46 import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
47 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
48 import org.onap.policy.rest.adapter.PolicyRestAdapter;
49 import org.onap.policy.rest.jpa.BRMSParamTemplate;
51 import com.att.research.xacml.std.IdentifierImpl;
53 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
54 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
55 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
56 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
57 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
58 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
59 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
60 import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
61 import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
62 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
63 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
64 import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
65 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
67 public class CreateBrmsParamPolicy extends Policy {
69 private static final Logger LOGGER = FlexLogger.getLogger(CreateBrmsParamPolicy.class);
71 public CreateBrmsParamPolicy() {
75 public CreateBrmsParamPolicy(PolicyRestAdapter policyAdapter) {
76 this.policyAdapter = policyAdapter;
77 this.policyAdapter.setConfigType(policyAdapter.getConfigType());
81 public String expandConfigBody(String ruleContents, Map<String, String> brmsParamBody) {
83 Map<String,String> copyMap=new HashMap<>();
84 copyMap.putAll(brmsParamBody);
85 copyMap.put("policyName", policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")));
86 copyMap.put("policyScope", policyAdapter.getDomainDir());
87 copyMap.put("policyVersion",policyAdapter.getHighestVersion().toString());
88 copyMap.put("unique", ("p"+policyName+UUID.randomUUID().toString()).replaceAll("[^A-Za-z0-9]", ""));
90 //Finding all the keys in the Map data-structure.
91 Iterator<String> iterator = copyMap.keySet().iterator();
94 while(iterator.hasNext()) {
95 //Converting the first character of the key into a lower case.
96 String input= iterator.next();
97 String output = Character.toLowerCase(input.charAt(0)) +
98 (input.length() > 1 ? input.substring(1) : "");
99 //Searching for a pattern in the String using the key.
100 p=Pattern.compile("\\$\\{"+output+"\\}");
101 m=p.matcher(ruleContents);
102 //Replacing the value with the inputs provided by the user in the editor.
103 String finalInput = copyMap.get(input);
104 if(finalInput.contains("$")){
105 finalInput = finalInput.replace("$", "\\$");
107 ruleContents=m.replaceAll(finalInput);
114 // Utility to read json data from the existing file to a string
115 static String readFile(String path, Charset encoding) throws IOException {
117 byte[] encoded = Files.readAllBytes(Paths.get(path));
118 return new String(encoded, encoding);
122 // Saving the Configurations file at server location for config policy.
123 protected void saveConfigurations(String policyName, String ruleBody) {
125 if (policyName.endsWith(".xml")) {
126 policyName = policyName.substring(0,
127 policyName.lastIndexOf(".xml"));
129 PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator + policyName + ".txt");
130 String expandedBody=expandConfigBody(ruleBody,policyAdapter.getBrmsParamBody());
131 out.println(expandedBody);
132 policyAdapter.setJsonBody(expandedBody);
133 policyAdapter.setConfigBodyData(expandedBody);
137 } catch (Exception e) {
138 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving configuration file");
143 // Here we are adding the extension for the configurations file based on the
144 // config type selection for saving.
145 private String getConfigFile(String filename) {
146 filename = FilenameUtils.removeExtension(filename);
147 if (filename.endsWith(".txt")) {
148 filename = filename.substring(0, filename.length() - 3);
151 filename = filename + ".txt";
155 // Validations for Config form
156 public boolean validateConfigForm() {
158 // Validating mandatory Fields.
165 public Map<String, String> savePolicies() throws Exception {
167 Map<String, String> successMap = new HashMap<>();
168 if(isPolicyExists()){
169 successMap.put("EXISTS", "This Policy already exist on the PAP");
173 if (!isPreparedToSave()) {
176 // Until here we prepared the data and here calling the method to create
178 Path newPolicyPath = null;
179 newPolicyPath = Paths.get(policyAdapter.getNewFileName());
180 successMap = createPolicy(newPolicyPath,getCorrectPolicyDataObject());
181 if(successMap == null){
182 successMap = new HashMap<>();
183 PolicyLogger.error("Failed to Update the Database Dictionary Tables.");
184 successMap.put("error", "DB UPDATE");
189 private String getValueFromDictionary(String templateName){
190 String ruleTemplate = null;
191 CommonClassDaoImpl dbConnection = new CommonClassDaoImpl();
192 String queryString="from BRMSParamTemplate where param_template_name= '"+templateName+"'";
193 List<Object> result = dbConnection.getDataByQuery(queryString);
194 if(!result.isEmpty()){
195 BRMSParamTemplate template = (BRMSParamTemplate) result.get(0);
196 ruleTemplate = template.getRule();
201 protected Map<String, String> findType(String rule) {
202 Map<String, String> mapFieldType= new HashMap<>();
206 Boolean flag = false;
207 Boolean comment = false;
208 String lines[] = rule.split("\n");
209 for(String line : lines){
210 if (line.isEmpty() || line.startsWith("//")) {
213 if (line.startsWith("/*")) {
217 if (line.contains("//")) {
218 if(!(line.contains("http://") || line.contains("https://"))){
219 line = line.split("\\/\\/")[0];
222 if (line.contains("/*")) {
224 if (line.contains("*/")) {
227 line = line.split("\\/\\*")[0]
228 + line.split("\\*\\/")[1].replace("*/", "");
229 } catch (Exception e) {
230 line = line.split("\\/\\*")[0];
233 line = line.split("\\/\\*")[0];
236 if (line.contains("*/")) {
239 line = line.split("\\*\\/")[1].replace("*/", "");
240 } catch (Exception e) {
248 params = params + line;
250 if (line.contains("declare Params")) {
251 params = params + line;
254 if (line.contains("end") && flag) {
258 params = params.replace("declare Params", "").replace("end", "")
259 .replaceAll("\\s+", "");
260 String[] components = params.split(":");
262 for (int i = 0; i < components.length; i++) {
265 caption = components[i];
267 if(caption.equals("")){
270 String nextComponent = "";
272 nextComponent = components[i + 1];
273 } catch (Exception e) {
274 nextComponent = components[i];
276 //If the type is of type String then we add the UI Item and type to the map.
277 if (nextComponent.startsWith("String")) {
279 mapFieldType.put(caption, type);
280 caption = nextComponent.replace("String", "");
281 } else if (nextComponent.startsWith("int")) {
283 mapFieldType.put(caption, type);
284 caption = nextComponent.replace("int", "");
287 } catch (Exception e) {
288 PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "CreateBrmsParamPolicy", "Exception parsing file in findType");
294 // This is the method for preparing the policy for saving. We have broken it
296 // separately because the fully configured policy is used for multiple
299 public boolean prepareToSave() throws Exception {
301 if (isPreparedToSave()) {
302 // we have already done this
307 String policyID = policyAdapter.getPolicyID();
308 version = policyAdapter.getHighestVersion();
310 // Create the Instance for pojo, PolicyType object is used in
312 if (policyAdapter.getPolicyType().equals("Config")) {
313 PolicyType policyConfig = new PolicyType();
315 policyConfig.setVersion(Integer.toString(version));
316 policyConfig.setPolicyId(policyID);
317 policyConfig.setTarget(new TargetType());
318 policyAdapter.setData(policyConfig);
321 policyName = policyAdapter.getNewFileName();
323 if (policyAdapter.getData() != null) {
324 Map<String,String> ruleAndUIValue= policyAdapter.getBrmsParamBody();
325 String tempateValue= ruleAndUIValue.get("templateName");
326 String valueFromDictionary= getValueFromDictionary(tempateValue);
328 //Get the type of the UI Fields.
329 Map<String,String> typeOfUIField=findType(valueFromDictionary);
330 String generatedRule=null;
336 body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
337 "<$%BRMSParamTemplate=" + tempateValue + "%$> \n */ \n";
338 body = body + valueFromDictionary + "\n";
339 generatedRule = "rule \"" +policyName.substring(0, policyName.replace(".xml", "").lastIndexOf(".")) +".Params\" \n\tsalience 1000 \n\twhen\n\tthen\n\t\tParams params = new Params();";
341 //We first read the map data structure(ruleAndUIValue) received from the PAP-ADMIN
342 //We ignore if the key is "templateName as we are interested only in the UI fields and its value.
343 //We have one more map data structure(typeOfUIField) created by parsing the Drools rule.
344 //From the type of the UI field(String/int) we structure whether to put the "" or not.
345 for (Map.Entry<String, String> entry : ruleAndUIValue.entrySet()) {
346 if(entry.getKey()!="templateName")
348 for(Map.Entry<String, String> fieldType:typeOfUIField.entrySet())
350 if(fieldType.getKey().equalsIgnoreCase(entry.getKey()))
352 String key = entry.getKey().substring(0, 1).toUpperCase() + entry.getKey().substring(1);
353 if(fieldType.getValue()=="String")
356 generatedRule = generatedRule + "\n\t\tparams.set"
358 + entry.getValue() + "\");";
361 generatedRule = generatedRule + "\n\t\tparams.set"
363 + entry.getValue() + ");";
370 generatedRule = generatedRule
371 + "\n\t\tinsert(params);\nend";
372 LOGGER.info("New rule generated with :" + generatedRule);
373 body = body + generatedRule;
374 } catch (Exception e) {
375 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
378 catch (Exception e) {
379 PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "CreateBrmsParamPolicy", "Exception saving policy");
382 saveConfigurations(policyName,body);
384 // Make sure the filename ends with an extension
385 if (policyName.endsWith(".xml") == false) {
386 policyName = policyName + ".xml";
389 PolicyType configPolicy = (PolicyType) policyAdapter.getData();
391 configPolicy.setDescription(policyAdapter.getPolicyDescription());
393 configPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
395 AllOfType allOfOne = new AllOfType();
397 String fileName = policyAdapter.getNewFileName();
398 String name = fileName.substring(fileName.lastIndexOf("\\") + 1, fileName.length());
399 if ((name == null) || (name.equals(""))) {
400 name = fileName.substring(fileName.lastIndexOf("/") + 1,
403 allOfOne.getMatch().add(createMatch("PolicyName", name));
406 AllOfType allOf = new AllOfType();
408 // Match for ONAPName
409 allOf.getMatch().add(createMatch("ONAPName", policyAdapter.getOnapName()));
410 allOf.getMatch().add(createMatch("ConfigName", policyAdapter.getConfigName()));
411 // Match for riskType
412 allOf.getMatch().add(createDynamicMatch("RiskType", policyAdapter.getRiskType()));
413 // Match for riskLevel
414 allOf.getMatch().add(createDynamicMatch("RiskLevel", String.valueOf(policyAdapter.getRiskLevel())));
415 // Match for riskguard
416 allOf.getMatch().add(createDynamicMatch("guard", policyAdapter.getGuard()));
418 allOf.getMatch().add(createDynamicMatch("TTLDate", policyAdapter.getTtlDate()));
419 AnyOfType anyOf = new AnyOfType();
420 anyOf.getAllOf().add(allOfOne);
421 anyOf.getAllOf().add(allOf);
423 TargetType target = new TargetType();
424 ((TargetType) target).getAnyOf().add(anyOf);
426 // Adding the target to the policy element
427 configPolicy.setTarget((TargetType) target);
429 RuleType rule = new RuleType();
430 rule.setRuleId(policyAdapter.getRuleID());
432 rule.setEffect(EffectType.PERMIT);
434 // Create Target in Rule
435 AllOfType allOfInRule = new AllOfType();
437 // Creating match for ACCESS in rule target
438 MatchType accessMatch = new MatchType();
439 AttributeValueType accessAttributeValue = new AttributeValueType();
440 accessAttributeValue.setDataType(STRING_DATATYPE);
441 accessAttributeValue.getContent().add("ACCESS");
442 accessMatch.setAttributeValue(accessAttributeValue);
443 AttributeDesignatorType accessAttributeDesignator = new AttributeDesignatorType();
444 URI accessURI = null;
446 accessURI = new URI(ACTION_ID);
447 } catch (URISyntaxException e) {
448 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating ACCESS URI");
450 accessAttributeDesignator.setCategory(CATEGORY_ACTION);
451 accessAttributeDesignator.setDataType(STRING_DATATYPE);
452 accessAttributeDesignator.setAttributeId(new IdentifierImpl(
453 accessURI).stringValue());
454 accessMatch.setAttributeDesignator(accessAttributeDesignator);
455 accessMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
457 // Creating Config Match in rule Target
458 MatchType configMatch = new MatchType();
459 AttributeValueType configAttributeValue = new AttributeValueType();
460 configAttributeValue.setDataType(STRING_DATATYPE);
462 configAttributeValue.getContent().add("Config");
464 configMatch.setAttributeValue(configAttributeValue);
465 AttributeDesignatorType configAttributeDesignator = new AttributeDesignatorType();
466 URI configURI = null;
468 configURI = new URI(RESOURCE_ID);
469 } catch (URISyntaxException e) {
470 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "CreateBrmsParamPolicy", "Exception creating Config URI");
473 configAttributeDesignator.setCategory(CATEGORY_RESOURCE);
474 configAttributeDesignator.setDataType(STRING_DATATYPE);
475 configAttributeDesignator.setAttributeId(new IdentifierImpl(configURI).stringValue());
476 configMatch.setAttributeDesignator(configAttributeDesignator);
477 configMatch.setMatchId(FUNCTION_STRING_EQUAL_IGNORE);
479 allOfInRule.getMatch().add(accessMatch);
480 allOfInRule.getMatch().add(configMatch);
482 AnyOfType anyOfInRule = new AnyOfType();
483 anyOfInRule.getAllOf().add(allOfInRule);
485 TargetType targetInRule = new TargetType();
486 targetInRule.getAnyOf().add(anyOfInRule);
488 rule.setTarget(targetInRule);
489 rule.setAdviceExpressions(getAdviceExpressions(version, policyName));
492 .getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()
494 policyAdapter.setPolicyData(configPolicy);
497 PolicyLogger.error("Unsupported data object."
498 + policyAdapter.getData().getClass().getCanonicalName());
500 setPreparedToSave(true);
504 // Data required for Advice part is setting here.
505 private AdviceExpressionsType getAdviceExpressions(int version,
508 //Policy Config ID Assignment
509 AdviceExpressionsType advices = new AdviceExpressionsType();
510 AdviceExpressionType advice = new AdviceExpressionType();
511 advice.setAdviceId("BRMSPARAMID");
512 advice.setAppliesTo(EffectType.PERMIT);
514 AttributeAssignmentExpressionType assignment1 = new AttributeAssignmentExpressionType();
515 assignment1.setAttributeId("type");
516 assignment1.setCategory(CATEGORY_RESOURCE);
517 assignment1.setIssuer("");
518 AttributeValueType configNameAttributeValue = new AttributeValueType();
519 configNameAttributeValue.setDataType(STRING_DATATYPE);
520 configNameAttributeValue.getContent().add("Configuration");
521 assignment1.setExpression(new ObjectFactory()
522 .createAttributeValue(configNameAttributeValue));
523 advice.getAttributeAssignmentExpression().add(assignment1);
525 // For Config file Url if configurations are provided.
527 AttributeAssignmentExpressionType assignment2 = new AttributeAssignmentExpressionType();
528 assignment2.setAttributeId("URLID");
529 assignment2.setCategory(CATEGORY_RESOURCE);
530 assignment2.setIssuer("");
531 AttributeValueType AttributeValue = new AttributeValueType();
532 AttributeValue.setDataType(URI_DATATYPE);
534 String content = CONFIG_URL + "/Config/"+ getConfigFile(policyName);
536 AttributeValue.getContent().add(content);
537 assignment2.setExpression(new ObjectFactory()
538 .createAttributeValue(AttributeValue));
539 advice.getAttributeAssignmentExpression().add(assignment2);
541 // Policy Name Assignment
542 AttributeAssignmentExpressionType assignment3 = new AttributeAssignmentExpressionType();
543 assignment3.setAttributeId("PolicyName");
544 assignment3.setCategory(CATEGORY_RESOURCE);
545 assignment3.setIssuer("");
546 AttributeValueType attributeValue3 = new AttributeValueType();
547 attributeValue3.setDataType(STRING_DATATYPE);
548 fileName = FilenameUtils.removeExtension(fileName);
549 fileName = fileName + ".xml";
550 String name = fileName.substring(fileName.lastIndexOf("\\") + 1,
552 if ((name == null) || (name.equals(""))) {
553 name = fileName.substring(fileName.lastIndexOf("/") + 1,
556 attributeValue3.getContent().add(name);
557 assignment3.setExpression(new ObjectFactory()
558 .createAttributeValue(attributeValue3));
559 advice.getAttributeAssignmentExpression().add(assignment3);
561 // Version Number Assignment
562 AttributeAssignmentExpressionType assignment4 = new AttributeAssignmentExpressionType();
563 assignment4.setAttributeId("VersionNumber");
564 assignment4.setCategory(CATEGORY_RESOURCE);
565 assignment4.setIssuer("");
566 AttributeValueType configNameAttributeValue4 = new AttributeValueType();
567 configNameAttributeValue4.setDataType(STRING_DATATYPE);
568 configNameAttributeValue4.getContent().add(Integer.toString(version));
569 assignment4.setExpression(new ObjectFactory()
570 .createAttributeValue(configNameAttributeValue4));
571 advice.getAttributeAssignmentExpression().add(assignment4);
573 // Onap Name Assignment
574 AttributeAssignmentExpressionType assignment5 = new AttributeAssignmentExpressionType();
575 assignment5.setAttributeId("matching:" + ONAPID);
576 assignment5.setCategory(CATEGORY_RESOURCE);
577 assignment5.setIssuer("");
578 AttributeValueType configNameAttributeValue5 = new AttributeValueType();
579 configNameAttributeValue5.setDataType(STRING_DATATYPE);
580 configNameAttributeValue5.getContent().add(policyAdapter.getOnapName());
581 assignment5.setExpression(new ObjectFactory()
582 .createAttributeValue(configNameAttributeValue5));
583 advice.getAttributeAssignmentExpression().add(assignment5);
586 //Config Name Assignment
587 AttributeAssignmentExpressionType assignment6 = new AttributeAssignmentExpressionType();
588 assignment6.setAttributeId("matching:" +CONFIGID);
589 assignment6.setCategory(CATEGORY_RESOURCE);
590 assignment6.setIssuer("");
591 AttributeValueType configNameAttributeValue6 = new AttributeValueType();
592 configNameAttributeValue6.setDataType(STRING_DATATYPE);
593 configNameAttributeValue6.getContent().add(policyAdapter.getConfigName());
594 assignment6.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue6));
595 advice.getAttributeAssignmentExpression().add(assignment6);
596 // Adding Controller Information.
597 if(policyAdapter.getBrmsController()!=null){
598 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
599 advice.getAttributeAssignmentExpression().add(
600 createResponseAttributes("controller:"+ policyAdapter.getBrmsController(),
601 brmsDicitonaryController.getControllerDataByID(policyAdapter.getBrmsController()).getController()));
604 // Adding Dependencies.
605 if(policyAdapter.getBrmsDependency()!=null){
606 BRMSDictionaryController brmsDicitonaryController = new BRMSDictionaryController();
607 ArrayList<String> dependencies = new ArrayList<>();
608 StringBuilder key = new StringBuilder();
609 for(String dependencyName: policyAdapter.getBrmsDependency()){
610 dependencies.add(brmsDicitonaryController.getDependencyDataByID(dependencyName).getDependency());
611 key.append(dependencyName + ",");
613 advice.getAttributeAssignmentExpression().add(
614 createResponseAttributes("dependencies:"+key.toString(), dependencies.toString()));
617 // Dynamic Field Config Attributes.
618 Map<String, String> dynamicFieldConfigAttributes = policyAdapter.getDynamicFieldConfigAttributes();
619 for (String keyField : dynamicFieldConfigAttributes.keySet()) {
620 advice.getAttributeAssignmentExpression().add(createResponseAttributes("key:"+keyField, dynamicFieldConfigAttributes.get(keyField)));
624 AttributeAssignmentExpressionType assignment8 = new AttributeAssignmentExpressionType();
625 assignment8.setAttributeId("RiskType");
626 assignment8.setCategory(CATEGORY_RESOURCE);
627 assignment8.setIssuer("");
629 AttributeValueType configNameAttributeValue8 = new AttributeValueType();
630 configNameAttributeValue8.setDataType(STRING_DATATYPE);
631 configNameAttributeValue8.getContent().add(policyAdapter.getRiskType());
632 assignment8.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue8));
634 advice.getAttributeAssignmentExpression().add(assignment8);
636 AttributeAssignmentExpressionType assignment9 = new AttributeAssignmentExpressionType();
637 assignment9.setAttributeId("RiskLevel");
638 assignment9.setCategory(CATEGORY_RESOURCE);
639 assignment9.setIssuer("");
641 AttributeValueType configNameAttributeValue9 = new AttributeValueType();
642 configNameAttributeValue9.setDataType(STRING_DATATYPE);
643 configNameAttributeValue9.getContent().add(policyAdapter.getRiskLevel());
644 assignment9.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue9));
646 advice.getAttributeAssignmentExpression().add(assignment9);
648 AttributeAssignmentExpressionType assignment10 = new AttributeAssignmentExpressionType();
649 assignment10.setAttributeId("guard");
650 assignment10.setCategory(CATEGORY_RESOURCE);
651 assignment10.setIssuer("");
653 AttributeValueType configNameAttributeValue10 = new AttributeValueType();
654 configNameAttributeValue10.setDataType(STRING_DATATYPE);
655 configNameAttributeValue10.getContent().add(policyAdapter.getGuard());
656 assignment10.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue10));
658 advice.getAttributeAssignmentExpression().add(assignment10);
660 AttributeAssignmentExpressionType assignment11 = new AttributeAssignmentExpressionType();
661 assignment11.setAttributeId("TTLDate");
662 assignment11.setCategory(CATEGORY_RESOURCE);
663 assignment11.setIssuer("");
665 AttributeValueType configNameAttributeValue11 = new AttributeValueType();
666 configNameAttributeValue11.setDataType(STRING_DATATYPE);
667 configNameAttributeValue11.getContent().add(policyAdapter.getTtlDate());
668 assignment11.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue11));
670 advice.getAttributeAssignmentExpression().add(assignment11);
672 advices.getAdviceExpression().add(advice);
677 public Object getCorrectPolicyDataObject() {
678 return policyAdapter.getData();
681 private AttributeAssignmentExpressionType createResponseAttributes(String key, String value){
682 AttributeAssignmentExpressionType assignment7 = new AttributeAssignmentExpressionType();
683 assignment7.setAttributeId(key);
684 assignment7.setCategory(CATEGORY_RESOURCE);
685 assignment7.setIssuer("");
686 AttributeValueType configNameAttributeValue7 = new AttributeValueType();
687 configNameAttributeValue7.setDataType(STRING_DATATYPE);
688 configNameAttributeValue7.getContent().add(value);
689 assignment7.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue7));