X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=ONAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fadapter%2FPolicyRestAdapter.java;h=97e6e9ef6fe951c3299e774b5f5c27d103df5621;hb=1e61676b77dd09659027b8984f050df7e8538526;hp=edadf53dec82c924803c4ea281b341acc22da0a7;hpb=7fd58e9a2427a215daa6b543e901534e83d3c246;p=policy%2Fengine.git diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java index edadf53de..97e6e9ef6 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,10 +29,10 @@ import org.onap.policy.rest.jpa.OnapName; public class PolicyRestAdapter { /* - * + * * Note : Make Sure if any variables are added in PolicyRestAdapter.java, add them to PolicyElasticData.java file - * - * + * + * */ // Common @@ -62,6 +62,7 @@ public class PolicyRestAdapter { private String finalPolicyPath; private String version; private String jsonBody; + private String uiJsonBody; private String apiflag; private String prevJsonBody; private Integer highestVersion; @@ -129,14 +130,6 @@ public class PolicyRestAdapter { private String blackListEntryType; private String rawXacmlPolicy; - public String getRawXacmlPolicy() { - return rawXacmlPolicy; - } - - public void setRawXacmlPolicy(String rawXacmlPolicy) { - this.rawXacmlPolicy = rawXacmlPolicy; - } - // Rainy Day Decision private RainyDayParams rainyday; private Map rainydayMap; @@ -1145,4 +1138,71 @@ public class PolicyRestAdapter { public void setBlackListEntryType(String blackListEntryType) { this.blackListEntryType = blackListEntryType; } + + public String getRawXacmlPolicy() { + return rawXacmlPolicy; + } + + public void setRawXacmlPolicy(String rawXacmlPolicy) { + this.rawXacmlPolicy = rawXacmlPolicy; + } + + public String getUiJsonBody() { + return uiJsonBody; + } + + public void setUiJsonBody(String uiJsonBody) { + this.uiJsonBody = uiJsonBody; + } + + public boolean setupUsingAttribute(String attributeId, String value) { + switch (attributeId) { + case "ONAPName": + this.setOnapName(value); + OnapName tempOnapName = new OnapName(); + tempOnapName.setOnapName(value); + this.setOnapNameField(tempOnapName); + return true; + case "RiskType": + this.setRiskType(value); + return true; + case "RiskLevel": + this.setRiskLevel(value); + return true; + case "guard": + this.setGuard(value); + return true; + case "ConfigName": + this.setConfigName(value); + return true; + case "uuid": + this.setUuid(value); + return true; + case "location": + this.setLocation(value); + return true; + case "TTLDate": + if (!value.contains("NA")) { + this.setTtlDate(PolicyRestAdapter.convertDate(value)); + return true; + } + return false; + default: + return false; + } + } + + /** + * Function to convert date. + * + * @param dateTimeToLive input date value. + * @return + */ + private static String convertDate(String dateTimeToLive) { + String formatDate = null; + if (dateTimeToLive.contains("-")) { + formatDate = dateTimeToLive.replace("-", "/"); + } + return formatDate; + } }