X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fadapter%2FPolicyRestAdapter.java;h=e7879a855ea2da6bdbfdd3837e1156ff0eecc41b;hb=b536883546b9fa87bce50c7a6d030f6de3aafdce;hp=e3faaff888c32306072670b1104996ca7d310bc6;hpb=1134bd40da28d3833a0dd4f821e75ec938f6061f;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 e3faaff88..e7879a855 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. @@ -23,16 +23,18 @@ package org.onap.policy.rest.adapter; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import javax.persistence.EntityManagerFactory; + 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 +64,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; @@ -1137,7 +1140,7 @@ public class PolicyRestAdapter { public void setBlackListEntryType(String blackListEntryType) { this.blackListEntryType = blackListEntryType; } - + public String getRawXacmlPolicy() { return rawXacmlPolicy; } @@ -1145,4 +1148,63 @@ public class PolicyRestAdapter { 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.setName(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; + } }