aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-09-10 12:25:47 +0200
committersebdet <sebastien.determe@intl.att.com>2019-09-10 12:25:47 +0200
commitf0d7a9645a2b773df5d278d3858ce36a61f23645 (patch)
tree69052ec34191afd65f8f52d6e2fc1fe289d820d0 /src/main/java
parent0387f232b4a56e98092519ccc2e0ee7985f6701c (diff)
Remove dead code
Removal of deprecated v1 interface code, sql cleaned up as well, old model removed from database Issue-ID: CLAMP-487 Change-Id: I4a9f14de9ea1c1b76c522581d75cf4b011c2aa01 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java31
-rw-r--r--src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java73
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java216
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java108
-rw-r--r--src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java81
-rw-r--r--src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java82
-rw-r--r--src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java94
-rw-r--r--src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java63
-rw-r--r--src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java57
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java91
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java71
-rw-r--r--src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java82
-rw-r--r--src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java66
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java109
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java166
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java219
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java681
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java203
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java9
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/CldsDao.java715
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java42
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java68
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java85
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionary.java33
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java32
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsEvent.java300
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java11
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModel.java627
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java56
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModelProp.java68
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsServiceData.java107
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsTemplate.java213
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java145
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java143
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java158
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsVfData.java70
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java89
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsVfcData.java60
-rw-r--r--src/main/java/org/onap/clamp/clds/model/DcaeEvent.java186
-rw-r--r--src/main/java/org/onap/clamp/clds/model/ValueItem.java65
-rw-r--r--src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java171
-rw-r--r--src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java38
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java81
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Global.java179
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Holmes.java71
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java173
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java107
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java380
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Policy.java95
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java125
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java330
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/Tca.java72
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java119
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java96
-rw-r--r--src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java68
-rw-r--r--src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java27
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java11
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java367
-rw-r--r--src/main/java/org/onap/clamp/clds/transform/XslTransformer.java75
-rw-r--r--src/main/java/org/onap/clamp/clds/util/JsonUtils.java27
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java42
61 files changed, 231 insertions, 8198 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index bac328d6..efc4b128 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -37,8 +37,6 @@ import java.security.cert.X509Certificate;
import java.util.Enumeration;
import org.apache.catalina.connector.Connector;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.ClampVersioning;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -65,7 +63,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "org.onap.clamp" })
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
- UserDetailsServiceAutoConfiguration.class })
+ UserDetailsServiceAutoConfiguration.class })
@EnableJpaRepositories(basePackages = { "org.onap.clamp" })
@EntityScan(basePackages = { "org.onap.clamp" })
@EnableTransactionManagement
@@ -98,28 +96,21 @@ public class Application extends SpringBootServletInitializer {
}
public static void main(String[] args) {
- // This is to initialize some Onap Clamp components
- initializeComponents();
// Start the Spring application
SpringApplication.run(Application.class, args);
}
- private static void initializeComponents() {
- ModelProperties.registerModelElement(Holmes.class, Holmes.getType());
- }
-
/**
* This method is used to declare the camel servlet.
*
* @return A servlet bean
- * @throws IOException
- * IO Exception
+ * @throws IOException IO Exception
*/
@Bean
public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
- eelfLogger.info(
- ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v" + ClampVersioning.getCldsVersionFromProps()
- + ")" + System.getProperty("line.separator") + getSslExpirationDate());
+ eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v"
+ + ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator")
+ + getSslExpirationDate());
ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/*");
registration.setName("CamelServlet");
return registration;
@@ -147,7 +138,7 @@ public class Application extends SpringBootServletInitializer {
private Connector createRedirectConnector(int redirectSecuredPort) {
if (redirectSecuredPort <= 0) {
eelfLogger.warn("HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1"
- + " (Connector disabled)");
+ + " (Connector disabled)");
return null;
}
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
@@ -165,16 +156,16 @@ public class Application extends SpringBootServletInitializer {
KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
keystore.load(
- ResourceFileUtil
- .getResourceAsStream(env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")),
- env.getProperty("server.ssl.key-store-password").toCharArray());
+ ResourceFileUtil.getResourceAsStream(
+ env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")),
+ env.getProperty("server.ssl.key-store-password").toCharArray());
Enumeration<String> aliases = keystore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
if ("X.509".equals(keystore.getCertificate(alias).getType())) {
result.append("* " + alias + " expires "
- + ((X509Certificate) keystore.getCertificate(alias)).getNotAfter()
- + System.getProperty("line.separator"));
+ + ((X509Certificate) keystore.getCertificate(alias)).getNotAfter()
+ + System.getProperty("line.separator"));
}
}
} else {
diff --git a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
deleted file mode 100644
index 8ae10b27..00000000
--- a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Create CLDS Event.
- */
-@Component
-public class CldsEventDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsEventDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private CldsDao cldsDao;
-
- /**
- * Insert event using process variables.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- * @param actionState
- * The action state that is used instead of the one in exchange property
- */
-
- public void addEvent(Exchange camelExchange, String actionState) {
- String controlName = (String) camelExchange.getProperty("controlName");
- String actionCd = (String) camelExchange.getProperty("actionCd");
- String actionStateCd = (actionState != null) ? actionState : CldsEvent.ACTION_STATE_COMPLETED;
- actionStateCd = ((String) camelExchange.getProperty("actionStateCd")) != null
- ? ((String) camelExchange.getProperty("actionStateCd"))
- : actionStateCd;
- // Flag indicate whether it is triggered by Validation Test button from
- // UI
- boolean isTest = (boolean) camelExchange.getProperty("isTest");
- boolean isInsertTestEvent = (boolean) camelExchange.getProperty("isInsertTestEvent");
- String userid = (String) camelExchange.getProperty("userid");
- // do not insert events for test actions unless flag set to insert them
- if (!isTest || isInsertTestEvent) {
- // won't really have userid here...
- CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, camelExchange.getExchangeId());
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
deleted file mode 100644
index 83401a3c..00000000
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.util.Date;
-
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.util.HttpConnectionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * This class implements the communication with DCAE for the service
- * deployments.
- */
-@Component
-public class DcaeDispatcherServices {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private final ClampProperties refProp;
- private final HttpConnectionManager dcaeHttpConnectionManager;
- private static final String STATUS_URL_LOG = "Status URL extracted: ";
- private static final String DCAE_URL_PREFIX = "/dcae-deployments/";
- private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";
- private static final String DCAE_LINK_FIELD = "links";
- private static final String DCAE_STATUS_FIELD = "status";
-
- @Autowired
- public DcaeDispatcherServices(ClampProperties refProp, HttpConnectionManager dcaeHttpConnectionManager) {
- this.refProp = refProp;
- this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
- }
-
- /**
- * Get the Operation Status from a specified URL with retry.
- * @param operationStatusUrl
- * The URL of the DCAE
- * @return The status
- * @throws InterruptedException Exception during the retry
- */
- public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {
- String operationStatus = "";
- for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {
- logger.info("Trying to get Operation status on DCAE for url:" + operationStatusUrl);
- operationStatus = getOperationStatus(operationStatusUrl);
- logger.info("Current Status is:" + operationStatus);
- if (!"processing".equalsIgnoreCase(operationStatus)) {
- return operationStatus;
- } else {
- Thread.sleep(Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.interval")));
- }
- }
- logger.warn("Number of attempts on DCAE is over, stopping the getOperationStatus method");
- return operationStatus;
- }
-
- /**
- * Get the Operation Status from a specified URL.
- * @param statusUrl
- * The URL provided by a previous DCAE Query
- * @return The status
- */
- public String getOperationStatus(String statusUrl) {
- // Assigning processing status to monitor operation status further
- String opStatus = "processing";
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "getOperationStatus");
- try {
- String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null,
- null, "DCAE", null,
- null);
- JSONObject jsonObj = parseResponse(responseStr);
- String operationType = (String) jsonObj.get("operationType");
- String status = (String) jsonObj.get(DCAE_STATUS_FIELD);
- logger.info("Operation Type - " + operationType + ", Status " + status);
- LoggingUtils.setResponseContext("0", "Get operation status success", this.getClass().getName());
- opStatus = status;
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Get operation status failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Get operation status error");
- logger.error("Exception occurred during getOperationStatus Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getOperationStatus complete");
- }
- return opStatus;
- }
-
- /**
- * Returns status URL for createNewDeployment operation.
- * @param deploymentId
- * The deployment ID
- * @param serviceTypeId
- * Service type ID
- * @param blueprintInputJson
- * The value for each blueprint parameters in a flat JSON
- * @return The status URL
- */
- public String createNewDeployment(String deploymentId, String serviceTypeId, JsonObject blueprintInputJson) {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "createNewDeployment");
- try {
- JsonObject rootObject = refProp.getJsonTemplate("dcae.deployment.template").getAsJsonObject();
- rootObject.addProperty("serviceTypeId", serviceTypeId);
- if (blueprintInputJson != null) {
- rootObject.add("inputs", blueprintInputJson);
- }
- String apiBodyString = rootObject.toString();
- logger.info("Dcae api Body String - " + apiBodyString);
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
- String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
- LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());
- return statusUrl;
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Create new deployment failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Create new deployment error");
- logger.error("Exception occurred during createNewDeployment Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("createNewDeployment complete");
- }
- }
-
- /***
- * Returns status URL for deleteExistingDeployment operation.
- *
- * @param deploymentId
- * The deployment ID
- * @param serviceTypeId
- * The service Type ID
- * @return The status URL
- */
- public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "deleteExistingDeployment");
- try {
- String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";
- logger.info("Dcae api Body String - " + apiBodyString);
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
- String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
- LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());
- return statusUrl;
-
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Delete existing deployment failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Delete existing deployment error");
- logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",
- e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("deleteExistingDeployment complete");
- }
- }
-
- private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,
- String nodeAttr) throws IOException, ParseException {
- Date startTime = new Date();
- try {
- String responseStr = dcaeHttpConnectionManager.doHttpRequest(url, requestMethod, payload, contentType, "DCAE", null, null);
- JSONObject jsonObj = parseResponse(responseStr);
- JSONObject linksObj = (JSONObject) jsonObj.get(node);
- String statusUrl = (String) linksObj.get(nodeAttr);
- logger.info(STATUS_URL_LOG + statusUrl);
- return statusUrl;
- } catch (IOException | ParseException e) {
- logger.error("Exception occurred getting response from DCAE", e);
- throw e;
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getDcaeResponse complete");
- }
- }
-
- private JSONObject parseResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
- return (JSONObject) parser.parse(responseStr);
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
index 7f209199..0ebaab55 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
@@ -29,20 +29,13 @@ import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.util.Date;
-import java.util.List;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.DcaeEvent;
import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;
-import org.onap.clamp.clds.model.properties.Global;
-import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.LoggingUtils;
import org.onap.clamp.util.HttpConnectionManager;
@@ -62,93 +55,17 @@ public class DcaeInventoryServices {
public static final String DCAE_INVENTORY_RETRY_INTERVAL = "dcae.intentory.retry.interval";
public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";
private final ClampProperties refProp;
- private final CldsDao cldsDao;
private final HttpConnectionManager httpConnectionManager;
/**
* Constructor.
*/
@Autowired
- public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,
- HttpConnectionManager httpConnectionManager) {
+ public DcaeInventoryServices(ClampProperties refProp, HttpConnectionManager httpConnectionManager) {
this.refProp = refProp;
- this.cldsDao = cldsDao;
this.httpConnectionManager = httpConnectionManager;
}
- /**
- * Set the event inventory.
- *
- * @param cldsModel
- * The CldsModel
- * @param userId
- * The user ID
- * @throws ParseException
- * In case of DCAE Json parse exception
- */
- public void setEventInventory(CldsModel cldsModel, String userId) throws InterruptedException {
- String artifactName = cldsModel.getControlName();
- DcaeEvent dcaeEvent = new DcaeEvent();
- DcaeInventoryResponse dcaeResponse = null;
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "setEventInventory");
- if (artifactName != null) {
- artifactName = artifactName + ".yml";
- }
- try {
- // Below are the properties required for calling the dcae inventory
- ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null,
- false, "{}", cldsModel.getPropText());
- Global global = prop.getGlobal();
- String invariantServiceUuid = global.getService();
- List<String> resourceUuidList = global.getResourceVf();
- String resourceUuid = "";
- if (resourceUuidList != null && !resourceUuidList.isEmpty()) {
- resourceUuid = resourceUuidList.get(0);
- }
- /* Inventory service url is called in this method */
- dcaeResponse = getDcaeInformation(artifactName, invariantServiceUuid, resourceUuid);
- /* set dcae events */
- dcaeEvent.setArtifactName(artifactName);
- dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
- LoggingUtils.setResponseContext("0", "Set inventory success", this.getClass().getName());
- } catch (ParseException e) {
- LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Set inventory error");
- logger.error("Error during JSON decoding", e);
- } catch (IOException ex) {
- LoggingUtils.setResponseContext("900", "Set inventory failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Set inventory error");
- logger.error("Error during DCAE communication", ex);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("setEventInventory complete");
- }
- this.analyzeAndSaveDcaeResponse(dcaeResponse, cldsModel, dcaeEvent, userId);
- }
-
- private void analyzeAndSaveDcaeResponse(DcaeInventoryResponse dcaeResponse, CldsModel cldsModel,
- DcaeEvent dcaeEvent, String userId) {
- if (dcaeResponse != null) {
- logger.info("Dcae Response for query on inventory: " + dcaeResponse);
- String oldTypeId = cldsModel.getTypeId();
- if (dcaeResponse.getTypeId() != null) {
- cldsModel.setTypeId(dcaeResponse.getTypeId());
- }
- if (dcaeResponse.getTypeName() != null) {
- cldsModel.setTypeName(dcaeResponse.getTypeName());
- }
- if (oldTypeId == null || !cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_DISTRIBUTE)
- || cldsModel.getEvent().getActionCd().equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE)) {
- CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
- CldsEvent.ACTION_STATE_RECEIVED, null);
- }
- cldsModel.save(cldsDao, userId);
- } else {
- logger.info(cldsModel.getName() + " Model is not present in Dcae Inventory Service.");
- }
- }
-
private int getTotalCountFromDcaeInventoryResponse(String responseStr) throws ParseException {
JSONParser parser = new JSONParser();
Object obj0 = parser.parse(responseStr);
@@ -169,23 +86,18 @@ public class DcaeInventoryServices {
/**
* DO a query to DCAE to get some Information.
*
- * @param artifactName
- * The artifact Name
- * @param serviceUuid
- * The service UUID
- * @param resourceUuid
- * The resource UUID
+ * @param artifactName The artifact Name
+ * @param serviceUuid The service UUID
+ * @param resourceUuid The resource UUID
* @return The DCAE inventory for the artifact in DcaeInventoryResponse
- * @throws IOException
- * In case of issues with the stream
- * @throws ParseException
- * In case of issues with the Json parsing
+ * @throws IOException In case of issues with the stream
+ * @throws ParseException In case of issues with the Json parsing
*/
public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)
- throws IOException, ParseException, InterruptedException {
+ throws IOException, ParseException, InterruptedException {
LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");
String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="
- + artifactName;
+ + artifactName;
String fullUrl = refProp.getStringValue(DCAE_INVENTORY_URL) + "/dcae-service-types" + queryString;
logger.info("Dcae Inventory Service full url - " + fullUrl);
DcaeInventoryResponse response = queryDcaeInventory(fullUrl);
@@ -196,7 +108,7 @@ public class DcaeInventoryServices {
}
private DcaeInventoryResponse queryDcaeInventory(String fullUrl)
- throws IOException, InterruptedException, ParseException {
+ throws IOException, InterruptedException, ParseException {
int retryInterval = 0;
int retryLimit = 1;
if (refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT) != null) {
@@ -215,7 +127,7 @@ public class DcaeInventoryServices {
return getItemsFromDcaeInventoryResponse(response);
}
logger.info(
- "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");
+ "Dcae inventory totalCount returned is 0, so waiting " + retryInterval + "ms before retrying ...");
// wait for a while and try to connect to DCAE again
Thread.sleep(retryInterval);
}
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
deleted file mode 100644
index 3229337b..00000000
--- a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Guard Policy info to policy API. It uses the policy code to define the
- * model and communicate with it. See also the PolicyClient class.
- */
-@Component
-public class GuardPolicyDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(GuardPolicyDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private final PolicyClient policyClient;
-
- @Autowired
- public GuardPolicyDelegate(PolicyClient policyClient) {
- this.policyClient = policyClient;
- }
-
- /**
- * Perform activity. Send Guard Policies info to policy api.
- *
- * @param camelExchange The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- Policy policy = prop.getType(Policy.class);
- if (policy.isFound()) {
- for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for (PolicyItem policyItem : GuardPolicyAttributesConstructor
- .getAllPolicyGuardsFromPolicyChain(policyChain)) {
- prop.setCurrentModelElementId(policy.getId());
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- prop.setGuardUniqueId(policyItem.getId());
- policyClient.sendGuardPolicy(GuardPolicyAttributesConstructor
- .formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(), policyItem);
- }
- }
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
deleted file mode 100644
index ae962a0b..00000000
--- a/src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Operational Policy via policy api.
- */
-@Component
-public class GuardPolicyDeleteDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(GuardPolicyDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private final PolicyClient policyClient;
-
- @Autowired
- public GuardPolicyDeleteDelegate(PolicyClient policyClient) {
- this.policyClient = policyClient;
- }
-
- /**
- * Perform activity. Delete Operational Policy via policy api.
- *
- * @param camelExchange The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- Policy policy = prop.getType(Policy.class);
-
- String eventAction = (String) camelExchange.getProperty("eventAction");
- if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
- for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for (PolicyItem policyItem : GuardPolicyAttributesConstructor
- .getAllPolicyGuardsFromPolicyChain(policyChain)) {
- prop.setCurrentModelElementId(policy.getId());
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- prop.setGuardUniqueId(policyItem.getId());
- policyClient.deleteGuard(prop);
- }
- }
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java
deleted file mode 100644
index e178ec71..00000000
--- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.UUID;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Holmes info to policy api.
- */
-@Component
-public class HolmesPolicyDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private PolicyClient policyClient;
- @Autowired
- private ClampProperties refProp;
- @Autowired
- private CldsDao cldsDao;
-
- /**
- * Perform activity. Send Holmes info to policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- String holmesPolicyRequestUuid = UUID.randomUUID().toString();
- camelExchange.setProperty("holmesPolicyRequestUuid", holmesPolicyRequestUuid);
- ModelProperties prop = ModelProperties.create(camelExchange);
- Holmes holmes = prop.getType(Holmes.class);
- if (holmes.isFound()) {
- String responseMessage = policyClient.sendBasePolicyInOther(formatHolmesConfigBody(prop, holmes),
- holmes.getConfigPolicyName(), prop, holmesPolicyRequestUuid);
- if (responseMessage != null) {
- camelExchange.setProperty("holmesPolicyResponseMessage", responseMessage.getBytes());
- }
- CldsModel cldsModel = CldsModel.retrieve(cldsDao, (String) camelExchange.getProperty("modelName"), false);
- cldsModel.setPropText(cldsModel.getPropText().replaceAll("AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
- prop.getPolicyNameForDcaeDeploy(refProp)));
- cldsModel.save(cldsDao, (String) camelExchange.getProperty("userid"));
- }
- }
-
- /**
- * This method is used to create the Payload that must be sent to Holmes.
- *
- * @param prop
- * The ModelProperties containing all the closed loop props
- * @param holmes
- * The holmes object extracted from the closed loop
- * @return The String that must be sent to policy for holmes
- */
- public static String formatHolmesConfigBody(ModelProperties prop, Holmes holmes) {
- return prop.getControlName() + "$$$" + holmes.getCorrelationLogic();
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java
deleted file mode 100644
index 965698db..00000000
--- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Holmes Policy via policy api.
- */
-@Component
-public class HolmesPolicyDeleteDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private PolicyClient policyClient;
-
- /**
- * Perform activity. Delete Holmes Policy via policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- Holmes holmes = prop.getType(Holmes.class);
- if (holmes.isFound()) {
- prop.setCurrentModelElementId(holmes.getId());
- policyClient.deleteBasePolicy(prop);
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java
deleted file mode 100644
index 6a369db9..00000000
--- a/src/main/java/org/onap/clamp/clds/client/ModelDeleteDelegate.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete model.
- */
-@Component
-public class ModelDeleteDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private CldsDao cldsDao;
-
- /**
- * Insert event using process variables.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- String modelName = (String) camelExchange.getProperty("modelName");
- cldsDao.deleteModel(modelName);
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
deleted file mode 100644
index 307c8e51..00000000
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Operational Policy info to policy api. It uses the policy code to define
- * the model and communicate with it. See also the PolicyClient class.
- */
-@Component
-public class OperationalPolicyDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private final PolicyClient policyClient;
- private final ClampProperties refProp;
-
- @Autowired
- public OperationalPolicyDelegate(PolicyClient policyClient, ClampProperties refProp) {
- this.policyClient = policyClient;
- this.refProp = refProp;
- }
-
- /**
- * Perform activity. Send Operational Policy info to policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- * @throws BuilderException
- * In case of issues with OperationalPolicyRequestAttributesConstructor
- * @throws UnsupportedEncodingException
- * In case of issues with the Charset encoding
- */
- @Handler
- public void execute(Exchange camelExchange) throws BuilderException, UnsupportedEncodingException {
- String responseMessage = null;
- ModelProperties prop = ModelProperties.create(camelExchange);
- Policy policy = prop.getType(Policy.class);
- if (policy.isFound()) {
- for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor
- .formatAttributes(refProp,prop, prop.getType(Policy.class).getId(), policyChain);
- responseMessage = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
- }
- if (responseMessage != null) {
- camelExchange.setProperty("operationalPolicyResponseMessage", responseMessage.getBytes());
- }
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
deleted file mode 100644
index adec94f3..00000000
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Operational Policy via policy api.
- */
-@Component
-public class OperationalPolicyDeleteDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(OperationalPolicyDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private PolicyClient policyClient;
-
- /**
- * Perform activity. Delete Operational Policy via policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- Policy policy = prop.getType(Policy.class);
- prop.setCurrentModelElementId(policy.getId());
- String eventAction = (String) camelExchange.getProperty("eventAction");
- if (policy.getPolicyChains() != null && !policy.getPolicyChains().isEmpty()
- && !eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
- for (PolicyChain policyChain : policy.getPolicyChains()) {
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- logger.info("Policy Delete response: " + policyClient.deleteBrms(prop));
- }
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java
deleted file mode 100644
index cb31b5f6..00000000
--- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.UUID;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Send Tca info to policy api.
- */
-@Component
-public class TcaPolicyDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private ClampProperties refProp;
- @Autowired
- private PolicyClient policyClient;
- @Autowired
- private CldsDao cldsDao;
-
- /**
- * Perform activity. Send Tca info to policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- String tcaPolicyRequestUuid = UUID.randomUUID().toString();
- camelExchange.setProperty("tcaPolicyRequestUuid", tcaPolicyRequestUuid);
- ModelProperties prop = ModelProperties.create(camelExchange);
- Tca tca = prop.getType(Tca.class);
- if (tca.isFound()) {
- String policyJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
- String responseMessage = policyClient.sendMicroServiceInOther(policyJson, prop);
- if (responseMessage != null) {
- camelExchange.setProperty("tcaPolicyResponseMessage", responseMessage.getBytes());
- }
- CldsModel cldsModel = CldsModel.retrieve(cldsDao, (String) camelExchange.getProperty("modelName"), false);
- cldsModel.setPropText(cldsModel.getPropText().replaceAll("AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
- prop.getPolicyNameForDcaeDeploy(refProp)));
- cldsModel.save(cldsDao, (String) camelExchange.getProperty("userid"));
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java
deleted file mode 100644
index a3fcc53b..00000000
--- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * Delete Tca Policy via policy api.
- */
-@Component
-public class TcaPolicyDeleteDelegate {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- @Autowired
- private PolicyClient policyClient;
-
- /**
- * Perform activity. Delete Tca Policy via policy api.
- *
- * @param camelExchange
- * The Camel Exchange object containing the properties
- */
- @Handler
- public void execute(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- Tca tca = prop.getType(Tca.class);
- if (tca.isFound()) {
- prop.setCurrentModelElementId(tca.getId());
- String responseMessage = policyClient.deleteMicrosService(prop);
- if (responseMessage != null) {
- camelExchange.setProperty("tcaPolicyDeleteResponseMessage", responseMessage.getBytes());
- }
- }
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
deleted file mode 100644
index e996ae82..00000000
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.EnumMap;
-
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.api.AttributeType;
-
-public class GuardPolicyAttributesConstructor {
- public static final String ACTOR = "actor";
- public static final String RECIPE = "recipe";
- public static final String TARGETS = "targets";
- public static final String CLNAME = "clname";
- public static final String MIN = "min";
- public static final String MAX = "max";
- public static final String LIMIT = "limit";
- public static final String TIME_WINDOW = "timeWindow";
- public static final String TIME_UNITS = "timeUnits";
- public static final String GUARD_ACTIVE_START = "guardActiveStart";
- public static final String GUARD_ACTIVE_END = "guardActiveEnd";
-
- private static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(GuardPolicyAttributesConstructor.class);
-
- private GuardPolicyAttributesConstructor() {
- }
-
- public static Map<AttributeType, Map<String, String>> formatAttributes(ModelProperties modelProperties,
- PolicyItem policyItem) {
- Map<String, String> matchingAttributes = prepareMatchingAttributes(policyItem, modelProperties);
- return createAttributesMap(matchingAttributes);
- }
-
- /**
- * Get all the Guard policies from the policy chain.
- * @param policyChain The policy chain
- * @return The list of guard policies
- */
- public static List<PolicyItem> getAllPolicyGuardsFromPolicyChain(PolicyChain policyChain) {
- List<PolicyItem> listItem = new ArrayList<>();
- for (PolicyItem policyItem : policyChain.getPolicyItems()) {
- if ("on".equals(policyItem.getEnableGuardPolicy())) {
- listItem.add(policyItem);
- }
- }
- return listItem;
- }
-
- private static Map<String, String> prepareMatchingAttributes(PolicyItem policyItem, ModelProperties modelProp) {
- logger.info("Preparing matching attributes for guard...");
- Map<String, String> matchingAttributes = new HashMap<>();
- matchingAttributes.put(ACTOR, policyItem.getActor());
- matchingAttributes.put(RECIPE, policyItem.getRecipe());
- matchingAttributes.put(TARGETS, policyItem.getGuardTargets());
- matchingAttributes.put(CLNAME, modelProp.getControlNameAndPolicyUniqueId());
- if ("GUARD_MIN_MAX".equals(policyItem.getGuardPolicyType())) {
- matchingAttributes.put(MIN, policyItem.getMinGuard());
- matchingAttributes.put(MAX, policyItem.getMaxGuard());
- } else if ("GUARD_YAML".equals(policyItem.getGuardPolicyType())) {
- matchingAttributes.put(LIMIT, policyItem.getLimitGuard());
- matchingAttributes.put(TIME_WINDOW, policyItem.getTimeWindowGuard());
- matchingAttributes.put(TIME_UNITS, policyItem.getTimeUnitsGuard());
- }
- matchingAttributes.put(GUARD_ACTIVE_START, policyItem.getGuardActiveStart());
- matchingAttributes.put(GUARD_ACTIVE_END, policyItem.getGuardActiveEnd());
-
- logger.info("Prepared: " + matchingAttributes);
- return matchingAttributes;
- }
-
- private static Map<AttributeType, Map<String, String>> createAttributesMap(Map<String, String> matchingAttributes) {
- Map<AttributeType, Map<String, String>> attributes = new EnumMap<>(AttributeType.class);
- attributes.put(AttributeType.MATCHING, matchingAttributes);
- return attributes;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java
deleted file mode 100644
index af23626d..00000000
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-
-public class OperationalPolicyAttributesConstructor {
-
- private static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(OperationalPolicyAttributesConstructor.class);
- public static final String TEMPLATE_NAME = "templateName";
- public static final String CLOSED_LOOP_CONTROL_NAME = "closedLoopControlName";
- public static final String NOTIFICATION_TOPIC = "notificationTopic";
- public static final String OPERATION_TOPIC = "operationTopic";
- public static final String CONTROL_LOOP_YAML = "controlLoopYaml";
- public static final String CONTROLLER = "controller";
- public static final String RECIPE = "Recipe";
- public static final String MAX_RETRIES = "MaxRetries";
- public static final String RETRY_TIME_LIMIT = "RetryTimeLimit";
- public static final String RESOURCE_ID = "ResourceId";
- public static final String RECIPE_TOPIC = "RecipeTopic";
-
- private OperationalPolicyAttributesConstructor() {
- }
-
- /**
- * Format the attributes.
- * @param refProp The Clamp properties
- * @param modelProperties The model properties
- * @param modelElementId The model element ID
- * @param policyChain The policy chain
- * @return The attributes map
- * @throws BuilderException Exception while building up the attributes map
- * @throws UnsupportedEncodingException Unsupported encoding exception
- */
- public static Map<AttributeType, Map<String, String>> formatAttributes(ClampProperties refProp,
- ModelProperties modelProperties,
- String modelElementId, PolicyChain policyChain)
- throws BuilderException, UnsupportedEncodingException {
- modelProperties.setCurrentModelElementId(modelElementId);
- modelProperties.setPolicyUniqueId(policyChain.getPolicyId());
-
- String globalService = modelProperties.getGlobal().getService();
-
- Map<String, String> ruleAttributes = prepareRuleAttributes(refProp, modelProperties, modelElementId,
- policyChain, globalService);
- Map<String, String> matchingAttributes = prepareMatchingAttributes(refProp, globalService);
-
- return createAttributesMap(matchingAttributes, ruleAttributes);
- }
-
- private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties,
- ModelProperties modelProperties,
- String modelElementId, PolicyChain policyChain, String globalService)
- throws BuilderException, UnsupportedEncodingException {
- logger.info("Preparing rule attributes...");
- String templateName = clampProperties.getStringValue("op.templateName", globalService);
- String operationTopic = clampProperties.getStringValue("op.operationTopic", globalService);
- String notificationTopic = clampProperties.getStringValue("op.notificationTopic", globalService);
-
- Map<String, String> ruleAttributes = new HashMap<>();
- ruleAttributes.put(TEMPLATE_NAME, templateName);
- ruleAttributes.put(CLOSED_LOOP_CONTROL_NAME, modelProperties.getControlNameAndPolicyUniqueId());
- ruleAttributes.put(NOTIFICATION_TOPIC, notificationTopic);
-
- ImmutableMap<String, String> attributes = createRuleAttributesFromPolicy(clampProperties, modelProperties,
- modelElementId, policyChain, globalService, operationTopic);
- ruleAttributes.putAll(attributes);
- logger.info("Prepared: " + ruleAttributes);
- return ruleAttributes;
- }
-
- private static Map<String, String> prepareMatchingAttributes(ClampProperties refProp, String globalService) {
- logger.info("Preparing matching attributes...");
- String controller = refProp.getStringValue("op.controller", globalService);
- Map<String, String> matchingAttributes = new HashMap<>();
- matchingAttributes.put(CONTROLLER, controller);
- logger.info("Prepared: " + matchingAttributes);
- return matchingAttributes;
- }
-
- private static Map<AttributeType, Map<String, String>> createAttributesMap(Map<String, String> matchingAttributes,
- Map<String, String> ruleAttributes) {
- Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
- attributes.put(AttributeType.RULE, ruleAttributes);
- attributes.put(AttributeType.MATCHING, matchingAttributes);
- return attributes;
- }
-
- private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp,
- ModelProperties modelProperties,
- String modelElementId, PolicyChain policyChain,
- String globalService, String operationTopic)
- throws BuilderException, UnsupportedEncodingException {
- if (Strings.isNullOrEmpty(operationTopic)) {
- // if no operationTopic, then don't format yaml - use first policy
- String recipeTopic = refProp.getStringValue("op.recipeTopic", globalService);
- return createRuleAttributesFromPolicyItem(
- policyChain.getPolicyItems().get(0), recipeTopic);
- } else {
- return createRuleAttributesFromPolicyChain(policyChain, modelProperties,
- modelElementId, operationTopic);
- }
- }
-
- private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem,
- String recipeTopic) {
- logger.info("recipeTopic=" + recipeTopic);
- return ImmutableMap.<String, String>builder()
- .put(RECIPE_TOPIC, recipeTopic)
- .put(RECIPE, policyItem.getRecipe())
- .put(MAX_RETRIES, String.valueOf(policyItem.getMaxRetries()))
- .put(RETRY_TIME_LIMIT, String.valueOf(policyItem.getRetryTimeLimit()))
- .put(RESOURCE_ID, String.valueOf(policyItem.getTargetResourceId()))
- .build();
- }
-
- private static ImmutableMap<String, String> createRuleAttributesFromPolicyChain(PolicyChain policyChain,
- ModelProperties modelProperties,
- String modelElementId,
- String operationTopic)
- throws BuilderException, UnsupportedEncodingException {
- logger.info("operationTopic=" + operationTopic);
- String yaml = OperationalPolicyYamlFormatter.formatYaml(modelProperties, modelElementId, policyChain);
- return ImmutableMap.<String, String>builder()
- .put(OPERATION_TOPIC, operationTopic)
- .put(CONTROL_LOOP_YAML, yaml)
- .build();
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
deleted file mode 100644
index f2536b1f..00000000
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.BadRequestException;
-
-import org.onap.clamp.clds.model.properties.Global;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder;
-import org.onap.policy.controlloop.policy.builder.Message;
-import org.onap.policy.controlloop.policy.builder.Results;
-import org.onap.policy.sdc.Resource;
-import org.onap.policy.sdc.ResourceType;
-import org.onap.policy.sdc.Service;
-
-public class OperationalPolicyYamlFormatter {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyYamlFormatter.class);
-
- protected OperationalPolicyYamlFormatter() {
- }
-
- /**
- * Format Operational OpenLoop Policy yaml.
- *
- * @param prop The model properties
- * @param modelElementId The model element ID
- * @param policyChain The policy chain
- * @return The operational openloop policy in yaml format
- * @throws BuilderException The builder exception
- * @throws UnsupportedEncodingException The unsupported encoding exception
- */
- public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
- throws BuilderException, UnsupportedEncodingException {
- // get property objects
- Global global = prop.getGlobal();
- prop.setCurrentModelElementId(modelElementId);
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- // convert values to SDC objects
- Service service = new Service(global.getService());
- Resource[] vfResources = convertToResources(global.getResourceVf(), ResourceType.VF);
- // create builder
- ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
- policyChain.getTimeout(), service, vfResources);
- // builder.setTriggerPolicy(refProp.getStringValue("op.openloop.policy"));
- // Build the specification
- Results results = builder.buildSpecification();
- validate(results);
- return URLEncoder.encode(results.getSpecification(), "UTF-8");
- }
-
- /**
- * Format Operational Policy yaml.
- * @param prop The model properties
- * @param modelElementId The model element ID
- * @param policyChain The policy chain
- * @return The operational policy properties in yaml format
- * @throws BuilderException The builder exception
- * @throws UnsupportedEncodingException The unsupported encoding exception
- */
- public static String formatYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
- throws BuilderException, UnsupportedEncodingException {
- // get property objects
- prop.setCurrentModelElementId(modelElementId);
- prop.setPolicyUniqueId(policyChain.getPolicyId());
-
- // create builder
- ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
- policyChain.getTimeout());
- // process each policy
- Map<String, Policy> policyObjMap = new HashMap<>();
- List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems());
- for (PolicyItem policyItem : policyItemList) {
- String policyName = policyItem.getRecipe() + " Policy";
- Target target = new Target();
- target.setType(TargetType.VM);
- // We can send target type as VM/VNF for most of recipes
- if (policyItem.getRecipeLevel() != null && !policyItem.getRecipeLevel().isEmpty()) {
- target.setType(TargetType.valueOf(policyItem.getRecipeLevel()));
- }
- target.setResourceID(policyItem.getTargetResourceId());
- String actor = policyItem.getActor();
- Map<String, String> payloadMap = policyItem.getRecipePayload();
- Policy policyObj;
- if (policyItemList.indexOf(policyItem) == 0) {
- String policyDescription = policyItem.getRecipe()
- + " Policy - the trigger (no parent) policy - created by CLDS";
- policyObj = builder.setTriggerPolicy(policyName, policyDescription, actor, target,
- policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit());
- } else {
- Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy());
- String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by "
- + parentPolicyObj.getName() + " - created by CLDS";
- policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, actor, target,
- policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(),
- parentPolicyObj.getId(), convertToPolicyResults(policyItem.getParentPolicyConditions()));
- logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId());
- }
- policyObjMap.put(policyItem.getId(), policyObj);
- }
- // Build the specification
- Results results = builder.buildSpecification();
- validate(results);
- return URLEncoder.encode(results.getSpecification(), "UTF-8");
- }
-
- protected static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
- List<PolicyItem> inList = new ArrayList<>();
- inList.addAll(inOrigList);
- List<PolicyItem> outList = new ArrayList<>();
- int prevSize = 0;
- while (!inList.isEmpty()) {
- // check if there's a loop in the policy chain (the inList should
- // have been reduced by at least one)
- if (inList.size() == prevSize) {
- throw new BadRequestException("Operation Policy validation problem: loop in Operation Policy chain");
- }
- prevSize = inList.size();
- // the following loop should remove at least one PolicyItem from the
- // inList
- Iterator<PolicyItem> inListItr = inList.iterator();
- while (inListItr.hasNext()) {
- PolicyItem inItem = inListItr.next();
- // check for trigger policy (no parent)
- String parent = inItem.getParentPolicy();
- if (parent == null || parent.length() == 0) {
- if (!outList.isEmpty()) {
- throw new BadRequestException(
- "Operation Policy validation problem: more than one trigger policy");
- } else {
- outList.add(inItem);
- inListItr.remove();
- }
- } else {
- // check if this PolicyItem's parent has been processed
- for (PolicyItem outItem : outList) {
- if (outItem.getId().equals(parent)) {
- // if the inItem parent is already in the outList,
- // then add inItem to outList and remove from inList
- outList.add(inItem);
- inListItr.remove();
- break;
- }
- }
- }
- }
- }
- return outList;
- }
-
- protected static void validate(Results results) {
- if (results.isValid()) {
- logger.info("results.getSpecification()=" + results.getSpecification());
- } else {
- // throw exception with error info
- StringBuilder sb = new StringBuilder();
- sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
- for (Message message : results.getMessages()) {
- sb.append(message.getMessage());
- sb.append("; ");
- }
- throw new BadRequestException(sb.toString());
- }
- }
-
- protected static Resource[] convertToResources(List<String> stringList, ResourceType resourceType) {
- if (stringList == null || stringList.isEmpty()) {
- return new Resource[0];
- }
- return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
- }
-
- protected static PolicyResult[] convertToPolicyResults(List<String> prList) {
- if (prList == null || prList.isEmpty()) {
- return new PolicyResult[0];
- }
- return prList.stream().map(PolicyResult::toResult).toArray(PolicyResult[]::new);
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
deleted file mode 100644
index 68d8529c..00000000
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
+++ /dev/null
@@ -1,681 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.BadRequestException;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.config.PolicyConfiguration;
-import org.onap.clamp.clds.exception.policy.PolicyClientException;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.ConfigRequestParameters;
-import org.onap.policy.api.DeletePolicyCondition;
-import org.onap.policy.api.DeletePolicyParameters;
-import org.onap.policy.api.DictionaryType;
-import org.onap.policy.api.ImportParameters;
-import org.onap.policy.api.ImportParameters.IMPORT_TYPE;
-import org.onap.policy.api.PolicyChangeResponse;
-import org.onap.policy.api.PolicyClass;
-import org.onap.policy.api.PolicyConfigException;
-import org.onap.policy.api.PolicyConfigType;
-import org.onap.policy.api.PolicyEngine;
-import org.onap.policy.api.PolicyEngineException;
-import org.onap.policy.api.PolicyParameters;
-import org.onap.policy.api.PolicyType;
-import org.onap.policy.api.PushPolicyParameters;
-import org.onap.policy.api.RuleProvider;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
-
-/**
- * Policy utility methods - specifically, send the policy.
- */
-@Component
-@Primary
-public class PolicyClient {
-
- private PolicyEngine policyEngine;
- private static final String LOG_POLICY_PREFIX = "Response is ";
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
- private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type";
- private static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name";
- private static final String POLICY_BASENAME_PREFIX_PROPERTY_NAME = "policy.base.policyNamePrefix";
- private static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix";
- public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix";
- private static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type";
- private static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath";
- private static final String POLICY_COMMUNICATION_LOG_MESSAGE = "Exception occurred during policy communication";
- private static final String POLICY_COMMUNICATION_EXC_MESSAGE = "Exception while communicating with Policy";
- private static final String POLICY = "Policy";
-
- @Autowired
- private ClampProperties refProp;
- @Autowired
- private PolicyConfiguration policyConfiguration;
-
- /**
- * Perform Guard policy type.
- *
- * @param attributes
- * A map of attributes
- * @param prop
- * The ModelProperties
- * @param policyRequestUuid
- * PolicyRequest UUID
- * @return The response message of policy
- */
- public String sendGuardPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
- String policyRequestUuid, PolicyItem policyItem) {
- PolicyParameters policyParameters = new PolicyParameters();
- // Set Policy Type(Mandatory)
- policyParameters.setPolicyClass(PolicyClass.Decision);
- // Set Policy Name(Mandatory)
- policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueGuardId());
- // documentation says this is options, but when tested, got the
- // following failure: java.lang.Exception: Policy send failed: PE300 -
- // Data Issue: No policyDescription given.
- policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription"));
- policyParameters.setOnapName("PDPD");
- policyParameters.setRuleProvider(RuleProvider.valueOf(policyItem.getGuardPolicyType()));
- policyParameters.setAttributes(attributes);
- // Set a random UUID(Mandatory)
- policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
-
- String rtnMsg = send(policyParameters, prop, null, null);
- push(DictionaryType.Decision.toString(), prop, null);
- return rtnMsg;
- }
-
- /**
- * Perform BRMS policy type.
- *
- * @param attributes
- * A map of attributes
- * @param prop
- * The ModelProperties
- * @param policyRequestUuid
- * PolicyRequest UUID
- * @return The response message of policy
- */
- public String sendBrmsPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
- String policyRequestUuid) {
- PolicyParameters policyParameters = new PolicyParameters();
- // Set Policy Type(Mandatory)
- policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
- // Set Policy Name(Mandatory)
- policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId());
- // documentation says this is options, but when tested, got the
- // following failure: java.lang.Exception: Policy send failed: PE300 -
- // Data Issue: No policyDescription given.
- policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription"));
- policyParameters.setAttributes(attributes);
- // Set a random UUID(Mandatory)
- policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
- String policyNamePrefix = refProp.getStringValue(POLICY_OP_NAME_PREFIX_PROPERTY_NAME);
- String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
- String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME);
- push(policyType, prop, null);
- return rtnMsg;
- }
-
- /**
- * Perform send of microservice policy in JSON.
- *
- * @param policyJson
- * The policy JSON
- * @param prop
- * The ModelProperties
- * @param policyRequestUuid
- * The policy Request UUID
- * @return The response message of policy
- */
- public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) {
- PolicyParameters policyParameters = new PolicyParameters();
- // Set Policy Type
- policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
- policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
- policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
- policyParameters.setConfigBody(policyJson);
- policyParameters.setConfigBodyType(PolicyType.JSON);
- policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
- String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
- // Adding this line to clear the policy id from policy name while
- // pushing to policy engine
- prop.setPolicyUniqueId("");
- String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
- String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
- push(policyType, prop, null);
- return rtnMsg;
- }
-
- /**
- * Perform send of base policy in OTHER type.
- *
- * @param configBody
- * The config policy string body
- * @param configPolicyName
- * The config policy name of the component that has been pre-deployed in
- * DCAE
- * @param prop
- * The ModelProperties
- * @param policyRequestUuid
- * The policy request UUID
- * @return The answer from policy call
- */
- public String sendBasePolicyInOther(String configBody, String configPolicyName, ModelProperties prop,
- String policyRequestUuid) {
- PolicyParameters policyParameters = new PolicyParameters();
- // Set Policy Type
- policyParameters.setPolicyConfigType(PolicyConfigType.Base);
- policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
- policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
- policyParameters.setConfigBody(configBody);
- policyParameters.setConfigBodyType(PolicyType.OTHER);
- policyParameters.setConfigName("HolmesPolicy");
- policyParameters.setPolicyName(configPolicyName);
- policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
- // Adding this line to clear the policy id from policy name while
- // pushing to policy engine
- prop.setPolicyUniqueId("");
- String rtnMsg = send(policyParameters, prop, refProp.getStringValue(POLICY_BASENAME_PREFIX_PROPERTY_NAME),
- null);
- push(PolicyConfigType.Base.toString(), prop, null);
- return rtnMsg;
- }
-
- /**
- * Perform send of Microservice policy in OTHER type.
- *
- * @param configBody
- * The config policy string body
- * @param prop
- * The ModelProperties
- * @return The answer from policy call
- */
- public String sendMicroServiceInOther(String configBody, ModelProperties prop) {
- PolicyParameters policyParameters = new PolicyParameters();
- // Set Policy Type
- policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
- policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
- policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
- policyParameters.setConfigBody(configBody);
- String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
- // Adding this line to clear the policy id from policy name while
- // pushing to policy engine
- prop.setPolicyUniqueId("");
- String rtnMsg = send(policyParameters, prop, policyNamePrefix, null);
- String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
- push(policyType, prop, null);
- return rtnMsg;
- }
-
- /**
- * Perform send of Configuration or Decision policies.
- *
- * @param policyParameters
- * The PolicyParameters
- * @param prop
- * The ModelProperties
- * @return The response message of Policy
- */
- protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyPrefix,
- String policyNameWithPrefix) {
- // Verify whether it is triggered by Validation Test button from UI
- if (prop.isTestOnly()) {
- return "send not executed for test action";
- }
- // API method to create or update Policy.
- PolicyChangeResponse response = null;
- String responseMessage = "";
- Date startTime = new Date();
- try {
- if ((PolicyClass.Decision.equals(policyParameters.getPolicyClass()) && !checkDecisionPolicyExists(prop))
- || (PolicyClass.Config.equals(policyParameters.getPolicyClass())
- && !checkPolicyExists(prop, policyPrefix, policyNameWithPrefix))) {
- LoggingUtils.setTargetContext(POLICY, "createPolicy");
- logger.info("Attempting to create policy for action=" + prop.getActionCd());
- response = getPolicyEngine().createPolicy(policyParameters);
- responseMessage = response.getResponseMessage();
- } else {
- LoggingUtils.setTargetContext(POLICY, "updatePolicy");
- logger.info("Attempting to update policy for action=" + prop.getActionCd());
- response = getPolicyEngine().updatePolicy(policyParameters);
- responseMessage = response.getResponseMessage();
- }
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Policy send error");
- logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
- throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
- }
- logger.info(LOG_POLICY_PREFIX + responseMessage);
- LoggingUtils.setTimeContext(startTime, new Date());
- if (response.getResponseCode() == 200) {
- LoggingUtils.setResponseContext("0", "Policy send success", this.getClass().getName());
- logger.info("Policy send successful");
- metricsLogger.info("Policy send success");
- } else {
- LoggingUtils.setResponseContext("900", "Policy send failed", this.getClass().getName());
- logger.warn("Policy send failed: " + responseMessage);
- metricsLogger.info("Policy send failure");
- throw new BadRequestException("Policy send failed: " + responseMessage);
- }
- return responseMessage;
- }
-
- /**
- * Format and send push of policy.
- *
- * @param policyType
- * The policy Type
- * @param prop
- * The ModelProperties
- * @return The response message of policy
- */
- protected String push(String policyType, ModelProperties prop, String policyName) {
- // Verify whether it is triggered by Validation Test button from UI
- if (prop.isTestOnly()) {
- return "push not executed for test action";
- }
- PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
- pushPolicyParameters.setPolicyName(selectRightPolicyName(prop, policyType, policyName));
- logger.info("Policy Name in Push policy method - " + pushPolicyParameters.getPolicyName());
- pushPolicyParameters.setPolicyType(policyType);
- pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
- pushPolicyParameters.setRequestID(null);
- // API method to create or update Policy.
- PolicyChangeResponse response;
- String responseMessage = "";
- try {
- LoggingUtils.setTargetContext(POLICY, "pushPolicy");
- logger.info("Attempting to push policy...");
- response = getPolicyEngine().pushPolicy(pushPolicyParameters);
- if (response != null) {
- responseMessage = response.getResponseMessage();
- }
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Policy push error");
- logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
- throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
- }
- logger.info(LOG_POLICY_PREFIX + responseMessage);
- if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
- LoggingUtils.setResponseContext("0", "Policy push success", this.getClass().getName());
- logger.info("Policy push successful");
- metricsLogger.info("Policy push success");
- } else {
- LoggingUtils.setResponseContext("900", "Policy push failed", this.getClass().getName());
- logger.warn("Policy push failed: " + responseMessage);
- metricsLogger.info("Policy push failure");
- throw new BadRequestException("Policy push failed: " + responseMessage);
- }
- return responseMessage;
- }
-
- /**
- * Use list Decision policy to know if the decision policy exists.
- *
- * @param prop
- * The model properties
- * @return true if it exists, false otherwise
- */
- protected boolean checkDecisionPolicyExists(ModelProperties prop) {
- boolean policyexists = false;
-
- logger.info("Search in Policy Engine for DecisionpolicyName=" + prop.getPolicyScopeAndNameWithUniqueGuardId());
- try {
- // No other choice than pushing to see if it exists or not
- String response = push(DictionaryType.Decision.toString(), prop, null);
- if (response != null) {
- policyexists = true;
- }
- } catch (BadRequestException e) {
- // just print warning - if no policy version found
- logger.warn("Policy not found...policy name - " + prop.getPolicyScopeAndNameWithUniqueGuardId(), e);
- }
- return policyexists;
- }
-
- /**
- * Use list Policy API to retrieve the policy. Return true if policy exists
- * otherwise return false.
- *
- * @param prop
- * The ModelProperties
- * @param policyPrefix
- * The Policy Name Prefix
- * @param policyNameWithPrefix
- * The Policy Full Name
- * @return The response message from policy
- * @throws PolicyConfigException
- * In case of issues with policy engine
- */
- protected boolean checkPolicyExists(ModelProperties prop, String policyPrefix, String policyNameWithPrefix) {
- boolean policyexists = false;
- String policyName = "";
- try {
- policyName = selectRightPolicyNameWithPrefix(prop, policyPrefix, policyNameWithPrefix);
- logger.info("Search in Policy Engine for policyName=" + policyName);
-
- ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
- configRequestParameters.setPolicyName(policyName);
- Collection<String> response = getPolicyEngine().listConfig(configRequestParameters);
- if (response != null && !response.isEmpty() && !response.contains("Policy Name: null")) {
- policyexists = true;
- }
- } catch (PolicyConfigException e1) {
- // just print warning - if no policy version found
- logger.warn("Policy not found...policy name - " + policyName, e1);
- }
- return policyexists;
- }
-
- /**
- * This method create a new policy engine.
- *
- * @return A new policy engine
- */
- private synchronized PolicyEngine getPolicyEngine() {
- try {
- if (policyEngine == null) {
- policyEngine = new PolicyEngine(policyConfiguration.getProperties());
- }
- } catch (PolicyEngineException e) {
- throw new PolicyClientException("Exception when creating a new policy engine", e);
- }
- return policyEngine;
- }
-
- /**
- * Format and send delete Micro Service requests to Policy.
- *
- * @param prop
- * The ModelProperties
- * @return The response message from Policy
- */
- public String deleteMicrosService(ModelProperties prop) {
- return findAndDelete(prop, POLICY_MS_NAME_PREFIX_PROPERTY_NAME, POLICY_MSTYPE_PROPERTY_NAME);
- }
-
- /**
- * This method delete the Base policy.
- *
- * @param prop
- * The model Properties
- * @return A string with the answer from policy
- */
- public String deleteBasePolicy(ModelProperties prop) {
- return deletePolicy(prop, PolicyConfigType.Base.toString(), null);
- }
-
- /**
- * Format and send delete Guard requests to Policy.
- *
- * @param prop
- * The ModelProperties
- * @return The response message from policy
- */
- public String deleteGuard(ModelProperties prop) {
- String deletePolicyResponse = "";
- try {
-
- if (checkDecisionPolicyExists(prop)) {
- deletePolicyResponse = deletePolicy(prop, DictionaryType.Decision.toString(), null);
- }
- } catch (Exception e) {
- logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
- throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
- }
- return deletePolicyResponse;
- }
-
- /**
- * Format and send delete BRMS requests to Policy.
- *
- * @param prop
- * The ModelProperties
- * @return The response message from policy
- */
- public String deleteBrms(ModelProperties prop) {
- return findAndDelete(prop, POLICY_OP_NAME_PREFIX_PROPERTY_NAME, POLICY_OP_TYPE_PROPERTY_NAME);
- }
-
- private String findAndDelete(ModelProperties prop, String policyPrefixProperty, String policyTypeProperty) {
- String deletePolicyResponse = "";
- try {
- String policyNamePrefix = refProp.getStringValue(policyPrefixProperty);
- if (checkPolicyExists(prop, policyNamePrefix, null)) {
- String policyType = refProp.getStringValue(policyTypeProperty);
- deletePolicyResponse = deletePolicy(prop, policyType, null);
- }
- } catch (Exception e) {
- logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
- throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
- }
- return deletePolicyResponse;
- }
-
- protected String selectRightPolicyName(ModelProperties prop, String policyType, String policyName) {
- if (policyName == null) {
- if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
- if (DictionaryType.Decision.toString().equals(policyType)) {
- return prop.getPolicyScopeAndNameWithUniqueGuardId();
- } else {
- return prop.getPolicyScopeAndNameWithUniqueId();
- }
- } else {
- return prop.getCurrentPolicyScopeAndPolicyName();
- }
- } else {
- return policyName;
- }
- }
-
- /**
- * Method to return correct policy name with prefix.
- *
- * @param prop
- * The ModelProperties
- * @param policyPrefix
- * Policy Prefix
- * @param policyNameWithPrefix
- * Policy Name With Prefix
- * @return The policy name with the prefix
- */
- protected String selectRightPolicyNameWithPrefix(ModelProperties prop, String policyPrefix,
- String policyNameWithPrefix) {
- if (policyNameWithPrefix == null) {
- if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
- return prop.getCurrentPolicyScopeAndFullPolicyName(policyPrefix) + "_" + prop.getPolicyUniqueId();
- } else {
- return prop.getCurrentPolicyScopeAndFullPolicyName(policyPrefix);
- }
- } else {
- return policyNameWithPrefix;
- }
- }
-
- /**
- * Format and send delete PAP and PDP requests to Policy.
- *
- * @param prop
- * The ModelProperties
- * @param policyType
- * The policyType "Decision" or
- * @return The response message from policy
- */
- protected String deletePolicy(ModelProperties prop, String policyType, String policyName) {
- DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters();
- deletePolicyParameters.setPolicyName(selectRightPolicyName(prop, policyType, policyName));
- logger.info("Policy Name in delete policy method - " + deletePolicyParameters.getPolicyName());
- logger.info("Deleting policy from PDP...");
- deletePolicyParameters.setPolicyComponent("PDP");
- deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
- deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
- deletePolicyParameters.setPolicyType(policyType);
- // send delete request
- logger.info("Deleting policy from PAP...");
- StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
- deletePolicyParameters.setPolicyComponent("PAP");
- deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
- // send delete request
- responseMessage.append(sendDeletePolicy(deletePolicyParameters, prop));
- return responseMessage.toString();
- }
-
- /**
- * Send delete request to Policy.
- *
- * @param deletePolicyParameters
- * The DeletePolicyParameters
- * @param prop
- * The ModelProperties
- * @return The response message from policy
- */
- protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) {
- // Verify whether it is triggered by Validation Test button from UI
- if (prop.isTestOnly()) {
- return "delete not executed for test action";
- }
- // API method to create or update Policy.
- PolicyChangeResponse response = null;
- String responseMessage = "";
- try {
- logger.info("Attempting to delete policy...");
- response = getPolicyEngine().deletePolicy(deletePolicyParameters);
- responseMessage = response.getResponseMessage();
- } catch (Exception e) {
- logger.error("Exception occurred during policy communnication", e);
- }
- logger.info(LOG_POLICY_PREFIX + responseMessage);
- if (response != null && response.getResponseCode() == 200) {
- logger.info("Policy delete successful");
- } else {
- logger.warn("Policy delete failed: " + responseMessage);
- throw new BadRequestException("Policy delete failed: " + responseMessage);
- }
- return responseMessage;
- }
-
- /**
- * Create a temp Tosca model file and perform import model to Policy Engine.
- *
- * @param cldsToscaModel
- * Policy model details
- * @return The response message from policy
- */
- public String importToscaModel(CldsToscaModel cldsToscaModel) {
- String filePath = "";
- try {
- String clampToscaPath = refProp.getStringValue(TOSCA_FILE_TEMP_PATH);
- filePath = buildFilePathForToscaFile(clampToscaPath, cldsToscaModel.getToscaModelName());
- logger.info("Writing Tosca model : " + filePath);
- Path path = Paths.get(filePath);
- Files.createDirectories(path.getParent());
- // Create or Ovewrite an existing the file
- try (OutputStream out = Files.newOutputStream(path)) {
- out.write(cldsToscaModel.getToscaModelYaml().getBytes(), 0,
- cldsToscaModel.getToscaModelYaml().getBytes().length);
- }
- } catch (IOException e) {
- logger.error("Exception caught when attempting to write Tosca files to disk", e);
- throw new PolicyClientException("Exception caught when attempting to write Tosca files to disk", e);
- }
-
- ImportParameters importParameters = new ImportParameters();
- importParameters.setImportParameters(cldsToscaModel.getToscaModelName(), cldsToscaModel.getToscaModelName(),
- null, filePath, IMPORT_TYPE.MICROSERVICE, String.valueOf(cldsToscaModel.getVersion()));
- return importModel(importParameters);
- }
-
- /**
- * Import the model.
- * @param importParameters
- * The ImportParameters
- * @return The response message from policy
- */
- private String importModel(ImportParameters importParameters) {
- PolicyChangeResponse response = null;
- String responseMessage = "";
-
- try {
- logger.info("Attempting to import tosca policy model for action=" + importParameters.getFilePath());
- response = getPolicyEngine().policyEngineImport(importParameters);
- if (response != null) {
- responseMessage = response.getResponseMessage();
- }
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Policy Model import failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Policy Model import error");
- logger.error(POLICY_COMMUNICATION_LOG_MESSAGE, e);
- throw new PolicyClientException(POLICY_COMMUNICATION_EXC_MESSAGE, e);
- }
- logger.info(LOG_POLICY_PREFIX + responseMessage);
- if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) {
- LoggingUtils.setResponseContext("0", "Policy Model import success", this.getClass().getName());
- logger.info("Policy import model successful");
- metricsLogger.info("Policy import model success");
- } else {
- LoggingUtils.setResponseContext("900", "Policy import model failed", this.getClass().getName());
- logger.warn("Policy import model failed: " + responseMessage);
- metricsLogger.info("Policy import model failure");
- throw new BadRequestException("Policy import model failed: " + responseMessage);
- }
- return responseMessage;
- }
-
- /**
- * Build file path for tosca file.
- * @param clampToscaPath
- * Temp directory path for writing tosca files
- * @param toscaModelName
- * Tosca Model Name
- * @return File Path on the system
- */
- private String buildFilePathForToscaFile(String clampToscaPath, String toscaModelName) {
- return clampToscaPath + "/" + toscaModelName + ".yml";
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
deleted file mode 100644
index ae0de074..00000000
--- a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.tca;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import java.util.Map;
-
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.TcaRequestFormatterException;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.model.properties.TcaItem;
-import org.onap.clamp.clds.model.properties.TcaThreshold;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Construct the requests for TCA policy and SDC.
- */
-public class TcaRequestFormatter {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaRequestFormatter.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
- /**
- * Hide the default constructor.
- */
- private TcaRequestFormatter() {
- }
-
- /**
- * Format Tca Policy JSON request.
- *
- * @param refProp
- * The refProp generally created by Spring, it's an access on the
- * clds-references.properties file
- * @param modelProperties
- * The Model Prop created from BPMN JSON and BPMN properties JSON
- * @return The Json string containing that should be sent to policy
- */
- public static String createPolicyJson(ClampProperties refProp, ModelProperties modelProperties) {
- try {
- String service = modelProperties.getGlobal().getService();
- Tca tca = modelProperties.getType(Tca.class);
- modelProperties.setCurrentModelElementId(tca.getId());
- // Always one tcaItem so must be set to id 0
- modelProperties.setPolicyUniqueId("0");
- JsonObject rootNode = refProp.getJsonTemplate("tca.policy.template", service ).getAsJsonObject();
- String policyName = modelProperties.getCurrentPolicyScopeAndPolicyName();
- rootNode.addProperty("policyName", policyName);
- rootNode.get("content").getAsJsonObject().add("tca_policy",
- createPolicyContent(refProp, modelProperties, service, policyName, tca));
- String tcaPolicyReq = rootNode.toString();
- logger.info("tcaPolicyReq=" + tcaPolicyReq);
- return tcaPolicyReq;
- } catch (IOException e) {
- throw new TcaRequestFormatterException("Exception caught when attempting to create the policy JSON", e);
- }
- }
-
- /**
- * Format Tca Policy Content JSON
- *
- * @param refProp
- * The refProp generally created by Spring, it's an access on the
- * clds-references.properties file
- * @param modelProperties
- * The Model Prop created from BPMN JSON and BPMN properties JSON
- * @param service
- * The service ID, if not specified getGlobal.getService will be
- * used
- * @param policyName
- * The policyName, if not specified the
- * modelProperties.getCurrentPolicyScopeAndPolicyName will be
- * used
- * @param tca
- * The Tca object, if not specified the
- * modelProperties.setCurrentModelElementId will be used
- * @return The Json node containing what should be sent to policy
- */
- public static JsonObject createPolicyContent(ClampProperties refProp, ModelProperties modelProperties, String service,
- String policyName, Tca tca) {
- try {
- String serviceToUse = service;
- String policyNameToUse = policyName;
- Tca tcaToUse = tca;
- if (serviceToUse == null) {
- serviceToUse = modelProperties.getGlobal().getService();
- }
- if (tcaToUse == null) {
- tcaToUse = modelProperties.getType(Tca.class);
- modelProperties.setCurrentModelElementId(tcaToUse.getId());
- }
- if (policyNameToUse == null) {
- policyNameToUse = modelProperties.getCurrentPolicyScopeAndPolicyName();
- }
- JsonObject rootNode = refProp.getJsonTemplate("tca.template", serviceToUse).getAsJsonObject();
- JsonObject metricsPerEventName = rootNode.get("metricsPerEventName").getAsJsonArray().get(0).getAsJsonObject();
- metricsPerEventName.addProperty("eventName", tcaToUse.getTcaItem().getEventName());
- metricsPerEventName.addProperty("policyName", policyNameToUse);
- metricsPerEventName.addProperty("controlLoopSchemaType",tcaToUse.getTcaItem().getControlLoopSchemaType());
- addThresholds(refProp, serviceToUse, metricsPerEventName, tcaToUse.getTcaItem(), modelProperties);
- logger.info("tcaPolicyContent=" + rootNode.toString());
- return rootNode;
- } catch (IOException e) {
- throw new TcaRequestFormatterException("Exception caught when attempting to create the policy content JSON",
- e);
- }
- }
-
- /**
- * Add threshold values to the existing policy JSON.
- *
- * @param refProp
- * The refProp generally created by Spring, it's an access on the
- * clds-references.properties file
- * @param service
- * The Service value extracted from Global section of the Bpmn
- * Properties JSON
- * @param appendToNode
- * The JSON structure from where the thresholds section must be
- * added
- * @param tcaItem
- * The TCA item contained in the Tca object
- * @param modelProperties
- * The Model Properties created from BPMN JSON and BPMN
- * properties JSON
- */
- private static void addThresholds(ClampProperties refProp, String service, JsonObject appendToNode, TcaItem tcaItem,
- ModelProperties modelProperties) {
- JsonArray tcaNodes = appendToNode.get("thresholds").getAsJsonArray();
- try {
- for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
- JsonObject tcaNode = refProp.getJsonTemplate("tca.thresholds.template", service).getAsJsonObject();
- tcaNode.addProperty("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
- tcaNode.addProperty("fieldPath", tcaThreshold.getFieldPath());
- tcaNode.addProperty("thresholdValue", tcaThreshold.getThreshold());
- tcaNode.addProperty("direction", tcaThreshold.getOperator());
- tcaNode.addProperty("closedLoopEventStatus", tcaThreshold.getClosedLoopEventStatus());
- tcaNodes.add(tcaNode);
- }
- } catch (IOException e) {
- throw new TcaRequestFormatterException("Exception caught when attempting to create the thresholds JSON", e);
- }
- }
-
- /**
- * This method updates the blueprint that is received in the UI with the TCA
- * Json.
- *
- * @param refProp
- * * The refProp generally created by Spring, it's an access on
- * the clds-references.properties file
- * @param modelProperties
- * The Model Prop created from BPMN JSON and BPMN properties JSON
- * @param yamlValue
- * The yaml string received from the UI
- * @return The updated YAML as a string
- */
- public static String updatedBlueprintWithConfiguration(ClampProperties refProp, ModelProperties modelProperties,
- String yamlValue) {
- String jsonPolicy = JsonUtils.GSON.toJson(createPolicyContent(refProp, modelProperties, null, null, null));
- logger.info("Yaml that will be updated:" + yamlValue);
- Yaml yaml = new Yaml();
- Map<String, Map> loadedYaml = yaml.load(yamlValue);
- Map<String, Map> nodeTemplates = loadedYaml.get("node_templates");
- Map<String, Map> tcaObject = nodeTemplates.get("tca_tca");
- Map<String, Map> propsObject = tcaObject.get("properties");
- Map<String, String> appPreferences = propsObject.get("app_preferences");
- appPreferences.put("tca_policy", jsonPolicy);
- String blueprint = yaml.dump(loadedYaml);
- logger.info("Yaml updated:" + blueprint);
- return blueprint;
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
index 1fdc898a..cb608941 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
@@ -24,11 +24,9 @@
package org.onap.clamp.clds.config.spring;
import javax.sql.DataSource;
-import javax.xml.transform.TransformerConfigurationException;
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.EncodedPasswordBasicDataSource;
-import org.onap.clamp.clds.transform.XslTransformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -63,11 +61,4 @@ public class CldsConfiguration {
bean.setLocation(appContext.getResource(refProp.getStringValue("files.systemProperties")));
return bean;
}
-
- @Bean(name = "cldsBpmnTransformer")
- public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
- XslTransformer xslTransformer = new XslTransformer();
- xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
- return xslTransformer;
- }
} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
deleted file mode 100644
index 91ddfc48..00000000
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ /dev/null
@@ -1,715 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.dao;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.onap.clamp.clds.model.CldsDictionary;
-import org.onap.clamp.clds.model.CldsDictionaryItem;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.CldsModelInstance;
-import org.onap.clamp.clds.model.CldsModelProp;
-import org.onap.clamp.clds.model.CldsTemplate;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.ValueItem;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.SqlParameterSource;
-import org.springframework.jdbc.core.simple.SimpleJdbcCall;
-import org.springframework.stereotype.Repository;
-
-/**
- * Data Access for CLDS Model tables.
- */
-@Repository("cldsDao")
-public class CldsDao {
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
- private JdbcTemplate jdbcTemplateObject;
- private SimpleJdbcCall procGetModel;
- private SimpleJdbcCall procGetModelTemplate;
- private SimpleJdbcCall procSetModel;
- private SimpleJdbcCall procInsEvent;
- private SimpleJdbcCall procUpdEvent;
- private SimpleJdbcCall procSetTemplate;
- private SimpleJdbcCall procGetTemplate;
- private SimpleJdbcCall procDelAllModelInstances;
- private SimpleJdbcCall procInsModelInstance;
- private SimpleJdbcCall procDeleteModel;
- private static final String HEALTHCHECK = "Select 1";
- private static final String V_CONTROL_NAME_PREFIX = "v_control_name_prefix";
- private static final String V_CONTROL_NAME_UUID = "v_control_name_uuid";
-
- private SimpleJdbcCall procInsertToscaModel;
- private SimpleJdbcCall procInsertNewToscaModelVersion;
- private SimpleJdbcCall procInsertDictionary;
- private SimpleJdbcCall procInsertDictionaryElement;
-
- private static final String DATE_FORMAT = "MM-dd-yyyy HH:mm:ss";
-
- /**
- * Log message when instantiating.
- */
- @Autowired
- public CldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
- logger.info("CldsDao instantiating...");
- setDataSource(dataSource);
- }
-
- /**
- * When dataSource is provided, instantiate spring jdbc objects.
- *
- * @param dataSource the data source
- */
- public void setDataSource(DataSource dataSource) {
- this.jdbcTemplateObject = new JdbcTemplate(dataSource);
- this.procGetModel = new SimpleJdbcCall(dataSource).withProcedureName("get_model");
- this.procGetModelTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_model_template");
- this.procSetModel = new SimpleJdbcCall(dataSource).withProcedureName("set_model");
- this.procInsEvent = new SimpleJdbcCall(dataSource).withProcedureName("ins_event");
- this.procUpdEvent = new SimpleJdbcCall(dataSource).withProcedureName("upd_event");
- this.procGetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_template");
- this.procSetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("set_template");
- this.procInsModelInstance = new SimpleJdbcCall(dataSource).withProcedureName("ins_model_instance");
- this.procDelAllModelInstances = new SimpleJdbcCall(dataSource).withProcedureName("del_all_model_instances");
- this.procDeleteModel = new SimpleJdbcCall(dataSource).withProcedureName("del_model");
- this.procInsertToscaModel = new SimpleJdbcCall(dataSource).withProcedureName("set_tosca_model");
- this.procInsertNewToscaModelVersion = new SimpleJdbcCall(dataSource)
- .withProcedureName("set_new_tosca_model_version");
- this.procInsertDictionary = new SimpleJdbcCall(dataSource).withProcedureName("set_dictionary");
- this.procInsertDictionaryElement = new SimpleJdbcCall(dataSource).withProcedureName("set_dictionary_elements");
- }
-
- /**
- * Get a model from the database given the model name.
- *
- * @param modelName the model name
- * @return the model
- */
- public CldsModel getModel(String modelName) {
- return getModel(modelName, null);
- }
-
- // Get a model from the database given the model name or a controlNameUuid.
- private CldsModel getModel(String modelName, String controlNameUuid) {
- CldsModel model = new CldsModel();
- model.setName(modelName);
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
- .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
- Map<String, Object> out = logSqlExecution(procGetModel, in);
- populateModelProperties(model, out);
- return model;
- }
-
- /**
- * Get a model from the database given the controlNameUuid.
- *
- * @param controlNameUuid the control name uuid
- * @return the model by uuid
- */
- public CldsModel getModelByUuid(String controlNameUuid) {
- return getModel(null, controlNameUuid);
- }
-
- /**
- * Get a model and template information from the database given the model name.
- *
- * @param modelName the model name
- * @return model model template
- */
-
- public CldsModel getModelTemplate(String modelName) {
- CldsModel model = new CldsModel();
- model.setName(modelName);
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
- Map<String, Object> out = logSqlExecution(procGetModelTemplate, in);
- populateModelProperties(model, out);
- Map<String, Object> modelResults = logSqlExecution(procGetModel, in);
- Object modelResultObject = modelResults.get("#result-set-1");
- if (modelResultObject instanceof ArrayList) {
- for (Object currModelInstance : (List<Object>) modelResultObject) {
- if (currModelInstance instanceof HashMap) {
- HashMap<String, String> modelInstanceMap = (HashMap<String, String>) currModelInstance;
- CldsModelInstance modelInstance = new CldsModelInstance();
- modelInstance.setModelInstanceId(modelInstanceMap.get("model_instance_id"));
- modelInstance.setVmName(modelInstanceMap.get("vm_name"));
- modelInstance.setLocation(modelInstanceMap.get("location"));
- model.getCldsModelInstanceList().add(modelInstance);
- logger.info("value of currModel: {}", currModelInstance);
- }
- }
- }
- return model;
- }
-
- /**
- * Update model in the database using parameter values and return updated model
- * object.
- *
- * @param model the model
- * @param userid the userid
- * @return model
- */
- public CldsModel setModel(CldsModel model, String userid) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", model.getName())
- .addValue("v_template_id", model.getTemplateId()).addValue("v_user_id", userid)
- .addValue("v_model_prop_text", model.getPropText())
- .addValue("v_model_blueprint_text", model.getBlueprintText())
- .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId())
- .addValue("v_deployment_status_url", model.getDeploymentStatusUrl())
- .addValue(V_CONTROL_NAME_PREFIX, model.getControlNamePrefix())
- .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid());
- Map<String, Object> out = logSqlExecution(procSetModel, in);
- model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
- model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
- model.setId((String) (out.get("v_model_id")));
- setEventProp(model.getEvent(), out);
- return model;
- }
-
- /**
- * Inserts new modelInstance in the database using parameter values and return
- * updated model object.
- *
- * @param model the model
- * @param modelInstancesList the model instances list
- */
- public void insModelInstance(CldsModel model, List<CldsModelInstance> modelInstancesList) {
- // Delete all existing model instances for given controlNameUUID
- logger.debug("deleting instances for: {}", model.getControlNameUuid());
- delAllModelInstances(model.getControlNameUuid());
- if (modelInstancesList == null) {
- logger.debug("modelInstancesList == null");
- } else {
- for (CldsModelInstance currModelInstance : modelInstancesList) {
- logger.debug("v_control_name_uuid={}", model.getControlNameUuid());
- logger.debug("v_vm_name={}", currModelInstance.getVmName());
- logger.debug("v_location={}", currModelInstance.getLocation());
- SqlParameterSource in = new MapSqlParameterSource()
- .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid())
- .addValue("v_vm_name", currModelInstance.getVmName())
- .addValue("v_location", currModelInstance.getLocation());
- Map<String, Object> out = logSqlExecution(procInsModelInstance, in);
- model.setId((String) (out.get("v_model_id")));
- CldsModelInstance modelInstance = new CldsModelInstance();
- modelInstance.setLocation(currModelInstance.getLocation());
- modelInstance.setVmName(currModelInstance.getVmName());
- modelInstance.setModelInstanceId((String) (out.get("v_model_instance_id")));
- model.getCldsModelInstanceList().add(modelInstance);
- }
- }
- }
-
- /**
- * Insert an event in the database - require either modelName or
- * controlNamePrefix/controlNameUuid.
- *
- * @param modelName the model name
- * @param controlNamePrefix the control name prefix
- * @param controlNameUuid the control name uuid
- * @param cldsEvent the clds event
- * @return clds event
- */
- public CldsEvent insEvent(String modelName, String controlNamePrefix, String controlNameUuid, CldsEvent cldsEvent) {
- CldsEvent event = new CldsEvent();
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
- .addValue(V_CONTROL_NAME_PREFIX, controlNamePrefix).addValue(V_CONTROL_NAME_UUID, controlNameUuid)
- .addValue("v_user_id", cldsEvent.getUserid()).addValue("v_action_cd", cldsEvent.getActionCd())
- .addValue("v_action_state_cd", cldsEvent.getActionStateCd())
- .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId());
- Map<String, Object> out = logSqlExecution(procInsEvent, in);
- event.setId((String) (out.get("v_event_id")));
- return event;
- }
-
- private String delAllModelInstances(String controlNameUUid) {
- SqlParameterSource in = new MapSqlParameterSource().addValue(V_CONTROL_NAME_UUID, controlNameUUid);
- Map<String, Object> out = logSqlExecution(procDelAllModelInstances, in);
- return (String) (out.get("v_model_id"));
- }
-
- /**
- * Update event with process instance id.
- *
- * @param eventId the event id
- * @param processInstanceId the process instance id
- */
- public void updEvent(String eventId, String processInstanceId) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId)
- .addValue("v_process_instance_id", processInstanceId);
- logSqlExecution(procUpdEvent, in);
- }
-
- /**
- * Return list of model names.
- *
- * @return model names
- */
- public List<ValueItem> getModelNames() {
- String sql = "SELECT model_name FROM model ORDER BY 1;";
- return jdbcTemplateObject.query(sql, new ValueItemMapper());
- }
-
- /**
- * Update template in the database using parameter values and return updated
- * template object.
- *
- * @param template the template
- * @param userid the userid
- */
- public void setTemplate(CldsTemplate template, String userid) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", template.getName())
- .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText())
- .addValue("v_template_image_text", template.getImageText())
- .addValue("v_template_doc_text", template.getPropText());
-
- // properties to setup the template is return from the logSqlExecution method
- setTemplateBaseProp(template, logSqlExecution(procSetTemplate, in));
- }
-
- /**
- * Return list of template names.
- *
- * @return template names
- */
- public List<ValueItem> getTemplateNames() {
- String sql = "SELECT template_name FROM template ORDER BY 1;";
- return jdbcTemplateObject.query(sql, new ValueItemMapper());
- }
-
- /**
- * Get a template from the database given the model name.
- *
- * @param templateName the template name
- * @return model template
- */
- public CldsTemplate getTemplate(String templateName) {
- CldsTemplate template = new CldsTemplate();
- template.setName(templateName);
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName);
-
- Map<String, Object> out = logSqlExecution(procGetTemplate, in);
- setTemplateBaseProp(template, out);
-
- // additional template setting's
- template.setPropText((String) out.get("v_template_doc_text"));
- template.setBpmnText((String) out.get("v_template_bpmn_text"));
- template.setImageText((String) out.get("v_template_image_text"));
- return template;
- }
-
- /**
- * Helper method to setup the base template properties.
- *
- * @param template the template
- * @param prop collection with the properties
- */
- private void setTemplateBaseProp(CldsTemplate template, Map prop) {
- template.setId((String) prop.get("v_template_id"));
- template.setBpmnUserid((String) prop.get("v_template_bpmn_user_id"));
- template.setBpmnId((String) prop.get("v_template_bpmn_id"));
- template.setImageId((String) prop.get("v_template_image_id"));
- template.setImageUserid((String) prop.get("v_template_image_user_id"));
- template.setPropId((String) prop.get("v_template_doc_id"));
- template.setPropUserid((String) prop.get("v_template_doc_user_id"));
- }
-
- private static Map<String, Object> logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) {
- try {
- return call.execute(source);
- } catch (Exception e) {
- logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e);
- throw e;
- }
- }
-
- /**
- * Do health check.
- */
- public void doHealthCheck() {
- jdbcTemplateObject.execute(HEALTHCHECK);
- }
-
- /**
- * Method to get deployed/active models with model properties.
- *
- * @return list of CldsModelProp
- */
- public List<CldsModelProp> getDeployedModelProperties() {
- List<CldsModelProp> cldsModelPropList = new ArrayList<>();
- String modelsSql = "select m.model_id, m.model_name, mp.model_prop_id, mp.model_prop_text FROM model m, "
- + "model_properties mp, event e "
- + "WHERE m.model_prop_id = mp.model_prop_id and m.event_id = e.event_id and e.action_cd = 'DEPLOY'";
- List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
- CldsModelProp cldsModelProp = null;
- for (Map<String, Object> row : rows) {
- cldsModelProp = new CldsModelProp();
- cldsModelProp.setId((String) row.get("model_id"));
- cldsModelProp.setName((String) row.get("model_name"));
- cldsModelProp.setPropId((String) row.get("model_prop_id"));
- cldsModelProp.setPropText((String) row.get("model_prop_text"));
- cldsModelPropList.add(cldsModelProp);
- }
- return cldsModelPropList;
- }
-
- /**
- * Method to delete model from database.
- *
- * @param modelName the model name
- */
- public void deleteModel(String modelName) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
- logSqlExecution(procDeleteModel, in);
- }
-
- private void populateModelProperties(CldsModel model, Map out) {
- model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
- model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
- model.setId((String) out.get("v_model_id"));
- model.setTemplateId((String) out.get("v_template_id"));
- model.setTemplateName((String) (out.get("v_template_name")));
- model.setBpmnText((String) out.get("v_template_bpmn_text"));
- model.setPropText((String) out.get("v_model_prop_text"));
- model.setImageText((String) out.get("v_template_image_text"));
- model.setDocText((String) out.get("v_template_doc_text"));
- model.setBlueprintText((String) out.get("v_model_blueprint_text"));
- model.setTypeId((String) out.get("v_service_type_id"));
- model.setDeploymentId((String) out.get("v_deployment_id"));
- model.setDeploymentStatusUrl((String) out.get("v_deployment_status_url"));
-
- setEventProp(model.getEvent(), out);
- }
-
- /**
- * Helper method to setup the event prop to the CldsEvent class.
- *
- * @param event the clds event
- * @param prop collection with the configuration
- */
- private void setEventProp(CldsEvent event, Map prop) {
- event.setId((String) prop.get("v_event_id"));
- event.setActionCd((String) prop.get("v_action_cd"));
- event.setActionStateCd((String) prop.get("v_action_state_cd"));
- event.setProcessInstanceId((String) prop.get("v_event_process_instance_id"));
- event.setUserid((String) prop.get("v_event_user_id"));
- }
-
- /**
- * Method to retrieve a tosca models by Policy Type from database.
- *
- * @return List of CldsToscaModel
- */
- public List<CldsToscaModel> getAllToscaModels() {
- return getToscaModel(null, null);
- }
-
- /**
- * Method to retrieve a tosca models by Policy Type from database.
- *
- * @param policyType the policy type
- * @return List of CldsToscaModel
- */
- public List<CldsToscaModel> getToscaModelByPolicyType(String policyType) {
- return getToscaModel(null, policyType);
- }
-
- /**
- * Method to retrieve a tosca models by toscaModelName, version from database.
- *
- * @param toscaModelName the tosca model name
- * @return List of CldsToscaModel
- */
- public List<CldsToscaModel> getToscaModelByName(String toscaModelName) {
- return getToscaModel(toscaModelName, null);
- }
-
- // Retrieve the latest tosca model for a policy type or by tosca model name
-
- private List<CldsToscaModel> getToscaModel(String toscaModelName, String policyType) {
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
- List<CldsToscaModel> cldsToscaModels = new ArrayList<>();
-
- String toscaModelSql = new StringBuilder("SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, "
- + "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp,"
- + "tmr.lastUpdatedTimestamp").append(toscaModelName != null ? (", tmr.tosca_model_yaml") : "").append(
- " FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id")
- .append(toscaModelName != null ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : "")
- .append(policyType != null ? (" AND tm.policy_type = '" + policyType + "'") : "")
- .append(" AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id"
- + "=st.tosca_model_id)")
- .toString();
-
- List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
-
- if (rows != null) {
- rows.forEach(row -> {
- CldsToscaModel cldsToscaModel = new CldsToscaModel();
- cldsToscaModel.setId((String) row.get("tosca_model_id"));
- cldsToscaModel.setPolicyType((String) row.get("policy_type"));
- cldsToscaModel.setToscaModelName((String) row.get("tosca_model_name"));
- cldsToscaModel.setUserId((String) row.get("user_id"));
- cldsToscaModel.setRevisionId((String) row.get("tosca_model_revision_id"));
- cldsToscaModel.setToscaModelJson((String) row.get("tosca_model_json"));
- cldsToscaModel.setVersion(((Double) row.get("version")));
- cldsToscaModel.setCreatedDate(sdf.format(row.get("createdTimestamp")));
- cldsToscaModel.setLastUpdatedDate(sdf.format(row.get("lastUpdatedTimestamp")));
- if (toscaModelName != null) {
- cldsToscaModel.setToscaModelYaml((String) row.get("tosca_model_yaml"));
- }
- cldsToscaModels.add(cldsToscaModel);
- });
- }
- return cldsToscaModels;
- }
-
- /**
- * Method to upload a new version of Tosca Model Yaml in Database.
- *
- * @param cldsToscaModel the clds tosca model
- * @param userId the user id
- * @return CldsToscaModel clds tosca model
- */
- public CldsToscaModel updateToscaModelWithNewVersion(CldsToscaModel cldsToscaModel, String userId) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_tosca_model_id", cldsToscaModel.getId())
- .addValue("v_version", cldsToscaModel.getVersion())
- .addValue("v_tosca_model_yaml", cldsToscaModel.getToscaModelYaml())
- .addValue("v_tosca_model_json", cldsToscaModel.getToscaModelJson()).addValue("v_user_id", userId);
- Map<String, Object> out = logSqlExecution(procInsertNewToscaModelVersion, in);
- cldsToscaModel.setRevisionId((String) out.get("v_revision_id"));
- return cldsToscaModel;
- }
-
- /**
- * Method to upload a new Tosca model Yaml in DB. Default version is 1.0
- *
- * @param cldsToscaModel the clds tosca model
- * @param userId the user id
- * @return CldsToscaModel clds tosca model
- */
- public CldsToscaModel insToscaModel(CldsToscaModel cldsToscaModel, String userId) {
- SqlParameterSource in = new MapSqlParameterSource()
- .addValue("v_tosca_model_name", cldsToscaModel.getToscaModelName())
- .addValue("v_policy_type", cldsToscaModel.getPolicyType())
- .addValue("v_tosca_model_yaml", cldsToscaModel.getToscaModelYaml())
- .addValue("v_tosca_model_json", cldsToscaModel.getToscaModelJson())
- .addValue("v_version", cldsToscaModel.getVersion()).addValue("v_user_id", userId);
- Map<String, Object> out = logSqlExecution(procInsertToscaModel, in);
- cldsToscaModel.setId((String) (out.get("v_tosca_model_id")));
- cldsToscaModel.setRevisionId((String) (out.get("v_revision_id")));
- cldsToscaModel.setUserId((String) out.get("v_user_id"));
- return cldsToscaModel;
- }
-
- /**
- * Method to insert a new Dictionary in Database.
- *
- * @param cldsDictionary the clds dictionary
- */
- public void insDictionary(CldsDictionary cldsDictionary) {
- SqlParameterSource in = new MapSqlParameterSource()
- .addValue("v_dictionary_name", cldsDictionary.getDictionaryName())
- .addValue("v_user_id", cldsDictionary.getCreatedBy());
- Map<String, Object> out = logSqlExecution(procInsertDictionary, in);
- cldsDictionary.setDictionaryId((String) out.get("v_dictionary_id"));
- }
-
- /**
- * Method to update Dictionary with new info in Database.
- *
- * @param dictionaryId the dictionary id
- * @param cldsDictionary the clds dictionary
- * @param userId the user id
- */
- public void updateDictionary(String dictionaryId, CldsDictionary cldsDictionary, String userId) {
-
- String dictionarySql = new StringBuilder("UPDATE dictionary SET dictionary_name = '")
- .append(cldsDictionary.getDictionaryName()).append("', modified_by = '").append(userId)
- .append("'WHERE dictionary_id = '").append(dictionaryId).append("'").toString();
- jdbcTemplateObject.update(dictionarySql);
- cldsDictionary.setUpdatedBy(userId);
- }
-
- /**
- * Method to get list of Dictionaries from the Database.
- *
- * @param dictionaryId the dictionary id
- * @param dictionaryName the dictionary name
- * @return dictionary
- */
- public List<CldsDictionary> getDictionary(String dictionaryId, String dictionaryName) {
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
- List<CldsDictionary> dictionaries = new ArrayList<>();
-
- String whereFilter = " WHERE ";
- if (dictionaryName != null) {
- whereFilter += "dictionary_name = '" + dictionaryName + "'";
- if (dictionaryId != null) {
- whereFilter += " AND dictionary_id = '" + dictionaryId + "'";
- }
- } else if (dictionaryId != null) {
- whereFilter += "dictionary_id = '" + dictionaryId + "'";
- } else {
- whereFilter = "";
- }
- String dictionarySql = new StringBuilder(
- "SELECT dictionary_id, dictionary_name, created_by, " + "modified_by, timestamp FROM dictionary")
- .append(whereFilter).toString();
-
- List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
- if (rows != null) {
- rows.forEach(row -> {
- CldsDictionary cldsDictionary = new CldsDictionary();
- cldsDictionary.setDictionaryId((String) row.get("dictionary_id"));
- cldsDictionary.setDictionaryName((String) row.get("dictionary_name"));
- cldsDictionary.setCreatedBy((String) row.get("created_by"));
- cldsDictionary.setUpdatedBy((String) row.get("modified_by"));
- cldsDictionary.setLastUpdatedDate(sdf.format(row.get("timestamp")));
- dictionaries.add(cldsDictionary);
- });
- }
- return dictionaries;
- }
-
- /**
- * Method to insert a new Dictionary Element for given dictionary in Database.
- *
- * @param cldsDictionaryItem the clds dictionary item
- * @param userId the user id
- */
- public void insDictionarElements(CldsDictionaryItem cldsDictionaryItem, String userId) {
- SqlParameterSource in = new MapSqlParameterSource()
- .addValue("v_dictionary_id", cldsDictionaryItem.getDictionaryId())
- .addValue("v_dict_element_name", cldsDictionaryItem.getDictElementName())
- .addValue("v_dict_element_short_name", cldsDictionaryItem.getDictElementShortName())
- .addValue("v_dict_element_description", cldsDictionaryItem.getDictElementDesc())
- .addValue("v_dict_element_type", cldsDictionaryItem.getDictElementType()).addValue("v_user_id", userId);
- Map<String, Object> out = logSqlExecution(procInsertDictionaryElement, in);
- cldsDictionaryItem.setDictElementId((String) out.get("v_dict_element_id"));
- }
-
- /**
- * Method to update Dictionary Elements with new info for a given dictionary in
- * Database.
- *
- * @param dictionaryElementId the dictionary element id
- * @param cldsDictionaryItem the clds dictionary item
- * @param userId the user id
- */
- public void updateDictionaryElements(String dictionaryElementId, CldsDictionaryItem cldsDictionaryItem,
- String userId) {
-
- String dictionarySql = new StringBuilder().append("UPDATE dictionary_elements SET dict_element_name = '")
- .append(cldsDictionaryItem.getDictElementName()).append("', dict_element_short_name = '")
- .append(cldsDictionaryItem.getDictElementShortName()).append("', dict_element_description= '")
- .append(cldsDictionaryItem.getDictElementDesc()).append("', dict_element_type = '")
- .append(cldsDictionaryItem.getDictElementType()).append("', modified_by = '").append(userId).append("'")
- .append(" WHERE dict_element_id = '").append(dictionaryElementId).append("'").toString();
- jdbcTemplateObject.update(dictionarySql);
- cldsDictionaryItem.setUpdatedBy(userId);
- }
-
- /**
- * Method to get list of all dictionary elements for a given dictionary in the
- * Database.
- *
- * @param dictionaryName the dictionary name
- * @param dictionaryId the dictionary id
- * @param dictElementShortName the dict element short name
- * @return dictionary elements
- */
- public List<CldsDictionaryItem> getDictionaryElements(String dictionaryName, String dictionaryId,
- String dictElementShortName) {
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
- List<CldsDictionaryItem> dictionaryItems = new ArrayList<>();
- String dictionarySql = new StringBuilder("SELECT de.dict_element_id, de.dictionary_id, de.dict_element_name, "
- + "de.dict_element_short_name, de.dict_element_description, de.dict_element_type, de.created_by, "
- + "de.modified_by, de.timestamp FROM dictionary_elements de, "
- + "dictionary d WHERE de.dictionary_id = d.dictionary_id")
- .append((dictionaryId != null) ? (" AND d.dictionary_id = '" + dictionaryId + "'") : "")
- .append((dictElementShortName != null)
- ? (" AND de.dict_element_short_name = '" + dictElementShortName + "'")
- : "")
- .append((dictionaryName != null) ? (" AND dictionary_name = '" + dictionaryName + "'") : "")
- .toString();
-
- List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
- if (rows != null) {
- rows.forEach(row -> {
- CldsDictionaryItem dictionaryItem = new CldsDictionaryItem();
- dictionaryItem.setDictElementId((String) row.get("dict_element_id"));
- dictionaryItem.setDictionaryId((String) row.get("dictionary_id"));
- dictionaryItem.setDictElementName((String) row.get("dict_element_name"));
- dictionaryItem.setDictElementShortName((String) row.get("dict_element_short_name"));
- dictionaryItem.setDictElementDesc((String) row.get("dict_element_description"));
- dictionaryItem.setDictElementType((String) row.get("dict_element_type"));
- dictionaryItem.setCreatedBy((String) row.get("created_by"));
- dictionaryItem.setUpdatedBy((String) row.get("modified_by"));
- dictionaryItem.setLastUpdatedDate(sdf.format(row.get("timestamp")));
- dictionaryItems.add(dictionaryItem);
- });
- }
- return dictionaryItems;
- }
-
- /**
- * Method to get Map of all dictionary elements with key as dictionary short
- * name and value as the full name.
- *
- * @param dictionaryElementType the dictionary element type
- * @return Map of dictionary elements as key value pair
- */
- public Map<String, String> getDictionaryElementsByType(String dictionaryElementType) {
- Map<String, String> dictionaryItems = new HashMap<>();
- String dictionarySql = new StringBuilder("SELECT dict_element_name, dict_element_short_name "
- + "FROM dictionary_elements WHERE dict_element_type = '").append(dictionaryElementType).append("'")
- .toString();
-
- List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
-
- if (rows != null) {
- rows.forEach(row -> {
- dictionaryItems.put(((String) row.get("dict_element_short_name")),
- ((String) row.get("dict_element_name")));
- });
- }
- return dictionaryItems;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java b/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java
deleted file mode 100644
index 599bef7e..00000000
--- a/src/main/java/org/onap/clamp/clds/dao/ValueItemMapper.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.onap.clamp.clds.model.ValueItem;
-import org.springframework.jdbc.core.RowMapper;
-
-/**
- * Generic mapper for list of values.
- */
-public final class ValueItemMapper implements RowMapper<ValueItem> {
- @Override
- public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException {
- ValueItem item = new ValueItem();
- item.setValue(rs.getString(1));
- return item;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java
deleted file mode 100644
index 114d7858..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-
-public class CldsAlarmCondition implements Serializable {
-
- private static final long serialVersionUID = 4271364536747705555L;
- private String eventSourceType;
- private String alarmConditionKey;
- private String severity;
- private String eventName;
-
- public String getEventSourceType() {
- return eventSourceType;
- }
-
- public void setEventSourceType(String eventSourceType) {
- this.eventSourceType = eventSourceType;
- }
-
- public String getSeverity() {
- return severity;
- }
-
- public void setSeverity(String severity) {
- this.severity = severity;
- }
-
- public String getAlarmConditionKey() {
- return alarmConditionKey;
- }
-
- public void setAlarmConditionKey(String alarmConditionKey) {
- this.alarmConditionKey = alarmConditionKey;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public void setEventName(String eventName) {
- this.eventName = eventName;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java
deleted file mode 100644
index 140d6e8c..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsDbServiceCache.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-
-public class CldsDbServiceCache {
-
- private String invariantId;
- private String serviceId;
- private InputStream cldsDataInstream;
-
- /**
- * Constructor.
- * @param cldsServiceData The cles service data
- * @throws IOException IO Exception
- */
- public CldsDbServiceCache(CldsServiceData cldsServiceData) throws IOException {
- setCldsDataInstream(cldsServiceData);
- setInvariantId(cldsServiceData.getServiceInvariantUUID());
- setServiceId(cldsServiceData.getServiceUUID());
- }
-
- public String getInvariantId() {
- return invariantId;
- }
-
- public void setInvariantId(String invariantId) {
- this.invariantId = invariantId;
- }
-
- public String getServiceId() {
- return serviceId;
- }
-
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
-
- public InputStream getCldsDataInstream() {
- return cldsDataInstream;
- }
-
- public void setCldsDataInstream(InputStream cldsDataInputstream) {
- this.cldsDataInstream = cldsDataInputstream;
- }
-
- public void setCldsDataInstream(CldsServiceData cldsServiceData) throws IOException {
- this.cldsDataInstream = getInstreamFromObject(cldsServiceData);
- }
-
- private InputStream getInstreamFromObject(CldsServiceData cldsServiceData) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(cldsServiceData);
- oos.flush();
- oos.close();
- return new ByteArrayInputStream(baos.toByteArray());
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
index 27a430c7..35fbcec4 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
@@ -23,13 +23,11 @@
package org.onap.clamp.clds.model;
+import com.google.gson.annotations.Expose;
+
import java.util.ArrayList;
import java.util.List;
-import org.onap.clamp.clds.dao.CldsDao;
-
-import com.google.gson.annotations.Expose;
-
/**
* Represents a CLDS Dictionary.
*/
@@ -51,33 +49,6 @@ public class CldsDictionary {
private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
/**
- * Creates or updates dictionary item for a dictionary in DB.
- *
- * @param dictionaryName The dictionary name
- * @param cldsDao The CldsDao
- * @param userId The user ID
- */
- public void save(String dictionaryName, CldsDao cldsDao, String userId) {
- List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
- if (list != null && !list.isEmpty()) {
- CldsDictionary cldsDictionary = list.stream().findFirst().get();
- if (!cldsDictionary.getDictionaryName().equalsIgnoreCase(this.getDictionaryName())) {
- cldsDao.updateDictionary(cldsDictionary.getDictionaryId(), this, userId);
- this.setCreatedBy(cldsDictionary.getCreatedBy());
- } else {
- this.setDictionaryId(cldsDictionary.getDictionaryId());
- this.setCreatedBy(cldsDictionary.getCreatedBy());
- this.setUpdatedBy(cldsDictionary.getUpdatedBy());
- this.setLastUpdatedDate(cldsDictionary.getLastUpdatedDate());
- }
- } else {
- this.setCreatedBy(userId);
- this.setUpdatedBy(userId);
- cldsDao.insDictionary(this);
- }
- }
-
- /**
* Get the dictionary ID.
*
* @return the dictionaryId
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
index 14a68502..1b79bdfa 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
@@ -25,10 +25,6 @@ package org.onap.clamp.clds.model;
import com.google.gson.annotations.Expose;
-import java.util.List;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
/**
* Represents a CLDS Dictionary Item.
*/
@@ -54,34 +50,6 @@ public class CldsDictionaryItem {
private String lastUpdatedDate;
/**
- * Save the dictionary item.
- *
- * @param dictionaryName The name of the dictionary
- * @param cldsDao The cldsDao
- * @param userId The user id
- */
- public void save(String dictionaryName, CldsDao cldsDao, String userId) {
- // Check if dictionary exists.
- List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
- if (list != null && !list.isEmpty()) {
- // Dictionary found. We can add or update the dictionary element
- CldsDictionary cldsDictionary = list.stream().findFirst().get();
- List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName,
- cldsDictionary.getDictionaryId(), this.getDictElementShortName());
- if (dictionaryItems != null && !dictionaryItems.isEmpty()) {
- CldsDictionaryItem item = dictionaryItems.stream().findFirst().get();
- cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId);
- this.setCreatedBy(item.getCreatedBy());
-
- } else {
- this.setCreatedBy(userId);
- this.setUpdatedBy(userId);
- cldsDao.insDictionarElements(this, userId);
- }
- }
- }
-
- /**
* Get the dictionary element id.
*
* @return the dictElementId
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
deleted file mode 100644
index cc57f9e7..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
-/**
- * Represent a CLDS Event.
- */
-public class CldsEvent {
- /**
- * The constant ACTION_TEST.
- */
- public static final String ACTION_TEST = "TEST";
- /**
- * The constant ACTION_CREATE.
- */
- public static final String ACTION_CREATE = "CREATE";
- /**
- * The constant ACTION_MODIFY.
- */
- public static final String ACTION_MODIFY = "MODIFY";
- /**
- * The constant ACTION_SUBMIT.
- */
- public static final String ACTION_SUBMIT = "SUBMIT";
- /**
- * The constant ACTION_RESUBMIT.
- */
- // an update before model is active
- public static final String ACTION_RESUBMIT = "RESUBMIT";
- /**
- * The constant ACTION_SUBMITDCAE.
- */
- // For simplified models
- public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
- /**
- * The constant ACTION_SUBMITPOLICY.
- */
- public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
- /**
- * The constant ACTION_DISTRIBUTE.
- */
- // only from dcae
- public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
- /**
- * The constant ACTION_DEPLOY.
- */
- // only from dcae
- public static final String ACTION_DEPLOY = "DEPLOY";
- /**
- * The constant ACTION_UNDEPLOY.
- */
- // only from dcae
- public static final String ACTION_UNDEPLOY = "UNDEPLOY";
- /**
- * The constant ACTION_UPDATE.
- */
- public static final String ACTION_UPDATE = "UPDATE";
- /**
- * The constant ACTION_DELETE.
- */
- public static final String ACTION_DELETE = "DELETE";
- /**
- * The constant ACTION_STOP.
- */
- public static final String ACTION_STOP = "STOP";
- /**
- * The constant ACTION_RESTART.
- */
- public static final String ACTION_RESTART = "RESTART";
-
- /**
- * The constant ACTION_STATE_INITIATED.
- */
- public static final String ACTION_STATE_INITIATED = "INITIATED";
- /**
- * The constant ACTION_STATE_SENT.
- */
- public static final String ACTION_STATE_SENT = "SENT";
- /**
- * The constant ACTION_STATE_COMPLETED.
- */
- public static final String ACTION_STATE_COMPLETED = "COMPLETED";
- /**
- * The constant ACTION_STATE_RECEIVED.
- */
- public static final String ACTION_STATE_RECEIVED = "RECEIVED";
- /**
- * The constant ACTION_STATE_ERROR.
- */
- public static final String ACTION_STATE_ERROR = "ERROR";
- /**
- * The constant ACTION_STATE_ANY.
- */
- public static final String ACTION_STATE_ANY = null;
-
- private String id;
- private String actionCd;
- private String actionStateCd;
- private String processInstanceId;
- private String userid;
-
- /**
- * Gets id.
- *
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Sets id.
- *
- * @param id the id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Ins event clds event.
- *
- * @param cldsDao the clds dao
- * @param controlName the control name
- * @param userid the userid
- * @param actionCd the action cd
- * @param actionStateCd the action state cd
- * @param processInstanceId the process instance id
- * @return clds event
- */
- public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd,
- String actionStateCd, String processInstanceId) {
- CldsModel model = CldsModel.createUsingControlName(controlName);
- return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId);
- }
-
- /**
- * Insert event using controlNameUuid to find the model. This method meant for
- * processing events from dcae.
- *
- * @param cldsDao the clds dao
- * @param model the model
- * @param userId the user id
- * @param actionCd the action cd
- * @param actionStateCd the action state cd
- * @param processInstanceId the process instance id
- * @return clds event
- */
- public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd,
- String actionStateCd, String processInstanceId) {
- CldsEvent event = new CldsEvent();
- event.setUserid(userId);
- event.setActionCd(actionCd);
- event.setActionStateCd(actionStateCd);
- event.setProcessInstanceId(processInstanceId);
- cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event);
- return event;
- }
-
- /**
- * Check if actionCd is equal to the supplied checkActionCd checkActionCd should
- * not be null.
- *
- * @param checkActionCd the check action cd
- * @return boolean
- */
- public boolean isActionCd(String checkActionCd) {
- if (actionCd == null) {
- return false;
- }
- return actionCd.equals(checkActionCd);
- }
-
- /**
- * Check if actionCd and actionStateCd are equal to the supplied checkActionCd
- * and checkActionStateCd. Treat checkActionStateCd == null as a wildcard
- * checkActionCd should not be null.
- *
- * @param checkActionCd the check action cd
- * @param checkActionStateCd the check action state cd
- * @return boolean
- */
- public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) {
- if (actionCd == null) {
- return false;
- }
- // treat checkActionStateCd == null as a wildcard (same for
- // actionStateCd, although it shouln't be null...)
- if (checkActionStateCd == null || actionStateCd == null) {
- return actionCd.equals(checkActionCd);
- }
- return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd);
- }
-
- /**
- * Check if actionStateCd is equal to the supplied checkActionStateCd.
- * checkActionCd should not be null.
- *
- * @param checkActionStateCd the check action state cd
- * @return boolean
- */
- public boolean isActionStateCd(String checkActionStateCd) {
- return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd);
- }
-
- /**
- * Gets action cd.
- *
- * @return the actionCd
- */
- public String getActionCd() {
- return actionCd;
- }
-
- /**
- * Sets action cd.
- *
- * @param actionCd the actionCd to set
- */
- public void setActionCd(String actionCd) {
- this.actionCd = actionCd;
- }
-
- /**
- * Gets action state cd.
- *
- * @return the actionStateCd
- */
- public String getActionStateCd() {
- return actionStateCd;
- }
-
- /**
- * Sets action state cd.
- *
- * @param actionStateCd the actionStateCd to set
- */
- public void setActionStateCd(String actionStateCd) {
- this.actionStateCd = actionStateCd;
- }
-
- /**
- * Gets process instance id.
- *
- * @return the processInstanceId
- */
- public String getProcessInstanceId() {
- return processInstanceId;
- }
-
- /**
- * Sets process instance id.
- *
- * @param processInstanceId the processInstanceId to set
- */
- public void setProcessInstanceId(String processInstanceId) {
- this.processInstanceId = processInstanceId;
- }
-
- /**
- * Gets userid.
- *
- * @return the userid
- */
- public String getUserid() {
- return userid;
- }
-
- /**
- * Sets userid.
- *
- * @param userid the userid to set
- */
- public void setUserid(String userid) {
- this.userid = userid;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java b/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java
index f66a6314..651997cd 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java
@@ -23,9 +23,15 @@
package org.onap.clamp.clds.model;
-public class CldsHealthCheck {
+import com.google.gson.annotations.Expose;
+public class CldsHealthCheck {
+ @Expose
private String healthCheckComponent;
+ @Expose
+ private String healthCheckStatus;
+ @Expose
+ private String description;
public String getHealthCheckComponent() {
return healthCheckComponent;
@@ -35,9 +41,6 @@ public class CldsHealthCheck {
this.healthCheckComponent = healthCheckComponent;
}
- private String healthCheckStatus;
- private String description;
-
public String getDescription() {
return description;
}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
deleted file mode 100644
index 4d2ca89a..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.NotFoundException;
-
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.actions.ActionsHandler;
-import org.onap.clamp.clds.model.actions.ActionsHandlerImpl;
-import org.onap.clamp.clds.model.status.StatusHandler;
-import org.onap.clamp.clds.model.status.StatusHandlerImpl;
-
-/**
- * Represent a CLDS Model.
- */
-public class CldsModel {
-
- private static final int UUID_LENGTH = 36;
- /**
- * The constant STATUS_DESIGN.
- */
- public static final String STATUS_DESIGN = "DESIGN";
- /**
- * The constant STATUS_DISTRIBUTED.
- */
- public static final String STATUS_DISTRIBUTED = "DISTRIBUTED";
- /**
- * The constant STATUS_ACTIVE.
- */
- public static final String STATUS_ACTIVE = "ACTIVE";
- /**
- * The constant STATUS_STOPPED.
- */
- public static final String STATUS_STOPPED = "STOPPED";
- /**
- * The constant STATUS_DELETING.
- */
- public static final String STATUS_DELETING = "DELETING";
- /**
- * The constant STATUS_ERROR.
- */
- public static final String STATUS_ERROR = "ERROR";
- /**
- * The constant STATUS_UNKNOWN.
- */
- public static final String STATUS_UNKNOWN = "UNKNOWN";
-
- @Expose
- private String id;
- @Expose
- private String templateId;
- @Expose
- private String templateName;
- @Expose
- private String name;
- @Expose
- private String controlNamePrefix;
- @Expose
- private String controlNameUuid;
- @Expose
- private String bpmnText;
- @Expose
- private String propText;
- @Expose
- private String imageText;
- @Expose
- private String docText;
- @Expose
- private String blueprintText;
- @Expose
- private CldsEvent event;
- @Expose
- private String status;
- @Expose
- private List<String> permittedActionCd;
- @Expose
- private List<CldsModelInstance> cldsModelInstanceList;
- // This is a transient value used to return the failure message to UI
- @Expose
- private String errorMessageForUi;
- /**
- * The service type Id received from DCAE by querying it.
- */
- @Expose
- private String typeId;
- @Expose
- private String typeName;
- @Expose
- private String deploymentId;
- @Expose
- private String deploymentStatusUrl;
-
- // Set default handlers but this can be changed if needed.
- private static StatusHandler statusHandler = new StatusHandlerImpl();
- private static ActionsHandler actionsHandler = new ActionsHandlerImpl();
-
- /**
- * Sets status handler.
- *
- * @param statHandler the stat handler
- */
- public static synchronized void setStatusHandler(StatusHandler statHandler) {
- statusHandler = statHandler;
- }
-
- /**
- * Sets actions handler.
- *
- * @param cdHandler the cd handler
- */
- public static synchronized void setActionsHandler(ActionsHandler cdHandler) {
- actionsHandler = cdHandler;
- }
-
- /**
- * Construct empty model.
- */
- public CldsModel() {
- event = new CldsEvent();
- }
-
- /**
- * Retrieve from DB.
- *
- * @param cldsDao the clds dao
- * @param name the name
- * @param okIfNotFound the ok if not found
- * @return the clds model
- */
- public static CldsModel retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
- // get from db
- CldsModel model = cldsDao.getModelTemplate(name);
- if (model.getId() == null && !okIfNotFound) {
- throw new NotFoundException();
- }
- model.determineStatus();
- model.determinePermittedActionCd();
- return model;
- }
-
- /**
- * Can dcae inventory call boolean.
- *
- * @return the boolean
- */
- public boolean canDcaeInventoryCall() {
- boolean canCall = false;
- /* Below checks the clds event is submit/resubmit/distribute */
- if (event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT)
- || event.isActionCd(CldsEvent.ACTION_DISTRIBUTE) || event.isActionCd(CldsEvent.ACTION_SUBMITDCAE)) {
- canCall = true;
- }
- return canCall;
- }
-
- /**
- * Save model to DB.
- *
- * @param cldsDao the clds dao
- * @param userid the userid
- * @return the clds model
- */
- public CldsModel save(CldsDao cldsDao, String userid) {
- CldsModel cldsModel = cldsDao.setModel(this, userid);
- determineStatus();
- determinePermittedActionCd();
- return cldsModel;
- }
-
- /**
- * set the status in the model.
- */
- public void determineStatus() {
- status = statusHandler.determineStatusOnLastEvent(event);
- }
-
- /**
- * Determine permittedActionCd list using the actionCd from the current event.
- * It's a states graph, given the next action that can be executed from the one
- * that has been executed (described in the event object). ACTION_CREATE being
- * the first one.
- */
- public void determinePermittedActionCd() {
- permittedActionCd = actionsHandler.determinePermittedActionsOnLastEvent(event, propText);
- }
-
- /**
- * Validate requestedActionCd - determine permittedActionCd and then check if
- * contained in permittedActionCd Throw IllegalArgumentException if requested
- * actionCd is not permitted.
- *
- * @param requestedActionCd the requested action cd
- */
- public void validateAction(String requestedActionCd) {
- determinePermittedActionCd();
- if (!permittedActionCd.contains(requestedActionCd)) {
- throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd
- + ". Given current actionCd: " + actionsHandler.getCurrentActionCd(event)
- + ", the permittedActionCd: " + permittedActionCd);
- }
- }
-
- /**
- * Extract the UUID portion of a given full control name (controlNamePrefix +
- * controlNameUuid). No fields are populated other than controlNamePrefix and
- * controlNameUuid. Throws BadRequestException if length of given control name
- * is less than UUID_LENGTH.
- *
- * @param fullControlName the full control name
- * @return the clds model
- */
- public static CldsModel createUsingControlName(String fullControlName) {
- if (fullControlName == null || fullControlName.length() < UUID_LENGTH) {
- throw new BadRequestException(
- "closed loop id / control name length, " + (fullControlName != null ? fullControlName.length() : 0)
- + ", less than the minimum of: " + UUID_LENGTH);
- }
- CldsModel model = new CldsModel();
- model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH));
- model.setControlNameUuid(fullControlName.substring(fullControlName.length() - UUID_LENGTH));
- return model;
- }
-
- /**
- * Gets control name.
- *
- * @return the controlName (controlNamePrefix + controlNameUuid)
- */
- public String getControlName() {
- return controlNamePrefix + controlNameUuid;
- }
-
- /**
- * To insert modelInstance to the database.
- *
- * @param cldsDao the clds dao
- * @param dcaeEvent the dcae event
- * @param userid the userid
- * @return the clds model
- */
- public static CldsModel insertModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent, String userid) {
- String controlName = dcaeEvent.getControlName();
- CldsModel cldsModel = createUsingControlName(controlName);
- cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid());
- cldsModel.determineStatus();
- if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || (dcaeEvent.getCldsActionCd()
- .equals(CldsEvent.ACTION_DEPLOY)
- && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) {
- CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(),
- CldsEvent.ACTION_STATE_RECEIVED, null);
- }
- cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances());
- return cldsModel;
- }
-
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets name.
- *
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Gets type name.
- *
- * @return the typeName
- */
- public String getTypeName() {
- return typeName;
- }
-
- /**
- * Sets type name.
- *
- * @param typeName the type name
- */
- public void setTypeName(String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * Gets template id.
- *
- * @return the template id
- */
- public String getTemplateId() {
- return templateId;
- }
-
- /**
- * Sets template id.
- *
- * @param templateId the template id
- */
- public void setTemplateId(String templateId) {
- this.templateId = templateId;
- }
-
- /**
- * Gets control name prefix.
- *
- * @return the controlNamePrefix
- */
- public String getControlNamePrefix() {
- return controlNamePrefix;
- }
-
- /**
- * Sets control name prefix.
- *
- * @param controlNamePrefix the controlNamePrefix to set
- */
- public void setControlNamePrefix(String controlNamePrefix) {
- this.controlNamePrefix = controlNamePrefix;
- }
-
- /**
- * Gets control name uuid.
- *
- * @return the controlNameUuid
- */
- public String getControlNameUuid() {
- return controlNameUuid;
- }
-
- /**
- * Sets control name uuid.
- *
- * @param controlNameUuid the controlNameUuid to set
- */
- public void setControlNameUuid(String controlNameUuid) {
- this.controlNameUuid = controlNameUuid;
- }
-
- /**
- * Gets prop text.
- *
- * @return the propText
- */
- public String getPropText() {
- return propText;
- }
-
- /**
- * Sets prop text.
- *
- * @param propText the propText to set
- */
- public void setPropText(String propText) {
- this.propText = propText;
- }
-
- /**
- * Gets event.
- *
- * @return the event
- */
- public CldsEvent getEvent() {
- return event;
- }
-
- /**
- * Gets id.
- *
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Sets id.
- *
- * @param id the id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Gets template name.
- *
- * @return the template name
- */
- public String getTemplateName() {
- return templateName;
- }
-
- /**
- * Sets template name.
- *
- * @param templateName the template name
- */
- public void setTemplateName(String templateName) {
- this.templateName = templateName;
- }
-
- /**
- * Sets event.
- *
- * @param event the event to set
- */
- public void setEvent(CldsEvent event) {
- this.event = event;
- }
-
- /**
- * Gets status.
- *
- * @return the status
- */
- public String getStatus() {
- return status;
- }
-
- /**
- * Sets status.
- *
- * @param status the status to set
- */
- public void setStatus(String status) {
- this.status = status;
- }
-
- /**
- * Gets blueprint text.
- *
- * @return the blueprint text
- */
- public String getBlueprintText() {
- return blueprintText;
- }
-
- /**
- * Sets blueprint text.
- *
- * @param blueprintText the blueprint text
- */
- public void setBlueprintText(String blueprintText) {
- this.blueprintText = blueprintText;
- }
-
- /**
- * Gets bpmn text.
- *
- * @return the bpmn text
- */
- public String getBpmnText() {
- return bpmnText;
- }
-
- /**
- * Sets bpmn text.
- *
- * @param bpmnText the bpmn text
- */
- public void setBpmnText(String bpmnText) {
- this.bpmnText = bpmnText;
- }
-
- /**
- * Gets image text.
- *
- * @return the image text
- */
- public String getImageText() {
- return imageText;
- }
-
- /**
- * Sets image text.
- *
- * @param imageText the image text
- */
- public void setImageText(String imageText) {
- this.imageText = imageText;
- }
-
- /**
- * Gets doc text.
- *
- * @return the doc text
- */
- public String getDocText() {
- return docText;
- }
-
- /**
- * Sets doc text.
- *
- * @param docText the doc text
- */
- public void setDocText(String docText) {
- this.docText = docText;
- }
-
- /**
- * Gets type id.
- *
- * @return the type id
- */
- public String getTypeId() {
- return typeId;
- }
-
- /**
- * Sets type id.
- *
- * @param typeId the type id
- */
- public void setTypeId(String typeId) {
- this.typeId = typeId;
- }
-
- /**
- * Gets clds model instance list.
- *
- * @return the clds model instance list
- */
- public List<CldsModelInstance> getCldsModelInstanceList() {
- if (cldsModelInstanceList == null) {
- cldsModelInstanceList = new ArrayList<>();
- }
- return cldsModelInstanceList;
- }
-
- /**
- * Gets deployment id.
- *
- * @return the deployment id
- */
- public String getDeploymentId() {
- return deploymentId;
- }
-
- /**
- * Sets deployment id.
- *
- * @param deploymentId the deployment id
- */
- public void setDeploymentId(String deploymentId) {
- this.deploymentId = deploymentId;
- }
-
- /**
- * Gets permitted action cd.
- *
- * @return the permitted action cd
- */
- public List<String> getPermittedActionCd() {
- return permittedActionCd;
- }
-
- /**
- * Gets error message for ui.
- *
- * @return the error message for ui
- */
- public String getErrorMessageForUi() {
- return errorMessageForUi;
- }
-
- /**
- * Sets error message for ui.
- *
- * @param errorMessageForUi the error message for ui
- */
- public void setErrorMessageForUi(String errorMessageForUi) {
- this.errorMessageForUi = errorMessageForUi;
- }
-
- /**
- * Gets deployment status url.
- *
- * @return the deployment status url
- */
- public String getDeploymentStatusUrl() {
- return deploymentStatusUrl;
- }
-
- /**
- * Sets deployment status url.
- *
- * @param deploymentStatusUrl the deployment status url
- */
- public void setDeploymentStatusUrl(String deploymentStatusUrl) {
- this.deploymentStatusUrl = deploymentStatusUrl;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java b/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java
deleted file mode 100644
index 082bfe33..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-public class CldsModelInstance {
-
- private String modelInstanceId;
- private String location;
- private String vmName;
-
- public String getVmName() {
- return vmName;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public String getModelInstanceId() {
- return modelInstanceId;
- }
-
- public void setModelInstanceId(String modelInstanceId) {
- this.modelInstanceId = modelInstanceId;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java b/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java
deleted file mode 100644
index 1a486e18..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-/**
- * Maintain model name and property text data.
- */
-public class CldsModelProp {
-
- private String id;
- private String name;
- private String propId;
- private String propText;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getPropId() {
- return propId;
- }
-
- public void setPropId(String propId) {
- this.propId = propId;
- }
-
- public String getPropText() {
- return propText;
- }
-
- public void setPropText(String propText) {
- this.propText = propText;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java
deleted file mode 100644
index 8777ab5c..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.NotAuthorizedException;
-
-import org.onap.clamp.clds.service.CldsService;
-
-public class CldsServiceData implements Serializable {
-
- private static final long serialVersionUID = -9153372664377279423L;
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private String serviceInvariantUuid;
- private String serviceUiod;
- private Long ageOfRecord;
- private List<CldsVfData> cldsVfs;
-
- public String getServiceInvariantUUID() {
- return serviceInvariantUuid;
- }
-
- public void setServiceInvariantUUID(String serviceInvariantUuid) {
- this.serviceInvariantUuid = serviceInvariantUuid;
- }
-
- public List<CldsVfData> getCldsVfs() {
- return cldsVfs;
- }
-
- public void setCldsVfs(List<CldsVfData> cldsVfs) {
- this.cldsVfs = cldsVfs;
- }
-
- public String getServiceUUID() {
- return serviceUiod;
- }
-
- public void setServiceUUID(String serviceUuid) {
- this.serviceUiod = serviceUuid;
- }
-
- public Long getAgeOfRecord() {
- return ageOfRecord;
- }
-
- public void setAgeOfRecord(Long ageOfRecord) {
- this.ageOfRecord = ageOfRecord;
- }
-
- /**
- * Filter out any VFs that the user is not authorized for. Use the CldsService
- * to determine if the user is authorized for a VF.
- *
- * @param svc The clds service
- */
- public void filterVfs(CldsService svc) {
- List<CldsVfData> filteredCldsVfs = new ArrayList<>();
- if (cldsVfs == null) {
- logger.debug("cldsVfs == null");
- } else {
- for (CldsVfData vf : cldsVfs) {
- // if user is authorized for the VF then add it to the filtered
- // list
- try {
- if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) {
- filteredCldsVfs.add(vf);
- }
- } catch (NotAuthorizedException e) {
- logger.error("user not authorized for {}" + vf.getVfInvariantResourceUUID(), e);
- // when not NotAuthorizedException - don't add to
- // filteredCldsVfs list
- }
- }
- }
- // new filtered list replaces the list of VFs for the user
- cldsVfs = filteredCldsVfs;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java
deleted file mode 100644
index b1247801..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import javax.ws.rs.NotFoundException;
-
-import org.onap.clamp.clds.dao.CldsDao;
-
-/**
- * Represent a CLDS Model.
- */
-public class CldsTemplate {
-
- public static final String STATUS_DESIGN = "DESIGN";
- public static final String STATUS_ACTIVE = "ACTIVE";
- public static final String STATUS_STOPPED = "STOPPED";
- public static final String STATUS_DELETING = "DELETING";
- // manual intervention required
- public static final String STATUS_ERROR = "ERROR";
- public static final String STATUS_UNKNOWN = "UNKNOWN";
-
- @Expose
- private String id;
- @Expose
- private String name;
- @Expose
- private String controlNamePrefix;
- @Expose
- private String controlNameUuid;
- @Expose
- private String bpmnId;
- @Expose
- private String bpmnUserid;
- @Expose
- private String bpmnText;
- @Expose
- private String imageId;
- @Expose
- private String imageUserid;
- @Expose
- private String imageText;
- @Expose
- private String propId;
- @Expose
- private String propUserid;
- @Expose
- private String propText;
- @Expose
- private boolean userAuthorizedToUpdate;
-
- /**
- * Save template to DB.
- *
- * @param cldsDao The cldsDao
- * @param userid The user Id
- */
- public void save(CldsDao cldsDao, String userid) {
- cldsDao.setTemplate(this, userid);
- }
-
- /**
- * Retrieve from DB.
- *
- * @param cldsDao The cldsDao
- * @param name The template name to retrieve
- * @param okIfNotFound The flag indicating whether exception will be returned in
- * case nothing is found
- * @return Clds template from DB
- */
- public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
- // get from db
- CldsTemplate template = cldsDao.getTemplate(name);
- if (template.getId() == null && !okIfNotFound) {
- throw new NotFoundException();
- }
- return template;
- }
-
- public String getBpmnUserid() {
- return bpmnUserid;
- }
-
- public void setBpmnUserid(String bpmnUserid) {
- this.bpmnUserid = bpmnUserid;
- }
-
- public String getBpmnText() {
- return bpmnText;
- }
-
- public void setBpmnText(String bpmnText) {
- this.bpmnText = bpmnText;
- }
-
- public String getImageUserid() {
- return imageUserid;
- }
-
- public void setImageUserid(String imageUserid) {
- this.imageUserid = imageUserid;
- }
-
- public String getImageText() {
- return imageText;
- }
-
- public void setImageText(String imageText) {
- this.imageText = imageText;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getControlNamePrefix() {
- return controlNamePrefix;
- }
-
- public void setControlNamePrefix(String controlNamePrefix) {
- this.controlNamePrefix = controlNamePrefix;
- }
-
- public String getControlNameUuid() {
- return controlNameUuid;
- }
-
- public void setControlNameUuid(String controlNameUuid) {
- this.controlNameUuid = controlNameUuid;
- }
-
- public String getPropId() {
- return propId;
- }
-
- public void setPropId(String propId) {
- this.propId = propId;
- }
-
- public String getPropUserid() {
- return propUserid;
- }
-
- public void setPropUserid(String propUserid) {
- this.propUserid = propUserid;
- }
-
- public String getPropText() {
- return propText;
- }
-
- public void setPropText(String propText) {
- this.propText = propText;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getBpmnId() {
- return bpmnId;
- }
-
- public void setBpmnId(String bpmnId) {
- this.bpmnId = bpmnId;
- }
-
- public String getImageId() {
- return imageId;
- }
-
- public void setImageId(String imageId) {
- this.imageId = imageId;
- }
-
- public boolean isUserAuthorizedToUpdate() {
- return userAuthorizedToUpdate;
- }
-
- public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) {
- this.userAuthorizedToUpdate = userAuthorizedToUpdate;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
deleted file mode 100644
index 5ae13d20..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
-
-public class CldsToscaModel extends CldsToscaModelRevision {
-
- @Expose
- private String id;
- @Expose
- private String policyType;
- @Expose
- private String toscaModelName;
-
- /**
- * Construct.
- */
- public CldsToscaModel() {
- }
-
- /**
- * Creates or updates Tosca Model to DB.
- *
- * @param cldsDao The cldsDao
- * @param userId The user Id
- */
- public CldsToscaModel save(CldsDao cldsDao, ClampProperties refProp, PolicyClient policyClient, String userId) {
- CldsToscaModel cldsToscaModel = null;
- refProp.getStringList("tosca.policyTypes", ",").stream().forEach(policyType -> {
- if (StringUtils.containsIgnoreCase(this.getToscaModelName(), policyType)) {
- this.setPolicyType(policyType);
- }
- });
-
- ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(cldsDao);
- this.setToscaModelJson(convertor.parseToscaYaml(this.getToscaModelYaml()));
- List<CldsToscaModel> toscaModels = cldsDao.getToscaModelByName(this.getToscaModelName());
- if (toscaModels != null && !toscaModels.isEmpty()) {
- CldsToscaModel toscaModel = toscaModels.stream().findFirst().get();
- this.setVersion(incrementVersion(toscaModel.getVersion()));
- this.setId(toscaModel.getId());
- this.setUserId(userId);
- if (refProp.getStringValue("import.tosca.model").equalsIgnoreCase("true")) {
- policyClient.importToscaModel(this);
- }
- cldsToscaModel = cldsDao.updateToscaModelWithNewVersion(this, userId);
- } else {
- this.setVersion(1);
- if (refProp.getStringValue("import.tosca.model").equalsIgnoreCase("true")) {
- policyClient.importToscaModel(this);
- }
- cldsToscaModel = cldsDao.insToscaModel(this, userId);
- }
- return cldsToscaModel;
- }
-
- private double incrementVersion(double curVersion) {
- return curVersion + 1;
- }
-
- /**
- * Get the Id.
- *
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Set the id.
- *
- * @param id the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Get the policy type.
- *
- * @return the policyType
- */
- public String getPolicyType() {
- return policyType;
- }
-
- /**
- * Set the policy type.
- *
- * @param policyType the policyType to set
- */
- public void setPolicyType(String policyType) {
- this.policyType = policyType;
- }
-
- /**
- * Get the tosca model name.
- *
- * @return the toscaModelName
- */
- public String getToscaModelName() {
- return toscaModelName;
- }
-
- /**
- * Set the tosca model name.
- *
- * @param toscaModelName the toscaModelName to set
- */
- public void setToscaModelName(String toscaModelName) {
- this.toscaModelName = toscaModelName;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
deleted file mode 100644
index 4ee1debc..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents a CLDS Tosca model.
- */
-public class CldsToscaModelDetails {
-
- private String id;
- private String toscaModelName;
- private String policyType;
- private List<CldsToscaModelRevision> toscaModelRevisions = new ArrayList<>();
- private String userId;
- private String lastUpdatedDate;
-
- /**
- * Get the id.
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Set the id.
- * @param id
- * the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Get the tosca model name.
- * @return the toscaModelName
- */
- public String getToscaModelName() {
- return toscaModelName;
- }
-
- /**
- * Set the tosca model name.
- * @param toscaModelName
- * the toscaModelName to set
- */
- public void setToscaModelName(String toscaModelName) {
- this.toscaModelName = toscaModelName;
- }
-
- /**
- * Get the policy type.
- * @return the policyType
- */
- public String getPolicyType() {
- return policyType;
- }
-
- /**
- * Set the policy type.
- * @param policyType
- * the policyType to set
- */
- public void setPolicyType(String policyType) {
- this.policyType = policyType;
- }
-
- /**
- * Get the list of tosca model revisions.
- * @return the toscaModelRevisions
- */
- public List<CldsToscaModelRevision> getToscaModelRevisions() {
- return toscaModelRevisions;
- }
-
- /**
- * Set the list of tosca model revisions.
- * @param toscaModelRevisions
- * the toscaModelRevisions to set
- */
- public void setToscaModelRevisions(List<CldsToscaModelRevision> toscaModelRevisions) {
- this.toscaModelRevisions = toscaModelRevisions;
- }
-
- /**
- * Get the user id.
- * @return the userId
- */
- public String getUserId() {
- return userId;
- }
-
- /**
- * Set the user id.
- * @param userId
- * the userId to set
- */
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- /**
- * Get the last updated date.
- * @return the lastUpdatedDate
- */
- public String getLastUpdatedDate() {
- return lastUpdatedDate;
- }
-
- /**
- * Set the last updated date.
- * @param lastUpdatedDate
- * the lastUpdatedDate to set
- */
- public void setLastUpdatedDate(String lastUpdatedDate) {
- this.lastUpdatedDate = lastUpdatedDate;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
deleted file mode 100644
index b9a7e0d5..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-/**
- * Represents a CLDS Tosca model revision.
- */
-
-package org.onap.clamp.clds.model;
-
-public class CldsToscaModelRevision {
-
- private String revisionId;
- private String toscaModelYaml;
- private double version;
- private String toscaModelJson;
- private String userId;
- private String createdDate;
- private String lastUpdatedDate;
-
- /**
- * Get the revision id.
- * @return the revisionId
- */
- public String getRevisionId() {
- return revisionId;
- }
-
- /**
- * Set the revision id.
- * @param revisionId
- * the revisionId to set
- */
- public void setRevisionId(String revisionId) {
- this.revisionId = revisionId;
- }
-
- /**
- * Get the tosca model yaml.
- * @return the toscaModelYaml
- */
- public String getToscaModelYaml() {
- return toscaModelYaml;
- }
-
- /**
- * Set the tosca model yaml.
- * @param toscaModelYaml
- * the toscaModelYaml to set
- */
- public void setToscaModelYaml(String toscaModelYaml) {
- this.toscaModelYaml = toscaModelYaml;
- }
-
- /**
- * Get the version.
- * @return the version
- */
- public double getVersion() {
- return version;
- }
-
- /**
- * Set the version.
- * @param version
- * the version to set
- */
- public void setVersion(double version) {
- this.version = version;
- }
-
- /**
- * Get the tosca model json.
- * @return the toscaModelJson
- */
- public String getToscaModelJson() {
- return toscaModelJson;
- }
-
- /**
- * Set the tosca model json.
- * @param toscaModelJson
- * the toscaModelJson to set
- */
- public void setToscaModelJson(String toscaModelJson) {
- this.toscaModelJson = toscaModelJson;
- }
-
- /**
- * Get the user id.
- * @return the userId
- */
- public String getUserId() {
- return userId;
- }
-
- /**
- * Set the user id.
- * @param userId
- * the userId to set
- */
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- /**
- * Get the created date.
- * @return the createdDate
- */
- public String getCreatedDate() {
- return createdDate;
- }
-
- /**
- * Set the created date.
- * @param createdDate
- * the createdDate to set
- */
- public void setCreatedDate(String createdDate) {
- this.createdDate = createdDate;
- }
-
- /**
- * Get the last updated date.
- * @return the lastUpdatedDate
- */
- public String getLastUpdatedDate() {
- return lastUpdatedDate;
- }
-
- /**
- * Set the last updated date.
- * @param lastUpdatedDate
- * the lastUpdatedDate to set
- */
- public void setLastUpdatedDate(String lastUpdatedDate) {
- this.lastUpdatedDate = lastUpdatedDate;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java
deleted file mode 100644
index a31388e1..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class CldsVfData implements Serializable {
-
- private static final long serialVersionUID = -5069670140274203606L;
- private String vfName;
- private String vfInvariantResourceUuid;
- private List<CldsVfcData> cldsVfcs;
-
- private List<CldsVfKPIData> cldsKpiList;
-
- public List<CldsVfKPIData> getCldsKPIList() {
- return cldsKpiList;
- }
-
- public void setCldsKPIList(List<CldsVfKPIData> cldsKpiList) {
- this.cldsKpiList = cldsKpiList;
- }
-
- public String getVfName() {
- return vfName;
- }
-
- public void setVfName(String vfName) {
- this.vfName = vfName;
- }
-
- public List<CldsVfcData> getCldsVfcs() {
- return cldsVfcs;
- }
-
- public void setCldsVfcs(List<CldsVfcData> cldsVfcs) {
- this.cldsVfcs = cldsVfcs;
- }
-
- public String getVfInvariantResourceUUID() {
- return vfInvariantResourceUuid;
- }
-
- public void setVfInvariantResourceUUID(String vfInvariantResourceUuid) {
- this.vfInvariantResourceUuid = vfInvariantResourceUuid;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java
deleted file mode 100644
index 8aab1fff..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-
-public class CldsVfKPIData implements Serializable {
-
- private static final long serialVersionUID = 9067755871527776380L;
-
- private String nfNamingCode;
- private String nfNamingValue;
-
- private String fieldPath;
- private String fieldPathValue;
-
- private String thresholdName;
- private String thresholdValue;
-
- public String getNfNamingCode() {
- return nfNamingCode;
- }
-
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
-
- public String getNfNamingValue() {
- return nfNamingValue;
- }
-
- public void setNfNamingValue(String nfNamingValue) {
- this.nfNamingValue = nfNamingValue;
- }
-
- public String getFieldPath() {
- return fieldPath;
- }
-
- public void setFieldPath(String fieldPath) {
- this.fieldPath = fieldPath;
- }
-
- public String getFieldPathValue() {
- return fieldPathValue;
- }
-
- public void setFieldPathValue(String fieldPathValue) {
- this.fieldPathValue = fieldPathValue;
- }
-
- public String getThresholdName() {
- return thresholdName;
- }
-
- public void setThresholdName(String thresholdName) {
- this.thresholdName = thresholdName;
- }
-
- public String getThresholdValue() {
- return thresholdValue;
- }
-
- public void setThresholdValue(String thresholdValue) {
- this.thresholdValue = thresholdValue;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java
deleted file mode 100644
index 034fc28c..00000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class CldsVfcData implements Serializable {
-
- private static final long serialVersionUID = 406993878174183557L;
- private String vfcName;
- private String vfcInvariantResourceUuid;
- private List<CldsAlarmCondition> cldsAlarmConditions;
-
- public String getVfcName() {
- return vfcName;
- }
-
- public void setVfcName(String vfcName) {
- this.vfcName = vfcName;
- }
-
- public List<CldsAlarmCondition> getCldsAlarmConditions() {
- return cldsAlarmConditions;
- }
-
- public void setCldsAlarmConditions(List<CldsAlarmCondition> cldsAlarmConditions) {
- this.cldsAlarmConditions = cldsAlarmConditions;
- }
-
- public String getVfcInvariantResourceUUID() {
- return vfcInvariantResourceUuid;
- }
-
- public void setVfcInvariantResourceUUID(String vfcInvariantResourceUuid) {
- this.vfcInvariantResourceUuid = vfcInvariantResourceUuid;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java
deleted file mode 100644
index 9126f9ab..00000000
--- a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.List;
-
-import javax.ws.rs.BadRequestException;
-
-/**
- * Represent a DCAE Event.
- */
-public class DcaeEvent {
- // this is an event we (clds) sends to dcae
- public static final String EVENT_CREATED = "created";
- public static final String EVENT_DISTRIBUTION = "distribute";
- public static final String EVENT_DEPLOYMENT = "deployment";
- public static final String EVENT_UNDEPLOYMENT = "undeployment";
- public static final String ARTIFACT_NAME_SUFFIX = ".yml";
-
- @Expose
- private String event;
- @Expose
- private String serviceUuid;
- @Expose
- private String resourceUuid;
- @Expose
- private String artifactName; // controlName.yml
- @Expose
- private List<CldsModelInstance> instances;
-
- /**
- * Transform a DCAE Event Action to a CldsEvent.actionCd.
- *
- * @return The clds action.
- */
- public String getCldsActionCd() {
- if (event == null || event.length() == 0) {
- throw new BadRequestException("action null or empty");
- } else if (event.equalsIgnoreCase(EVENT_CREATED)) {
- return CldsEvent.ACTION_CREATE;
- } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) {
- return CldsEvent.ACTION_DISTRIBUTE;
- } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.isEmpty())) {
- return CldsEvent.ACTION_DEPLOY;
- } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) {
- return CldsEvent.ACTION_DEPLOY;
- // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy
- // individual instances. It will send an empty list of
- // deployed instances to indicate all have been removed. Or it will
- // send an updated list to indicate those that
- // are still deployed with any not on the list considered
- // undeployed.
- } else if (event.equals(EVENT_UNDEPLOYMENT)) {
- return CldsEvent.ACTION_UNDEPLOY;
- }
-
- throw new BadRequestException("event value not valid: " + event);
- }
-
- /**
- * Derive the controlName from the artifactName.
- *
- * @return the controlName
- */
- public String getControlName() {
- if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) {
- return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length());
- } else {
- throw new BadRequestException("artifactName value not valid (expecting it to end with "
- + ARTIFACT_NAME_SUFFIX + "): " + artifactName);
- }
- }
-
- /**
- * Get the event.
- *
- * @return the event
- */
- public String getEvent() {
- return event;
- }
-
- /**
- * Set the event.
- *
- * @param event the event to set
- */
- public void setEvent(String event) {
- this.event = event;
- }
-
- /**
- * Get the serviceUUID.
- *
- * @return the serviceUUID
- */
- public String getServiceUUID() {
- return serviceUuid;
- }
-
- /**
- * Set the serviceUUID.
- *
- * @param serviceUUID the serviceUUID to set
- */
- public void setServiceUUID(String serviceUuid) {
- this.serviceUuid = serviceUuid;
- }
-
- /**
- * Get the resourceUUID.
- *
- * @return the resourceUUID
- */
- public String getResourceUUID() {
- return resourceUuid;
- }
-
- /**
- * Set the resourceUUID.
- *
- * @param resourceUUID the resourceUUID to set
- */
- public void setResourceUUID(String resourceUuid) {
- this.resourceUuid = resourceUuid;
- }
-
- /**
- * Get the artifact name.
- *
- * @return the artifactName
- */
- public String getArtifactName() {
- return artifactName;
- }
-
- /**
- * Set the artifact name.
- *
- * @param artifactName the artifactName to set
- */
- public void setArtifactName(String artifactName) {
- this.artifactName = artifactName;
- }
-
- /**
- * Get the list of instances.
- *
- * @return The list of model instances
- */
- public List<CldsModelInstance> getInstances() {
- return instances;
- }
-
- /**
- * Set the list of model instances.
- *
- * @param instances The list of model instances to set
- */
- public void setInstances(List<CldsModelInstance> instances) {
- this.instances = instances;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java
deleted file mode 100644
index 42323908..00000000
--- a/src/main/java/org/onap/clamp/clds/model/ValueItem.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-/**
- * ValueItem used for value lists.
- */
-public class ValueItem {
- @Expose
- private String value;
-
- /**
- * Instantiate using value.
- *
- * @param value The value
- */
- public ValueItem(String value) {
- this.value = value;
- }
-
- public ValueItem() {
- }
-
- /**
- * Get the value.
- *
- * @return the value
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Set the value.
- *
- * @param value the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java b/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java
deleted file mode 100644
index 9aed447d..00000000
--- a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018-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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.actions;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.util.Arrays;
-import java.util.List;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Interface for actions that the user can do according to the last event.
- *
- *
- */
-public interface ActionsHandler {
-
- enum ModelType {
- SIMPLE_MODEL("simpleModel"), POLICY_MODEL("policyModel");
- private final String type;
-
- ModelType(String type) {
- this.type = type;
- }
-
- public final String getType() {
- return this.type;
- }
- }
-
- EELFLogger getLogger();
-
- /**
- * This method determines a list of actions that the user can do according to
- * the last event.
- *
- * @param event
- * The last event
- * @param propText
- * The Json properties string
- * @return A list of actions
- */
- default List<String> determinePermittedActionsOnLastEvent(CldsEvent event, String propText) {
- List<String> permittedActions;
- String actionCd = getCurrentActionCd(event);
- switch (actionCd) {
- case CldsEvent.ACTION_CREATE:
- permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST,
- CldsEvent.ACTION_DELETE);
- if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
- permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
- CldsEvent.ACTION_TEST, CldsEvent.ACTION_DELETE);
- }
- break;
- case CldsEvent.ACTION_SUBMIT:
- case CldsEvent.ACTION_RESUBMIT:
- case CldsEvent.ACTION_DISTRIBUTE:
- permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT,
- CldsEvent.ACTION_DELETE);
- if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
- permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_SUBMITDCAE,
- CldsEvent.ACTION_DELETE);
- }
- break;
- case CldsEvent.ACTION_SUBMITDCAE:
- permittedActions = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
- break;
- case CldsEvent.ACTION_SUBMITPOLICY:
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
- break;
- case CldsEvent.ACTION_UNDEPLOY:
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY,
- CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_DELETE);
- if (isTypeModel(propText, ModelType.SIMPLE_MODEL)) {
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY,
- CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
- }
- break;
- case CldsEvent.ACTION_DEPLOY:
- permittedActions = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE,
- CldsEvent.ACTION_STOP);
- break;
- case CldsEvent.ACTION_RESTART:
- case CldsEvent.ACTION_UPDATE:
- permittedActions = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE,
- CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY);
- if (isTypeModel(propText, ModelType.POLICY_MODEL)) {
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
- }
- break;
- case CldsEvent.ACTION_STOP:
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
- CldsEvent.ACTION_UNDEPLOY);
- if (isTypeModel(propText, ModelType.POLICY_MODEL)) {
- permittedActions = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
- CldsEvent.ACTION_DELETE);
- }
- break;
- default:
- getLogger().warn("Invalid current actionCd: " + actionCd);
- permittedActions = Arrays.asList();
- }
- return permittedActions;
- }
-
- /**
- * This returns the action of the event or a default one if not found.
- *
- * @param event The last event
- * @return The action
- */
- default String getCurrentActionCd(CldsEvent event) {
- // current default actionCd is CREATE
- String actionCd = CldsEvent.ACTION_CREATE;
- if (event != null && event.getActionCd() != null) {
- actionCd = event.getActionCd();
- }
- return actionCd;
- }
-
- /**
- * Check whether the text properties is of specified type ModelType.
- *
- * @param propText
- * The Clamp Json properties
- * @param key
- * The model type
- * @return True if matches the right type specified
- */
- default boolean isTypeModel(String propText, ModelType key) {
- boolean result = false;
- try {
- if (propText != null) {
- JsonObject modelJson = JsonUtils.GSON.fromJson(propText, JsonObject.class);
- JsonElement modelJsonOfType = modelJson.get(key.getType());
- if (modelJsonOfType != null
- && modelJsonOfType.isJsonPrimitive()
- && modelJsonOfType.getAsJsonPrimitive().getAsBoolean()) {
- result = true;
- }
- }
- } catch (JsonParseException e) {
- getLogger().error("Error while parsing propText json", e);
- }
- return result;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java b/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java
deleted file mode 100644
index 8d7d2408..00000000
--- a/src/main/java/org/onap/clamp/clds/model/actions/ActionsHandlerImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.actions;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-public class ActionsHandlerImpl implements ActionsHandler {
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(ActionsHandlerImpl.class);
-
- @Override
- public EELFLogger getLogger() {
- return logger;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
deleted file mode 100644
index 9c15524d..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- * Provide base ModelElement functionality. Perform base parsing of properties for a ModelElement (such as,
- * VesCollector, Policy, Tca, Holmes, ...)
- */
-public abstract class AbstractModelElement {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private final String id;
- protected String topicPublishes;
- protected final JsonElement modelElementJsonNode;
- private final boolean isFound;
-
- /**
- * Perform base parsing of properties for a ModelElement (such as, VesCollector, Policy and Tca).
- */
- protected AbstractModelElement(String type, ModelBpmn modelBpmn, JsonObject modelJson) {
- this.id = modelBpmn.getId(type);
- this.modelElementJsonNode = modelJson.get(id);
- this.isFound = modelBpmn.isModelElementTypeInList(type);
- }
-
- /**
- * Get the topic publishes.
- *
- * @return the topicPublishes
- */
- public String getTopicPublishes() {
- return topicPublishes;
- }
-
- /**
- * Get the id.
- *
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Get the isFound flag.
- *
- * @return the isFound
- */
- public boolean isFound() {
- return isFound;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Global.java b/src/main/java/org/onap/clamp/clds/model/properties/Global.java
deleted file mode 100644
index 0eed6ab9..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/Global.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse global json properties.
- * Example json:
- * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS",
- * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city"
- * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}]
- */
-public class Global {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private String service;
- private String actionSet;
- private List<String> resourceVf;
- private List<String> resourceVfc;
- private JsonObject deployParameters;
- private List<String> location;
- private String vnfScope;
-
- /**
- * Parse global given json node.
- *
- * @param modelJson The model in json format.
- */
- public Global(JsonObject modelJson) {
- JsonElement globalNode = modelJson.get("global");
- service = JsonUtils.getStringValueByName(globalNode, "service");
- actionSet = JsonUtils.getStringValueByName(globalNode, "actionSet");
- resourceVf = JsonUtils.getStringValuesByName(globalNode, "vf");
- resourceVfc = JsonUtils.getStringValuesByName(globalNode, "vfc");
- deployParameters = JsonUtils.getJsonObjectByName(globalNode, "deployParameters");
- location = JsonUtils.getStringValuesByName(globalNode, "location");
- vnfScope = JsonUtils.getStringValueByName(globalNode, "vnf");
- }
-
- /**
- * Get the service.
- * @return the service
- */
- public String getService() {
- return service;
- }
-
- /**
- * Set the service.
- * @param service
- * the service to set
- */
- public void setService(String service) {
- this.service = service;
- }
-
- /**
- * Get the action set.
- * @return the actionSet
- */
- public String getActionSet() {
- return actionSet;
- }
-
- /**
- * Set tje actionSet.
- * @param actionSet
- * The actionSet to set
- */
- public void setActionSet(String actionSet) {
- this.actionSet = actionSet;
- }
-
- /**
- * Get the resource vf.
- * @return the resourceVf
- */
- public List<String> getResourceVf() {
- return resourceVf;
- }
-
- /**
- * Set the resourceVf.
- * @param resourceVf
- * the resourceVf to set
- */
- public void setResourceVf(List<String> resourceVf) {
- this.resourceVf = resourceVf;
- }
-
- /**
- * Get the resource Vfc.
- * @return the resourceVfc
- */
- public List<String> getResourceVfc() {
- return resourceVfc;
- }
-
- /**
- * Set tje respirce Vfc.
- * @param resourceVfc
- * the resourceVfc to set
- */
- public void setResourceVfc(List<String> resourceVfc) {
- this.resourceVfc = resourceVfc;
- }
-
- /**
- * Get the list of locations.
- * @return the location
- */
- public List<String> getLocation() {
- return location;
- }
-
- /**
- * Set the list of locations.
- * @param location
- * the location to set
- */
- public void setLocation(List<String> location) {
- this.location = location;
- }
-
- /**
- * Get the deploy parameters.
- * @return The deploy parameters
- */
- public JsonObject getDeployParameters() {
- return deployParameters;
- }
-
- /**
- * Set the deploy parameters.
- * @param deployParameters
- * the deploy parameters to set
- */
- public void setDeployParameters(JsonObject deployParameters) {
- this.deployParameters = deployParameters;
- }
-
- /**
- * Get the vnf scope.
- * @return The vnf scope
- */
- public String getVnfScope() {
- return vnfScope;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
deleted file mode 100644
index a56c57d1..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.google.gson.JsonObject;
-
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Holmes bpmn parameters json properties. Example json:
- * [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}]
- */
-public class Holmes extends AbstractModelElement {
-
- private static final String TYPE_HOLMES = "holmes";
-
- private String correlationLogic;
- private String configPolicyName;
-
- /**
- * Default constructor for Holmes Element.
- *
- * @param modelBpmn
- * The model bpmn
- * @param modelJson
- * The model json
- */
- public Holmes(ModelBpmn modelBpmn, JsonObject modelJson) {
- super(TYPE_HOLMES, modelBpmn, modelJson);
-
- if (modelElementJsonNode != null) {
- correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic");
- configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName");
- }
- }
-
- public static final String getType() {
- return TYPE_HOLMES;
- }
-
- public String getCorrelationLogic() {
- return correlationLogic;
- }
-
- public String getConfigPolicyName() {
- return configPolicyName;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java
deleted file mode 100644
index d35eea88..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Model BPMN properties.
- * Example json: {"policy" :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
- */
-public class ModelBpmn {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- // for each type, an array of entries
- private final Map<String, List<ModelBpmnEntry>> entriesByType = new HashMap<>();
- // for each id, an array of entries
- private final Map<String, List<ModelBpmnEntry>> entriesById = new HashMap<>();
- // List of all elementIds
- private List<String> bpmnElementIds;
-
- /**
- * Create ModelBpmn and populate maps from json.
- *
- * @param modelBpmnPropText The model bpmn properties text
- * @return The model bpmn
- */
- public static ModelBpmn create(String modelBpmnPropText) {
- try {
- ModelBpmn modelBpmn = new ModelBpmn();
- JsonObject root = JsonUtils.GSON.fromJson(modelBpmnPropText, JsonObject.class);
- // iterate over each entry like:
- // "Policy":[{"id":"Policy","from":"StartEvent_1"}]
- Iterator<Entry<String, JsonElement>> entryItr = root.entrySet().iterator();
- List<String> bpmnElementIdList = new ArrayList<>();
- while (entryItr.hasNext()) {
- // process the entry
- Entry<String, JsonElement> entry = entryItr.next();
- String type = entry.getKey();
- JsonArray arrayNode = entry.getValue().getAsJsonArray();
- // process each id/from object, like:
- // {"id":"Policy","from":"StartEvent_1"}
- for (JsonElement anArrayNode : arrayNode) {
- JsonObject node = anArrayNode.getAsJsonObject();
- String id = node.get("id").getAsString();
- String fromId = node.get("from").getAsString();
- ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId);
- modelBpmn.addEntry(modelBpmnEntry);
- bpmnElementIdList.add(id);
- }
- modelBpmn.setBpmnElementIds(bpmnElementIdList);
- }
- return modelBpmn;
- } catch (JsonParseException e) {
- throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e);
- }
- }
-
- /**
- * Add entry to both maps.
- *
- * @param entry The model bpmn entry.
- */
- private void addEntry(ModelBpmnEntry entry) {
- addEntry(entriesByType, entry, entry.getType());
- addEntry(entriesById, entry, entry.getId());
- }
-
- /**
- * Add an entry to provided map with provided key.
- *
- * @param map The map to add the model bpmn entry
- * @param entry The model bmpn entry
- * @param key The key
- */
- private static void addEntry(Map<String, List<ModelBpmnEntry>> map, ModelBpmnEntry entry, String key) {
- List<ModelBpmnEntry> list = map.computeIfAbsent(key, k -> new ArrayList<>());
- list.add(entry);
- }
-
- /**
- * This method verifies if the ModelElement Type (holmes, tca, ...) is in
- * the list.
- *
- * @param type
- * A model Element type (tca, ...)
- * @return true if the element is found or false otherwise
- */
- public boolean isModelElementTypeInList(String type) {
- return entriesByType.get(type) != null;
- }
-
- /**
- * Get the id.
- * @return the id field given the ModelElement type
- */
- public String getId(String type) {
- String modelElementId = "";
- if (entriesByType.get(type) != null) {
- modelElementId = entriesByType.get(type).get(0).getId();
- }
- return modelElementId;
- }
-
- /**
- * Get the form id.
- * @return the fromId field given the ModelElement type
- */
- public String getFromId(String type) {
- String modelElementFromIdId = "";
- if (entriesByType.get(type) != null) {
- modelElementFromIdId = entriesByType.get(type).get(0).getFromId();
- }
- return modelElementFromIdId;
- }
-
- /**
- * Get the type.
- * @return the ModelElement type given the ModelElement id
- */
- public String getType(String id) {
- return entriesById.get(id).get(0).getType();
- }
-
- /**
- * Get the bpmn element ids.
- * @return list of elementIds from bpmn
- */
- public List<String> getBpmnElementIds() {
- return bpmnElementIds;
- }
-
- public void setBpmnElementIds(List<String> bpmnElementIds) {
- this.bpmnElementIds = bpmnElementIds;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java
deleted file mode 100644
index 741b9dec..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-/**
- * Model BPMN property entry.
- * Example json: {"policy":
- * [{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]}
- */
-public class ModelBpmnEntry {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelBpmnEntry.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private String type;
- private String id;
- private String fromId;
-
- /**
- * Parse the json so that the "id" and "from" fields can be retrieved on
- * demand.
- *
- * @param type The type
- * @param id The id
- * @param fromId The form id
- */
- public ModelBpmnEntry(String type, String id, String fromId) {
- this.type = type;
- this.id = id;
- this.fromId = fromId;
- }
-
- /**
- * Get the type.
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * Set the type.
- * @param type
- * the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * Get the id.
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Set the id.
- * @param id
- * the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Get the form id.
- * @return the fromId
- */
- public String getFromId() {
- return fromId;
- }
-
- /**
- * Set the form id.
- * @param fromId
- * the fromId to set
- */
- public void setFromId(String fromId) {
- this.fromId = fromId;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
deleted file mode 100644
index 9b7f85d9..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.camel.Exchange;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse model properties.
- */
-public class ModelProperties {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private ModelBpmn modelBpmn;
- private JsonObject modelJson;
- private final String modelName;
- private final String controlName;
- private final String actionCd;
- // Flag indicate whether it is triggered by Validation Test button from UI
- private final boolean testOnly;
- private Global global;
- private final Map<String, AbstractModelElement> modelElements = new ConcurrentHashMap<>();
- private String currentModelElementId;
- private String policyUniqueId;
- private String guardUniqueId;
- public static final String POLICY_GUARD_SUFFIX = "_Guard_";
- private static final Object lock = new Object();
- private static Map<Class<? extends AbstractModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
-
- static {
- synchronized (lock) {
- modelElementClasses.put(Policy.class, Policy.getType());
- modelElementClasses.put(Tca.class, Tca.getType());
- modelElementClasses.put(Holmes.class, Holmes.getType());
- }
- }
-
- /**
- * Retain data required to parse the ModelElement objects. (Rather than parse
- * them all - parse them on demand if requested.)
- *
- * @param modelName
- * The model name coming form the UI
- * @param controlName
- * The closed loop name coming from the UI
- * @param actionCd
- * Type of operation PUT,UPDATE,DELETE
- * @param isATest
- * The test flag coming from the UI (for validation only, no query are
- * physically executed)
- * @param modelBpmnText
- * The BPMN flow in JSON from the UI
- * @param modelPropText
- * The BPMN parameters for all boxes defined in modelBpmnTest
- */
- public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText,
- String modelPropText) {
- try {
- this.modelName = modelName;
- this.controlName = controlName;
- this.actionCd = actionCd;
- this.testOnly = isATest;
- modelBpmn = ModelBpmn.create(modelBpmnText);
- modelJson = JsonUtils.GSON.fromJson(modelPropText, JsonObject.class);
- instantiateMissingModelElements();
- } catch (JsonParseException e) {
- throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e);
- }
- }
-
- /**
- * This method is meant to ensure that one ModelElement instance exists for each
- * ModelElement class. As new ModelElement classes could have been registered
- * after instantiation of this ModelProperties, we need to build the missing
- * ModelElement instances.
- */
- private void instantiateMissingModelElements() {
- if (modelElementClasses.size() != modelElements.size()) {
- Set<String> missingTypes = new HashSet<>(modelElementClasses.values());
- missingTypes.removeAll(modelElements.keySet());
- // Parse the list of base Model Elements and build up the
- // ModelElements
- modelElementClasses.entrySet().stream().parallel()
- .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
- && missingTypes.contains(entry.getValue())))
- .forEach(entry -> {
- try {
- modelElements.put(entry.getValue(),
- (entry.getKey().getConstructor(ModelBpmn.class, JsonObject.class)
- .newInstance(modelBpmn, modelJson)));
- } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
- | InvocationTargetException e) {
- logger.warn("Unable to instantiate a ModelElement " + entry.getValue()
- + ", exception follows: ", e);
- }
- });
- }
- }
-
- /**
- * Get the VF for a model. If return null if there is no VF.
- *
- * @param model The clds model
- * @return The vf of the model
- */
- public static String getVf(CldsModel model) {
- List<String> vfs = null;
- try {
- JsonObject modelJson = JsonUtils.GSON.fromJson(model.getPropText(), JsonObject.class);
- Global global = new Global(modelJson);
- vfs = global.getResourceVf();
- } catch (JsonParseException e) {
- logger.warn("no VF found", e);
- }
- String vf = null;
- if (vfs != null && !vfs.isEmpty()) {
- vf = vfs.get(0);
- }
- return vf;
- }
-
- /**
- * Create ModelProperties extracted from a CamelExchange.
- *
- * @param camelExchange
- * The camel Exchange object that contains all info provided to the flow
- * @return A model Properties created from the parameters found in camelExchange
- * object
- */
- public static ModelProperties create(Exchange camelExchange) {
- String modelProp = (String) camelExchange.getProperty("modelProp");
- String modelBpmnProp = (String) camelExchange.getProperty("modelBpmnProp");
- String modelName = (String) camelExchange.getProperty("modelName");
- String controlName = (String) camelExchange.getProperty("controlName");
- String actionCd = (String) camelExchange.getProperty("actionCd");
- boolean isTest = (boolean) camelExchange.getProperty("isTest");
- return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp);
- }
-
- /**
- * Get the model name.
- * @return the modelName
- */
- public String getModelName() {
- return modelName;
- }
-
- /**
- * Get the control name.
- * @return the controlName
- */
- public String getControlName() {
- return controlName;
- }
-
- /**
- * Get the control name qnd policy uniqueId.
- * @return the controlNameAndPolicyUniqueId
- */
- public String getControlNameAndPolicyUniqueId() {
- return controlName + "_" + policyUniqueId;
- }
-
- /**
- * Get the current policy name.
- * @return the currentPolicyName
- */
- private String getCurrentPolicyName() {
- return normalizePolicyScopeName(controlName + "_" + currentModelElementId);
- }
-
- private String createScopeSeparator(String policyScope) {
- return policyScope.contains(".") ? "" : ".";
- }
-
- /**
- * Get the current policy scope and policy name.
- * @return the currentPolicyScopeAndPolicyName
- */
- public String getCurrentPolicyScopeAndPolicyName() {
- return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName());
- }
-
- /**
- * Get policy name for dcae deploy.
- * @return The policyName that wil be used in input parameters of DCAE deploy
- */
- public String getPolicyNameForDcaeDeploy(ClampProperties refProp) {
- return normalizePolicyScopeName(modelName + createScopeSeparator(modelName)
- + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
- }
-
- /**
- * Get policy scope and name with uniqueid.
- * @return the policyScopeAndNameWithUniqueId
- */
- public String getPolicyScopeAndNameWithUniqueId() {
- return normalizePolicyScopeName(
- modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_" + policyUniqueId);
- }
-
- /**
- * Get policy scope and name with unique guardid.
- * @return the policyScopeAndNameWithUniqueId
- */
- public String getPolicyScopeAndNameWithUniqueGuardId() {
- return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_"
- + policyUniqueId + POLICY_GUARD_SUFFIX + guardUniqueId);
- }
-
- /**
- * Get current policy scope and full policy name.
- * @return the currentPolicyScopeAndFullPolicyName
- */
- public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) {
- return normalizePolicyScopeName(
- modelName + createScopeSeparator(modelName) + policyNamePrefix + getCurrentPolicyName());
- }
-
- /**
- * Get policy name with scope context.
- * @return the PolicyNameWithScopeContext
- */
- public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context,
- String userDefinedName) {
- return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope
- + "_" + context + "_" + modelName + "_" + userDefinedName);
- }
-
- /**
- * Get policy name with prefix scope context.
- * @return the PolicyNameWithPrefixScopeContext
- */
- public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope,
- String context, String userDefinedName, String policyPrefix) {
- return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType
- + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
- }
-
- /**
- * Replace all '-' with '_' within policy scope and name.
- *
- * @param inName policy scope and name
- * @return policy scope and name with "-" replaced with "_"
- */
- private String normalizePolicyScopeName(String inName) {
- return inName.replaceAll("-", "_");
- }
-
- /**
- * Get current model element id.
- * @return the currentModelElementId
- */
- public String getCurrentModelElementId() {
- return currentModelElementId;
- }
-
- /**
- * When generating a policy request for a model element, must set the id of that
- * model element using this method. Used to generate the policy name.
- *
- * @param currentModelElementId
- * the currentModelElementId to set
- */
- public void setCurrentModelElementId(String currentModelElementId) {
- this.currentModelElementId = currentModelElementId;
- }
-
- /**
- * Get policy uniqueId.
- * @return the policyUniqueId
- */
- public String getPolicyUniqueId() {
- return policyUniqueId;
- }
-
- public String getGuardUniqueId() {
- return guardUniqueId;
- }
-
- public void setGuardUniqueId(String guardUniqueId) {
- this.guardUniqueId = guardUniqueId;
- }
-
- /**
- * When generating a policy request for a model element, must set the unique id
- * of that policy using this method. Used to generate the policy name.
- *
- * @param policyUniqueId
- * the policyUniqueId to set
- */
- public void setPolicyUniqueId(String policyUniqueId) {
- this.policyUniqueId = policyUniqueId;
- }
-
- /**
- * Get actioncd.
- * @return the actionCd
- */
- public String getActionCd() {
- return actionCd;
- }
-
- /**
- * Get the testOnly flag value.
- * @return the testOnly
- */
- public boolean isTestOnly() {
- return testOnly;
- }
-
- /**
- * Get the global value.
- * @return the global
- */
- public Global getGlobal() {
- if (global == null) {
- global = new Global(modelJson);
- }
- return global;
- }
-
- /**
- * Registers model element.
- *
- * @param modelElementClass model element class
- * @param type model element type
- */
- public static final synchronized void registerModelElement(Class<? extends AbstractModelElement> modelElementClass,
- String type) {
- if (!modelElementClasses.containsKey(modelElementClass.getClass())) {
- modelElementClasses.put(modelElementClass, type);
- }
- }
-
- public <T extends AbstractModelElement> T getType(Class<T> clazz) {
- instantiateMissingModelElements();
- String type = modelElementClasses.get(clazz);
- return (type != null ? (T) modelElements.get(type) : null);
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
deleted file mode 100644
index 9537cb9e..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-/**
- * Parse Policy json properties.
- * Example json:
- * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
- * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
- * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
- * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
- * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
- * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
- * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
- * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
- * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
- * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
- * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
- * "vf3RtPi"]}]]}]
- */
-public class Policy extends AbstractModelElement {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private List<PolicyChain> policyChains;
-
- private static final String TYPE_POLICY = "policy";
-
- /**
- * Parse Policy given json node.
- *
- * @param modelBpmn The model bpmn
- * @param modelJson The model json
- * @throws IOException The IO Exception
- */
- public Policy(ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
- super(TYPE_POLICY, modelBpmn, modelJson);
-
- // process policies
- if (modelElementJsonNode != null) {
- Iterator<Entry<String, JsonElement>> itr = modelElementJsonNode.getAsJsonObject().entrySet().iterator();
- policyChains = new ArrayList<>();
- while (itr.hasNext()) {
- policyChains.add(new PolicyChain(itr.next().getValue()));
- }
- }
- }
-
- /**
- * Get the policy chains.
- *
- * @return the policyChains
- */
- public List<PolicyChain> getPolicyChains() {
- return policyChains;
- }
-
- public static final String getType() {
- return TYPE_POLICY;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java
deleted file mode 100644
index ba6abd86..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse Policy json properties.
- * Example json:
- * {"Policy_1e33tn8":{"PolicyTest1":[{"name":"pname","value":"PolicyTest1"},{
- * "name":"pid","value":"1"},{"name":"timeout","value":"345"},{
- * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":
- * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name"
- * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name":
- * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":
- * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name":
- * "parentPolicy","value":[""]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}],
- * "PolicyTest2":[{"name":"pname","value":
- * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{
- * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":
- * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name"
- * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name":
- * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":
- * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name":
- * "parentPolicy","value":[""]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]}} f
- *
- */
-public class PolicyChain {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private String policyId;
- private Integer timeout;
- private List<PolicyItem> policyItems;
- private String policyType;
-
- /**
- * Constructor.
- * @param node The policy element in JsonElement format
- * @throws IOException The IO Exception
- */
- public PolicyChain(JsonElement node) throws IOException {
- if (node != null && node.isJsonArray() && node.getAsJsonArray().size() > 0) {
- policyId = JsonUtils.getStringValueByName(node, "pid");
- timeout = JsonUtils.getIntValueByName(node, "timeout");
- policyType = JsonUtils.getStringValueByName(node, "policyType");
- JsonArray operationalPolicyParameters = node.getAsJsonArray();
-
- JsonArray policyConfigurations = operationalPolicyParameters.get(operationalPolicyParameters.size() - 1)
- .getAsJsonObject()
- .get("policyConfigurations")
- .getAsJsonArray();
- Iterator<JsonElement> itr = policyConfigurations.iterator();
- policyItems = new ArrayList<>();
- while (itr.hasNext()) {
- policyItems.add(new PolicyItem(itr.next()));
-
- }
- }
- }
- /**
- * Get the policy Id.
- * @return the policyId
- */
- public String getPolicyId() {
- return policyId;
- }
-
- /**
- * Get the time out.
- * @return the timeout
- */
- public Integer getTimeout() {
- return timeout;
- }
-
- /**
- * Get the policy items.
- * @return the policyItems
- */
- public List<PolicyItem> getPolicyItems() {
- return policyItems;
- }
-
- /**
- * Get the policy type.
- * @return the policyType
- */
- public String getPolicyType() {
- return policyType;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
deleted file mode 100644
index 18554687..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonElement;
-import com.google.gson.reflect.TypeToken;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.clamp.clds.util.JsonUtils;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Parse policyConfigurations from Policy json properties.
- * Example json:
- * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
- * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
- * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
- * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
- * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
- * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
- * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
- * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
- * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
- * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
- * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
- * "vf3RtPi"]},{"name":
- * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]
- */
-public class PolicyItem implements Cloneable {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private String id;
- private String recipe;
- private int maxRetries;
- private int retryTimeLimit;
- private String parentPolicy;
- private List<String> parentPolicyConditions;
- private String actor;
- private String targetResourceId;
- private String recipeInfo;
- private String recipeLevel;
- private String recipeInput;
- private Map<String, String> recipePayload;
- private String oapRop;
- private String oapLimit;
-
- private String enableGuardPolicy;
- private String guardPolicyType;
- private String guardTargets;
- private String minGuard;
- private String maxGuard;
- private String limitGuard;
- private String timeUnitsGuard;
- private String timeWindowGuard;
- private String guardActiveStart;
- private String guardActiveEnd;
-
- /**
- * Parse Policy given JSON node.
- *
- * @param item policy in JSON format
- * @throws IOException IO exception
- */
- public PolicyItem(JsonElement item) throws IOException {
- id = JsonUtils.getStringValueByName(item, "_id");
- recipe = JsonUtils.getStringValueByName(item, "recipe");
- maxRetries = JsonUtils.getIntValueByName(item, "maxRetries");
- retryTimeLimit = JsonUtils.getIntValueByName(item, "retryTimeLimit");
- parentPolicy = JsonUtils.getStringValueByName(item, "parentPolicy");
- parentPolicyConditions = JsonUtils.getStringValuesByName(item, "parentPolicyConditions");
- targetResourceId = JsonUtils.getStringValueByName(item, "targetResourceId");
- if (targetResourceId != null && targetResourceId.isEmpty()) {
- this.setTargetResourceId(null);
- }
- recipeInfo = JsonUtils.getStringValueByName(item, "recipeInfo");
- recipeLevel = JsonUtils.getStringValueByName(item, "recipeLevel");
- recipeInput = JsonUtils.getStringValueByName(item, "recipeInput");
- String payload = JsonUtils.getStringValueByName(item, "recipePayload");
-
- if (payload != null && !payload.isEmpty()) {
- if (payload.trim().startsWith("{") && payload.trim().endsWith("}")) {
- // Seems to be a JSON
- recipePayload = JsonUtils.GSON.fromJson(payload, new TypeToken<Map<String, String>>() {}.getType());
- } else {
- // SHould be a YAML then
- recipePayload = new Yaml().load(payload);
- }
- }
- oapRop = JsonUtils.getStringValueByName(item, "oapRop");
- oapLimit = JsonUtils.getStringValueByName(item, "oapLimit");
- actor = JsonUtils.getStringValueByName(item, "actor");
-
- enableGuardPolicy = JsonUtils.getStringValueByName(item, "enableGuardPolicy");
- guardPolicyType = JsonUtils.getStringValueByName(item, "guardPolicyType");
- guardTargets = JsonUtils.getStringValueByName(item, "guardTargets");
- minGuard = JsonUtils.getStringValueByName(item, "minGuard");
- maxGuard = JsonUtils.getStringValueByName(item, "maxGuard");
- limitGuard = JsonUtils.getStringValueByName(item, "limitGuard");
- timeUnitsGuard = JsonUtils.getStringValueByName(item, "timeUnitsGuard");
- timeWindowGuard = JsonUtils.getStringValueByName(item, "timeWindowGuard");
- guardActiveStart = JsonUtils.getStringValueByName(item, "guardActiveStart");
- guardActiveEnd = JsonUtils.getStringValueByName(item, "guardActiveEnd");
- }
-
- /**
- * Get the id.
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Get the recipe.
- * @return the recipe
- */
- public String getRecipe() {
- return recipe;
- }
-
- /**
- * Set the id.
- * @param the id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Set the recipe.
- * @param the recipe
- */
- public void setRecipe(String recipe) {
- this.recipe = recipe;
- }
-
- /**
- * Set the parent policy.
- * @param the parentPolicy
- */
- public void setParentPolicy(String parentPolicy) {
- this.parentPolicy = parentPolicy;
- }
-
- /**
- * Set the max retries.
- * @param the maxRetries
- */
- public void setMaxRetries(int maxRetries) {
- this.maxRetries = maxRetries;
- }
-
- /**
- * Set the retry time limit.
- * @param the retryTimeLimit
- */
- public void setRetryTimeLimit(int retryTimeLimit) {
- this.retryTimeLimit = retryTimeLimit;
- }
-
- /**
- * Set the parent policy conditions.
- * @param the parentPolicyConditions
- */
- public void setParentPolicyConditions(List<String> parentPolicyConditions) {
- this.parentPolicyConditions = parentPolicyConditions;
- }
-
- /**
- * Get the max retires.
- * @return the maxRetries
- */
- public int getMaxRetries() {
- return maxRetries;
- }
-
- /**
- * Get the retry time limit.
- * @return the retryTimeLimit
- */
- public int getRetryTimeLimit() {
- return retryTimeLimit;
- }
-
- /**
- * Get the parent policy.
- * @return the parentPolicy
- */
- public String getParentPolicy() {
- return parentPolicy;
- }
-
- /**
- * Get the list of parent policy conditions.
- * @return the parentPolicyConditions
- */
- public List<String> getParentPolicyConditions() {
- return parentPolicyConditions;
- }
-
- /**
- * Get the actor.
- * @return the actor
- */
- public String getActor() {
- return actor;
- }
-
- /**
- * Set the actor.
- * @param the actor
- */
- public void setActor(String actor) {
- this.actor = actor;
- }
-
- public String getTargetResourceId() {
- return targetResourceId;
- }
-
- public void setTargetResourceId(String targetResourceId) {
- this.targetResourceId = targetResourceId;
- }
-
- public String getRecipeInfo() {
- return recipeInfo;
- }
-
- public String getRecipeLevel() {
- return recipeLevel;
- }
-
- public String getRecipeInput() {
- return recipeInput;
- }
-
- public Map<String, String> getRecipePayload() {
- return recipePayload;
- }
-
- /**
- * Get oap rop.
- * @return The oap rop?
- */
- public String getOapRop() {
- if (oapRop == null) {
- oapRop = "0m";
- }
- return oapRop;
- }
-
- /**
- * Get oap limit.
- * @return the oap limit
- */
- public String getOapLimit() {
- if (oapLimit == null) {
- oapLimit = "0";
- }
- return oapLimit;
- }
-
- public String getEnableGuardPolicy() {
- return enableGuardPolicy;
- }
-
- public String getGuardPolicyType() {
- return guardPolicyType;
- }
-
- public String getGuardTargets() {
- return guardTargets;
- }
-
- public String getMinGuard() {
- return minGuard;
- }
-
- public String getMaxGuard() {
- return maxGuard;
- }
-
- public String getLimitGuard() {
- return limitGuard;
- }
-
- public String getTimeUnitsGuard() {
- return timeUnitsGuard;
- }
-
- public String getTimeWindowGuard() {
- return timeWindowGuard;
- }
-
- public String getGuardActiveStart() {
- return guardActiveStart;
- }
-
- public String getGuardActiveEnd() {
- return guardActiveEnd;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
deleted file mode 100644
index efa0188e..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Parse ONAP Tca json properties.
- */
-public class Tca extends AbstractModelElement {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private TcaItem tcaItem;
-
- private static final String TYPE_TCA = "tca";
-
- /**
- * Parse Tca given json node.
- *
- * @param modelBpmn The model bpmn
- * @param modelJson The model json
- */
- public Tca(ModelBpmn modelBpmn, JsonObject modelJson) {
- super(TYPE_TCA, modelBpmn, modelJson);
-
- // process Server_Configurations
- if (modelElementJsonNode != null) {
- //this is wrong assumption that there is only one property object
- Set<Entry<String, JsonElement>> entries = modelElementJsonNode.getAsJsonObject().entrySet();
- tcaItem = new TcaItem(entries.iterator().next().getValue());
- }
- }
-
- public TcaItem getTcaItem() {
- return tcaItem;
- }
-
- public static final String getType() {
- return TYPE_TCA;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java
deleted file mode 100644
index 94361c70..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * Parse ONAP Tca Item json properties.
- *
- */
-public class TcaItem {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private String tcaName;
- private String tcaUuId;
- private String policyId;
- private String eventName;
- private String controlLoopSchemaType;
- private List<TcaThreshold> tcaThresholds;
-
- /**
- * Parse Tca Item given json node.
- *
- * @param tcaJson The tac json
- */
- public TcaItem(JsonElement tcaJson) {
-
- tcaName = JsonUtils.getStringValueByName(tcaJson, "tname");
- tcaUuId = JsonUtils.getStringValueByName(tcaJson, "tuuid");
- policyId = JsonUtils.getStringValueByName(tcaJson, "tcaPolId");
- eventName = JsonUtils.getStringValueByName(tcaJson, "eventName");
- controlLoopSchemaType = JsonUtils.getStringValueByName(tcaJson, "controlLoopSchemaType");
- // process service Configurations
- JsonArray tcaConfigurationArray = tcaJson.getAsJsonArray();
- JsonArray serviceConfigurationsNode = tcaConfigurationArray.get(tcaConfigurationArray.size() - 1)
- .getAsJsonObject().get("serviceConfigurations").getAsJsonArray();
- Iterator<JsonElement> itr = serviceConfigurationsNode.iterator();
- tcaThresholds = new ArrayList<>();
- while (itr.hasNext()) {
- tcaThresholds.add(new TcaThreshold(itr.next().getAsJsonArray()));
- }
- }
-
- public String getControlLoopSchemaType() {
- return controlLoopSchemaType;
- }
-
- public void setControlLoopSchemaType(String controlLoopSchemaType) {
- this.controlLoopSchemaType = controlLoopSchemaType;
- }
-
- public String getTcaName() {
- return tcaName;
- }
-
- public void setTcaName(String tcaName) {
- this.tcaName = tcaName;
- }
-
- public String getTcaUuId() {
- return tcaUuId;
- }
-
- public void setTcaUuId(String tcaUuId) {
- this.tcaUuId = tcaUuId;
- }
-
- public String getPolicyId() {
- return policyId;
- }
-
- public void setPolicyId(String policyId) {
- this.policyId = policyId;
- }
-
- public List<TcaThreshold> getTcaThresholds() {
- return tcaThresholds;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public void setEventName(String eventName) {
- this.eventName = eventName;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java
deleted file mode 100644
index 8c69f48b..00000000
--- a/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.properties;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonArray;
-
-/**
- * Parse ONAP Tca Threshold json properties.
- *
- */
-public class TcaThreshold {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaThreshold.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-
- private String fieldPath;
- private String operator;
- private Integer threshold;
- private String closedLoopEventStatus;
-
- /**
- * Parse Tca Threshhold given json node.
- *
- * @param tcaTresholdConfiguration The tca threshold in JsonArray format
- */
- public TcaThreshold(JsonArray tcaTresholdConfiguration) {
-
- if (tcaTresholdConfiguration.get(0) != null) {
- fieldPath = tcaTresholdConfiguration.get(0).getAsString();
- }
- if (tcaTresholdConfiguration.get(1) != null) {
- operator = tcaTresholdConfiguration.get(1).getAsString();
- }
- if (tcaTresholdConfiguration.get(2) != null) {
- threshold = Integer.valueOf(tcaTresholdConfiguration.get(2).getAsString());
- }
- if (tcaTresholdConfiguration.get(3) != null) {
- closedLoopEventStatus = tcaTresholdConfiguration.get(3).getAsString();
- }
- }
-
- public String getFieldPath() {
- return fieldPath;
- }
-
- public void setFieldPath(String fieldPath) {
- this.fieldPath = fieldPath;
- }
-
- public String getOperator() {
- return operator;
- }
-
- public void setOperator(String operator) {
- this.operator = operator;
- }
-
- public Integer getThreshold() {
- return threshold;
- }
-
- public void setThreshold(Integer threshold) {
- this.threshold = threshold;
- }
-
- public String getClosedLoopEventStatus() {
- return closedLoopEventStatus;
- }
-
- public void setClosedLoopEventStatus(String closedLoopEventStatus) {
- this.closedLoopEventStatus = closedLoopEventStatus;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java b/src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java
deleted file mode 100644
index 300c8b13..00000000
--- a/src/main/java/org/onap/clamp/clds/model/status/StatusHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.status;
-
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-
-/**
- * This interface describe the handler of the status in CldsModel, it's normally
- * based on the last event stored in db.
- *
- */
-public interface StatusHandler {
-
- /**
- * This method determines the status of the closed loop based on the last event.
- *
- * @param event
- * The last event
- * @return The status
- */
- default String determineStatusOnLastEvent(CldsEvent event) {
- String status = CldsModel.STATUS_UNKNOWN;
- if (event == null || event.getActionCd() == null) {
- status = CldsModel.STATUS_DESIGN;
- } else if (event.isActionStateCd(CldsEvent.ACTION_STATE_ERROR)) {
- status = CldsModel.STATUS_ERROR;
- } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY)) {
- status = CldsModel.STATUS_DESIGN;
- } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED)
- || event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_COMPLETED)
- || event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_COMPLETED)
- || event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_COMPLETED)) {
- status = CldsModel.STATUS_DISTRIBUTED;
- } else if (event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_SENT)) {
- status = CldsModel.STATUS_DELETING;
- } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_COMPLETED)
- || event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED)
- || event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_COMPLETED)
- || event.isActionAndStateCd(CldsEvent.ACTION_SUBMITPOLICY, CldsEvent.ACTION_STATE_ANY)) {
- status = CldsModel.STATUS_ACTIVE;
- } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_COMPLETED)) {
- status = CldsModel.STATUS_STOPPED;
- }
- return status;
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java b/src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java
deleted file mode 100644
index b539e905..00000000
--- a/src/main/java/org/onap/clamp/clds/model/status/StatusHandlerImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.status;
-
-public class StatusHandlerImpl implements StatusHandler {
-}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java b/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
index 1b0cca60..f1679168 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
@@ -27,10 +27,10 @@ import com.att.eelf.configuration.EELFManager;
import java.util.Date;
-import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsHealthCheck;
import org.onap.clamp.clds.util.LoggingUtils;
import org.onap.clamp.clds.util.ONAPLogConstants;
+import org.onap.clamp.loop.LoopController;
import org.slf4j.event.Level;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -45,7 +45,7 @@ import org.springframework.stereotype.Component;
public class CldsHealthcheckService {
@Autowired
- private CldsDao cldsDao;
+ private LoopController loopController;
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsHealthcheckService.class);
@@ -62,7 +62,7 @@ public class CldsHealthcheckService {
LoggingUtils.setTimeContext(startTime, new Date());
boolean healthcheckFailed = false;
try {
- cldsDao.doHealthCheck();
+ loopController.getLoopNames();
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("UP");
cldsHealthCheck.setDescription("OK");
@@ -79,11 +79,10 @@ public class CldsHealthcheckService {
LoggingUtils.setTimeContext(startTime, new Date());
if (healthcheckFailed) {
util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Healthcheck failed", Level.INFO,
- ONAPLogConstants.ResponseStatus.ERROR);
+ ONAPLogConstants.ResponseStatus.ERROR);
return new ResponseEntity<>(cldsHealthCheck, HttpStatus.INTERNAL_SERVER_ERROR);
} else {
- util.exiting("200", "Healthcheck failed", Level.INFO,
- ONAPLogConstants.ResponseStatus.COMPLETED);
+ util.exiting("200", "Healthcheck failed", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
return new ResponseEntity<>(cldsHealthCheck, HttpStatus.OK);
}
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
index ea4e097f..f5c21c13 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
@@ -29,13 +29,9 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
import org.json.JSONArray;
import org.json.JSONObject;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsDictionaryItem;
import org.yaml.snakeyaml.Yaml;
/**
@@ -45,15 +41,10 @@ import org.yaml.snakeyaml.Yaml;
*/
public class ToscaYamlToJsonConvertor {
- private CldsDao cldsDao;
private int simpleTypeOrder = 1000;
private int complexTypeOrder = 10000;
private int complexSimpleTypeOrder = 1;
- public ToscaYamlToJsonConvertor(CldsDao cldsDao) {
- this.cldsDao = cldsDao;
- }
-
private int incrementSimpleTypeOrder() {
return simpleTypeOrder++;
}
@@ -68,24 +59,6 @@ public class ToscaYamlToJsonConvertor {
}
/**
- * Returns the CldsDao.
- *
- * @return the cldsDao
- */
- public CldsDao getCldsDao() {
- return cldsDao;
- }
-
- /**
- * Sets the CldsDao.
- *
- * @param cldsDao the cldsDao to set
- */
- public void setCldsDao(CldsDao cldsDao) {
- this.cldsDao = cldsDao;
- }
-
- /**
* Parses Tosca YAML string.
*
* @param yamlString YAML string
@@ -115,7 +88,7 @@ public class ToscaYamlToJsonConvertor {
// Parse node_type and data_type
@SuppressWarnings("unchecked")
private void parseNodeAndDataType(LinkedHashMap<String, Object> map, LinkedHashMap<String, Object> nodeTypes,
- LinkedHashMap<String, Object> dataNodes) {
+ LinkedHashMap<String, Object> dataNodes) {
map.entrySet().stream().forEach(n -> {
if (n.getKey().contains(ToscaSchemaConstants.NODE_TYPES) && n.getValue() instanceof Map) {
parseNodeAndDataType((LinkedHashMap<String, Object>) n.getValue(), nodeTypes, dataNodes);
@@ -132,7 +105,7 @@ public class ToscaYamlToJsonConvertor {
@SuppressWarnings("unchecked")
private void populateJsonEditorObject(LinkedHashMap<String, Object> map, LinkedHashMap<String, Object> nodeTypes,
- LinkedHashMap<String, Object> dataNodes, JSONObject jsonParentObject, JSONObject jsonTempObject) {
+ LinkedHashMap<String, Object> dataNodes, JSONObject jsonParentObject, JSONObject jsonTempObject) {
Map<String, JSONObject> jsonEntrySchema = new HashMap();
jsonParentObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_OBJECT);
@@ -143,49 +116,53 @@ public class ToscaYamlToJsonConvertor {
JSONArray rootNodeArray = new JSONArray();
if (ntElement.getValue() instanceof Map) {
((LinkedHashMap<String, Object>) ntElement.getValue()).entrySet()
- .forEach((ntPropertiesElement) -> {
- boolean isListNode = false;
- parseDescription((LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
- jsonParentObject);
- LinkedHashMap<String, Object> parentPropertiesMap =
- (LinkedHashMap<String, Object>) ntPropertiesElement.getValue();
- if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
- && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
- .contains(ToscaSchemaConstants.TYPE_MAP)
- && parentPropertiesMap.containsKey(ToscaSchemaConstants.ENTRY_SCHEMA)) {
- parentPropertiesMap = (LinkedHashMap<String, Object>) parentPropertiesMap
- .get(ToscaSchemaConstants.ENTRY_SCHEMA);
- isListNode = true;
- }
- if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
- && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
- .contains(ToscaSchemaConstants.POLICY_DATA)) {
- ((LinkedHashMap<String, Object>) dataNodes
- .get(parentPropertiesMap.get(ToscaSchemaConstants.TYPE))).entrySet()
- .stream().forEach(pmap -> {
- if (pmap.getKey()
- .equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
- parseToscaProperties(ToscaSchemaConstants.POLICY_NODE,
- (LinkedHashMap<String, Object>) pmap.getValue(),
- jsonParentObject, rootNodeArray, jsonEntrySchema, dataNodes,
- incrementSimpleTypeOrder());
- }
-
- });
-
- }
- if (isListNode) {
- jsonTempObject.put(JsonEditorSchemaConstants.TYPE,
- JsonEditorSchemaConstants.TYPE_ARRAY);
+ .forEach((ntPropertiesElement) -> {
+ boolean isListNode = false;
parseDescription((LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
- jsonTempObject);
- jsonTempObject.put(JsonEditorSchemaConstants.ITEMS, jsonParentObject);
- jsonTempObject.put(JsonEditorSchemaConstants.FORMAT,
- JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
- jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
- JsonEditorSchemaConstants.TRUE);
- }
- });
+ jsonParentObject);
+ LinkedHashMap<String, Object> parentPropertiesMap = (LinkedHashMap<String, Object>) ntPropertiesElement
+ .getValue();
+ if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
+ && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
+ .contains(ToscaSchemaConstants.TYPE_MAP)
+ && parentPropertiesMap.containsKey(ToscaSchemaConstants.ENTRY_SCHEMA)) {
+ parentPropertiesMap = (LinkedHashMap<String, Object>) parentPropertiesMap
+ .get(ToscaSchemaConstants.ENTRY_SCHEMA);
+ isListNode = true;
+ }
+ if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
+ && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
+ .contains(ToscaSchemaConstants.POLICY_DATA)) {
+ ((LinkedHashMap<String, Object>) dataNodes
+ .get(parentPropertiesMap.get(ToscaSchemaConstants.TYPE))).entrySet()
+ .stream().forEach(pmap -> {
+ if (pmap.getKey().equalsIgnoreCase(
+ ToscaSchemaConstants.PROPERTIES)) {
+ parseToscaProperties(
+ ToscaSchemaConstants.POLICY_NODE,
+ (LinkedHashMap<String, Object>) pmap
+ .getValue(),
+ jsonParentObject, rootNodeArray,
+ jsonEntrySchema, dataNodes,
+ incrementSimpleTypeOrder());
+ }
+
+ });
+
+ }
+ if (isListNode) {
+ jsonTempObject.put(JsonEditorSchemaConstants.TYPE,
+ JsonEditorSchemaConstants.TYPE_ARRAY);
+ parseDescription(
+ (LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
+ jsonTempObject);
+ jsonTempObject.put(JsonEditorSchemaConstants.ITEMS, jsonParentObject);
+ jsonTempObject.put(JsonEditorSchemaConstants.FORMAT,
+ JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
+ jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
+ JsonEditorSchemaConstants.TRUE);
+ }
+ });
}
}
});
@@ -195,8 +172,8 @@ public class ToscaYamlToJsonConvertor {
@SuppressWarnings("unchecked")
private void parseToscaProperties(String parentKey, LinkedHashMap<String, Object> propertiesMap,
- JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
- LinkedHashMap<String, Object> dataNodes, final int order) {
+ JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
+ LinkedHashMap<String, Object> dataNodes, final int order) {
JSONObject jsonPropertyNode = new JSONObject();
propertiesMap.entrySet().stream().forEach(p -> {
// Populate JSON Array for "required" key
@@ -204,12 +181,12 @@ public class ToscaYamlToJsonConvertor {
if (p.getValue() instanceof Map) {
LinkedHashMap<String, Object> nodeMap = (LinkedHashMap<String, Object>) p.getValue();
if (nodeMap.containsKey(ToscaSchemaConstants.REQUIRED)
- && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
+ && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
array.put(p.getKey());
}
// if(nodeMap.containsKey(ToscaSchemaConstants.CONSTRAINTS))
parseToscaChildNodeMap(p.getKey(), nodeMap, jsonPropertyNode, jsonEntrySchema, dataNodes, array,
- incrementSimpleTypeOrder());
+ incrementSimpleTypeOrder());
}
});
jsonDataNode.put(JsonEditorSchemaConstants.REQUIRED, array);
@@ -218,8 +195,8 @@ public class ToscaYamlToJsonConvertor {
@SuppressWarnings("unchecked")
private void parseToscaPropertiesForType(String parentKey, LinkedHashMap<String, Object> propertiesMap,
- JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
- LinkedHashMap<String, Object> dataNodes, boolean isType, int order) {
+ JSONObject jsonDataNode, JSONArray array, Map<String, JSONObject> jsonEntrySchema,
+ LinkedHashMap<String, Object> dataNodes, boolean isType, int order) {
JSONObject jsonPropertyNode = new JSONObject();
propertiesMap.entrySet().stream().forEach(p -> {
@@ -228,13 +205,14 @@ public class ToscaYamlToJsonConvertor {
if (p.getValue() instanceof Map) {
LinkedHashMap<String, Object> nodeMap = (LinkedHashMap<String, Object>) p.getValue();
if (!(parentKey.contains(ToscaSchemaConstants.ENTRY_SCHEMA)
- || parentKey.contains(ToscaSchemaConstants.POLICY_NODE))
- && nodeMap.containsKey(ToscaSchemaConstants.TYPE)
- && (((String) nodeMap.get(ToscaSchemaConstants.TYPE)).contains(ToscaSchemaConstants.POLICY_DATA))) {
+ || parentKey.contains(ToscaSchemaConstants.POLICY_NODE))
+ && nodeMap.containsKey(ToscaSchemaConstants.TYPE)
+ && (((String) nodeMap.get(ToscaSchemaConstants.TYPE))
+ .contains(ToscaSchemaConstants.POLICY_DATA))) {
overWriteArray = true;
}
if (nodeMap.containsKey(ToscaSchemaConstants.REQUIRED)
- && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
+ && ((boolean) nodeMap.get(ToscaSchemaConstants.REQUIRED))) {
array.put(p.getKey());
}
parseToscaChildNodeMap(p.getKey(), nodeMap, jsonPropertyNode, jsonEntrySchema, dataNodes, array, order);
@@ -245,8 +223,8 @@ public class ToscaYamlToJsonConvertor {
}
private void parseToscaChildNodeMap(String childObjectKey, LinkedHashMap<String, Object> childNodeMap,
- JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes,
- JSONArray array, int order) {
+ JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema,
+ LinkedHashMap<String, Object> dataNodes, JSONArray array, int order) {
JSONObject childObject = new JSONObject();
// JSONArray childArray = new JSONArray();
parseDescription(childNodeMap, childObject);
@@ -260,11 +238,12 @@ public class ToscaYamlToJsonConvertor {
}
private void parseEntrySchema(LinkedHashMap<String, Object> childNodeMap, JSONObject childObject,
- JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes) {
+ JSONObject jsonPropertyNode, Map<String, JSONObject> jsonEntrySchema,
+ LinkedHashMap<String, Object> dataNodes) {
if (childNodeMap.get(ToscaSchemaConstants.ENTRY_SCHEMA) != null) {
if (childNodeMap.get(ToscaSchemaConstants.ENTRY_SCHEMA) instanceof Map) {
LinkedHashMap<String, Object> entrySchemaMap = (LinkedHashMap<String, Object>) childNodeMap
- .get(ToscaSchemaConstants.ENTRY_SCHEMA);
+ .get(ToscaSchemaConstants.ENTRY_SCHEMA);
entrySchemaMap.entrySet().stream().forEach(entry -> {
if (entry.getKey().equalsIgnoreCase(ToscaSchemaConstants.TYPE) && entry.getValue() != null) {
String entrySchemaType = (String) entry.getValue();
@@ -274,33 +253,34 @@ public class ToscaYamlToJsonConvertor {
// Already traversed
JSONObject entrySchemaObject = jsonEntrySchema.get(entrySchemaType);
attachEntrySchemaJsonObject(childObject, entrySchemaObject,
- JsonEditorSchemaConstants.TYPE_OBJECT);
+ JsonEditorSchemaConstants.TYPE_OBJECT);
} else if (dataNodes.containsKey(entrySchemaType)) {
JSONObject entrySchemaObject = new JSONObject();
// Need to traverse
((LinkedHashMap<String, Object>) dataNodes.get(entrySchemaType)).entrySet().stream()
- .forEach(pmap -> {
- if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
- parseToscaProperties(ToscaSchemaConstants.ENTRY_SCHEMA,
- (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject,
- array, jsonEntrySchema, dataNodes, incrementComplexTypeOrder());
- jsonEntrySchema.put(entrySchemaType, entrySchemaObject);
- dataNodes.remove(entrySchemaType);
- attachEntrySchemaJsonObject(childObject, entrySchemaObject,
- JsonEditorSchemaConstants.TYPE_OBJECT);
- }
-
- });
+ .forEach(pmap -> {
+ if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
+ parseToscaProperties(ToscaSchemaConstants.ENTRY_SCHEMA,
+ (LinkedHashMap<String, Object>) pmap.getValue(),
+ entrySchemaObject, array, jsonEntrySchema, dataNodes,
+ incrementComplexTypeOrder());
+ jsonEntrySchema.put(entrySchemaType, entrySchemaObject);
+ dataNodes.remove(entrySchemaType);
+ attachEntrySchemaJsonObject(childObject, entrySchemaObject,
+ JsonEditorSchemaConstants.TYPE_OBJECT);
+ }
+
+ });
}
} else if (entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)
- || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
- || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
+ || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
+ || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
JSONObject entrySchemaObject = new JSONObject();
parseConstraints(entrySchemaMap, entrySchemaObject);
String jsontype = JsonEditorSchemaConstants.TYPE_STRING;
if (entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)
- || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
+ || entrySchemaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_FLOAT)) {
jsontype = JsonEditorSchemaConstants.TYPE_INTEGER;
}
if (childNodeMap.get(ToscaSchemaConstants.TYPE) != null) {
@@ -310,7 +290,7 @@ public class ToscaYamlToJsonConvertor {
if (typeValue.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) {
// Custom key for JSON Editor and UI rendering
childObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT,
- JsonEditorSchemaConstants.FORMAT_SELECT);
+ JsonEditorSchemaConstants.FORMAT_SELECT);
// childObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS,
// JsonEditorSchemaConstants.TRUE);
}
@@ -352,7 +332,8 @@ public class ToscaYamlToJsonConvertor {
}
private void parseTypes(String childObjectKey, LinkedHashMap<String, Object> childNodeMap, JSONObject childObject,
- Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes, JSONArray array, int order) {
+ Map<String, JSONObject> jsonEntrySchema, LinkedHashMap<String, Object> dataNodes, JSONArray array,
+ int order) {
if (childNodeMap.get(ToscaSchemaConstants.TYPE) != null) {
// Only known value of type is String for now
if (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String) {
@@ -367,7 +348,7 @@ public class ToscaYamlToJsonConvertor {
childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_ARRAY);
// Custom key for JSON Editor and UI rendering
childObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT,
- JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
+ JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP);
childObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS, JsonEditorSchemaConstants.TRUE);
} else if (typeValue.equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP)) {
childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_OBJECT);
@@ -388,10 +369,10 @@ public class ToscaYamlToJsonConvertor {
((LinkedHashMap<String, Object>) pmap.getValue()).entrySet().stream().forEach(p -> {
if (p.getValue() instanceof Map) {
LinkedHashMap<String, Object> childNodeMap2 = (LinkedHashMap<String, Object>) p
- .getValue();
+ .getValue();
if (childNodeMap2.containsKey(ToscaSchemaConstants.TYPE)
- && (((String) childNodeMap2.get(ToscaSchemaConstants.TYPE))
- .contains(ToscaSchemaConstants.POLICY_DATA))) {
+ && (((String) childNodeMap2.get(ToscaSchemaConstants.TYPE))
+ .contains(ToscaSchemaConstants.POLICY_DATA))) {
}
}
});
@@ -400,8 +381,8 @@ public class ToscaYamlToJsonConvertor {
((LinkedHashMap<String, Object>) dataNodes.get(typeValue)).entrySet().stream().forEach(pmap -> {
if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
parseToscaPropertiesForType(childObjectKey,
- (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject, childArray,
- jsonEntrySchema, dataNodes, true, incrementComplexSimpleTypeOrder());
+ (LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject, childArray,
+ jsonEntrySchema, dataNodes, true, incrementComplexSimpleTypeOrder());
jsonEntrySchema.put(typeValue, entrySchemaObject);
dataNodes.remove(typeValue);
attachTypeJsonObject(childObject, entrySchemaObject);
@@ -420,32 +401,32 @@ public class ToscaYamlToJsonConvertor {
private void parseConstraints(LinkedHashMap<String, Object> childNodeMap, JSONObject childObject) {
if (childNodeMap.containsKey(ToscaSchemaConstants.CONSTRAINTS)
- && childNodeMap.get(ToscaSchemaConstants.CONSTRAINTS) != null) {
+ && childNodeMap.get(ToscaSchemaConstants.CONSTRAINTS) != null) {
List<LinkedHashMap<String, Object>> constraintsList = (List<LinkedHashMap<String, Object>>) childNodeMap
- .get(ToscaSchemaConstants.CONSTRAINTS);
+ .get(ToscaSchemaConstants.CONSTRAINTS);
constraintsList.stream().forEach(c -> {
if (c instanceof Map) {
c.entrySet().stream().forEach(constraint -> {
if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.MIN_LENGTH)
- || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.GREATER_OR_EQUAL)) {
+ || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.GREATER_OR_EQUAL)) {
// For String min_lenghth is minimum length whereas for number, it will be
// minimum or greater than to the defined value
if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
- && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
- && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
- .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+ && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+ .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, constraint.getValue());
} else {
childObject.put(JsonEditorSchemaConstants.MINIMUM, constraint.getValue());
}
} else if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.MAX_LENGTH)
- || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.LESS_OR_EQUAL)) {
+ || constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.LESS_OR_EQUAL)) {
// For String max_lenghth is maximum length whereas for number, it will be
// maximum or less than the defined value
if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
- && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
- && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
- .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+ && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+ .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
childObject.put(JsonEditorSchemaConstants.MAX_LENGTH, constraint.getValue());
} else {
childObject.put(JsonEditorSchemaConstants.MAXIMUM, constraint.getValue());
@@ -457,18 +438,18 @@ public class ToscaYamlToJsonConvertor {
} else if (constraint.getKey().equalsIgnoreCase(ToscaSchemaConstants.IN_RANGE)) {
if (constraint.getValue() instanceof ArrayList<?>) {
if (childNodeMap.containsKey(ToscaSchemaConstants.TYPE)
- && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
- && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
- .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ && (childNodeMap.get(ToscaSchemaConstants.TYPE) instanceof String)
+ && ((String) childNodeMap.get(ToscaSchemaConstants.TYPE))
+ .equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
childObject.put(JsonEditorSchemaConstants.MIN_LENGTH,
- ((ArrayList) constraint.getValue()).get(0));
+ ((ArrayList) constraint.getValue()).get(0));
childObject.put(JsonEditorSchemaConstants.MAX_LENGTH,
- ((ArrayList) constraint.getValue()).get(1));
+ ((ArrayList) constraint.getValue()).get(1));
} else {
childObject.put(JsonEditorSchemaConstants.MINIMUM,
- ((ArrayList) constraint.getValue()).get(0));
+ ((ArrayList) constraint.getValue()).get(0));
childObject.put(JsonEditorSchemaConstants.MAXIMUM,
- ((ArrayList) constraint.getValue()).get(1));
+ ((ArrayList) constraint.getValue()).get(1));
}
}
@@ -477,8 +458,8 @@ public class ToscaYamlToJsonConvertor {
if (constraint.getValue() instanceof ArrayList<?>) {
boolean processDictionary = ((ArrayList<?>) constraint.getValue()).stream()
- .anyMatch(value -> (value instanceof String
- && ((String) value).contains(ToscaSchemaConstants.DICTIONARY)));
+ .anyMatch(value -> (value instanceof String
+ && ((String) value).contains(ToscaSchemaConstants.DICTIONARY)));
if (!processDictionary) {
((ArrayList<?>) constraint.getValue()).stream().forEach(value -> {
validValuesArray.put(value);
@@ -487,7 +468,7 @@ public class ToscaYamlToJsonConvertor {
} else {
((ArrayList<?>) constraint.getValue()).stream().forEach(value -> {
if ((value instanceof String
- && ((String) value).contains(ToscaSchemaConstants.DICTIONARY))) {
+ && ((String) value).contains(ToscaSchemaConstants.DICTIONARY))) {
processDictionaryElements(childObject, (String) value);
}
@@ -505,77 +486,63 @@ public class ToscaYamlToJsonConvertor {
private void processDictionaryElements(JSONObject childObject, String dictionaryReference) {
- if (dictionaryReference.contains("#")) {
- String[] dictionaryKeyArray = dictionaryReference
- .substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
- dictionaryReference.length())
- .split("#");
- // We support only one # as of now.
- List<CldsDictionaryItem> cldsDictionaryElements = null;
- List<CldsDictionaryItem> subDictionaryElements = null;
- if (dictionaryKeyArray != null && dictionaryKeyArray.length == 2) {
- cldsDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKeyArray[0], null, null);
- subDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKeyArray[1], null, null);
-
- if (cldsDictionaryElements != null) {
- List<String> subCldsDictionaryNames = subDictionaryElements.stream()
- .map(CldsDictionaryItem::getDictElementShortName).collect(Collectors.toList());
- JSONArray jsonArray = new JSONArray();
-
- Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put(JsonEditorSchemaConstants.TYPE, getJsonType(c.getDictElementType()));
- if (c.getDictElementType() != null
- && c.getDictElementType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
- jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
- }
- jsonObject.put(JsonEditorSchemaConstants.ID, c.getDictElementName());
- jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getDictElementShortName());
- jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
- jsonArray.put(jsonObject);
- });
- ;
- JSONObject filterObject = new JSONObject();
- filterObject.put(JsonEditorSchemaConstants.FILTERS, jsonArray);
-
- childObject.put(JsonEditorSchemaConstants.TYPE, JsonEditorSchemaConstants.TYPE_QBLDR);
- // TO invoke validation on such parameters
- childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
- childObject.put(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
-
- }
- }
- } else {
- String dictionaryKey = dictionaryReference.substring(
- dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11, dictionaryReference.length());
- if (dictionaryKey != null) {
- List<CldsDictionaryItem> cldsDictionaryElements = getCldsDao().getDictionaryElements(dictionaryKey,
- null, null);
- if (cldsDictionaryElements != null) {
- List<String> cldsDictionaryNames = new ArrayList<>();
- List<String> cldsDictionaryFullNames = new ArrayList<>();
- cldsDictionaryElements.stream().forEach(c -> {
- // Json type will be translated before Policy creation
- if (c.getDictElementType() != null && !c.getDictElementType().equalsIgnoreCase("json")) {
- cldsDictionaryFullNames.add(c.getDictElementName());
- }
- cldsDictionaryNames.add(c.getDictElementShortName());
- });
-
- if (cldsDictionaryFullNames.size() > 0) {
- childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames);
- // Add Enum titles for generated translated values during JSON instance
- // generation
- JSONObject enumTitles = new JSONObject();
- enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
- childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles);
- } else {
- childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames);
- }
-
- }
- }
- }
+ /*
+ * if (dictionaryReference.contains("#")) { String[] dictionaryKeyArray =
+ * dictionaryReference
+ * .substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
+ * dictionaryReference.length()) .split("#"); // We support only one # as of
+ * now. List<CldsDictionaryItem> cldsDictionaryElements = null;
+ * List<CldsDictionaryItem> subDictionaryElements = null; if (dictionaryKeyArray
+ * != null && dictionaryKeyArray.length == 2) { cldsDictionaryElements =
+ * getCldsDao().getDictionaryElements(dictionaryKeyArray[0], null, null);
+ * subDictionaryElements =
+ * getCldsDao().getDictionaryElements(dictionaryKeyArray[1], null, null);
+ *
+ * if (cldsDictionaryElements != null) { List<String> subCldsDictionaryNames =
+ * subDictionaryElements.stream()
+ * .map(CldsDictionaryItem::getDictElementShortName).collect(Collectors.toList()
+ * ); JSONArray jsonArray = new JSONArray();
+ *
+ * Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
+ * JSONObject jsonObject = new JSONObject();
+ * jsonObject.put(JsonEditorSchemaConstants.TYPE,
+ * getJsonType(c.getDictElementType())); if (c.getDictElementType() != null &&
+ * c.getDictElementType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
+ * jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1); }
+ * jsonObject.put(JsonEditorSchemaConstants.ID, c.getDictElementName());
+ * jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getDictElementShortName());
+ * jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
+ * jsonArray.put(jsonObject); }); ; JSONObject filterObject = new JSONObject();
+ * filterObject.put(JsonEditorSchemaConstants.FILTERS, jsonArray);
+ *
+ * childObject.put(JsonEditorSchemaConstants.TYPE,
+ * JsonEditorSchemaConstants.TYPE_QBLDR); // TO invoke validation on such
+ * parameters childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
+ * childObject.put(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
+ *
+ * } } } else { String dictionaryKey = dictionaryReference.substring(
+ * dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
+ * dictionaryReference.length()); if (dictionaryKey != null) {
+ * List<CldsDictionaryItem> cldsDictionaryElements =
+ * getCldsDao().getDictionaryElements(dictionaryKey, null, null); if
+ * (cldsDictionaryElements != null) { List<String> cldsDictionaryNames = new
+ * ArrayList<>(); List<String> cldsDictionaryFullNames = new ArrayList<>();
+ * cldsDictionaryElements.stream().forEach(c -> { // Json type will be
+ * translated before Policy creation if (c.getDictElementType() != null &&
+ * !c.getDictElementType().equalsIgnoreCase("json")) {
+ * cldsDictionaryFullNames.add(c.getDictElementName()); }
+ * cldsDictionaryNames.add(c.getDictElementShortName()); });
+ *
+ * if (cldsDictionaryFullNames.size() > 0) {
+ * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames); //
+ * Add Enum titles for generated translated values during JSON instance //
+ * generation JSONObject enumTitles = new JSONObject();
+ * enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
+ * childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); } else {
+ * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames); }
+ *
+ * } } }
+ */
}
private String getJsonType(String toscaType) {
diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
deleted file mode 100644
index 85b3f5ce..00000000
--- a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.transform;
-
-import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.onap.clamp.clds.util.ResourceFileUtil;
-
-/**
- * XSL Transformer.
- */
-public class XslTransformer {
-
- private Templates templates;
-
- /**
- * Sets Xsl Resource name.
- *
- * @param xslResourceName xsl resource name
- * @throws TransformerConfigurationException exception if there is configuration error
- */
- public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException {
- TransformerFactory tfactory = new TransformerFactoryImpl();
- tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- tfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- templates = tfactory.newTemplates(new StreamSource(ResourceFileUtil.getResourceAsStream(xslResourceName)));
- }
-
- /**
- * Given xml input, return the transformed result.
- *
- * @param xml xml string
- * @throws TransformerException exception during transformation
- */
- public String doXslTransformToString(String xml) throws TransformerException {
- StringWriter output = new StringWriter(4096);
-
- Transformer transformer = templates.newTransformer();
- transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(output));
- return output.toString();
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/util/JsonUtils.java b/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
index 6182598b..cc875d6d 100644
--- a/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
+++ b/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
@@ -41,7 +41,6 @@ import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.onap.clamp.clds.model.properties.AbstractModelElement;
import org.onap.clamp.clds.service.SecureServicePermission;
import org.onap.clamp.clds.service.SecureServicePermissionDeserializer;
import org.onap.clamp.dao.model.gson.converter.InstantDeserializer;
@@ -52,17 +51,17 @@ import org.onap.clamp.dao.model.gson.converter.InstantSerializer;
*/
public class JsonUtils {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonUtils.class);
private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
public static final Gson GSON = new GsonBuilder()
- .registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer()).create();
+ .registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer()).create();
public static final Gson GSON_JPA_MODEL = new GsonBuilder()
- .registerTypeAdapter(Instant.class, new InstantSerializer())
- .registerTypeAdapter(Instant.class, new InstantDeserializer()).setPrettyPrinting()
- .excludeFieldsWithoutExposeAnnotation().create();
+ .registerTypeAdapter(Instant.class, new InstantSerializer())
+ .registerTypeAdapter(Instant.class, new InstantDeserializer()).setPrettyPrinting()
+ .excludeFieldsWithoutExposeAnnotation().create();
private JsonUtils() {
}
@@ -73,7 +72,7 @@ public class JsonUtils {
*/
public static String getStringValueByName(JsonElement jsonElement, String name) {
String value = extractJsonValueFromElement(jsonElement, name).map(JsonUtils::extractStringValueFromElement)
- .orElse(null);
+ .orElse(null);
if (value == null) {
if (logger.isDebugEnabled()) {
logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
@@ -90,7 +89,7 @@ public class JsonUtils {
*/
public static List<String> getStringValuesByName(JsonElement jsonElement, String name) {
List<String> values = extractJsonValueFromElement(jsonElement, name)
- .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
+ .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
if (values.isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
@@ -116,7 +115,7 @@ public class JsonUtils {
*/
public static JsonObject getJsonObjectByName(JsonElement jsonElement, String name) {
JsonObject jsonObject = extractJsonValueFromElement(jsonElement, name).map(JsonElement::getAsJsonObject)
- .orElse(null);
+ .orElse(null);
if (jsonObject == null) {
logger.warn(LOG_ELEMENT_NOT_FOUND, name);
} else {
@@ -147,7 +146,7 @@ public class JsonUtils {
private static boolean hasMatchingParameterName(String name, JsonElement element) {
return element.isJsonObject() && element.getAsJsonObject().has("name")
- && name.equals(element.getAsJsonObject().get("name").getAsString());
+ && name.equals(element.getAsJsonObject().get("name").getAsString());
}
private static String extractStringValueFromElement(JsonElement element) {
@@ -163,10 +162,10 @@ public class JsonUtils {
private static List<String> extractStringValuesFromElement(JsonElement element) {
if (element.isJsonArray()) {
return StreamSupport
- .stream(Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(), Spliterator.ORDERED),
- false)
- .filter(JsonElement::isJsonPrimitive).map(JsonElement::getAsJsonPrimitive)
- .filter(JsonPrimitive::isString).map(JsonPrimitive::getAsString).collect(Collectors.toList());
+ .stream(Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(),
+ Spliterator.ORDERED), false)
+ .filter(JsonElement::isJsonPrimitive).map(JsonElement::getAsJsonPrimitive)
+ .filter(JsonPrimitive::isString).map(JsonPrimitive::getAsString).collect(Collectors.toList());
} else {
String value = extractStringValueFromElement(element);
return Lists.newArrayList(value);
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index d8d15a5b..b1cea34b 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -104,25 +104,20 @@ public class MicroServicePolicy implements Serializable, Policy {
* The constructor that create the json representation from the policyTosca
* using the ToscaYamlToJsonConvertor.
*
- * @param name
- * The name of the MicroService
- * @param modelType
- * The model type of the MicroService
- * @param policyTosca
- * The policy Tosca of the MicroService
- * @param shared
- * The flag indicate whether the MicroService is shared
- * @param usedByLoops
- * The list of loops that uses this MicroService
+ * @param name The name of the MicroService
+ * @param modelType The model type of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is shared
+ * @param usedByLoops The list of loops that uses this MicroService
*/
public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
- Set<Loop> usedByLoops) {
+ Set<Loop> usedByLoops) {
this.name = name;
this.modelType = modelType;
this.policyTosca = policyTosca;
this.shared = shared;
this.jsonRepresentation = JsonUtils.GSON_JPA_MODEL
- .fromJson(new ToscaYamlToJsonConvertor(null).parseToscaYaml(policyTosca), JsonObject.class);
+ .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca), JsonObject.class);
this.usedByLoops = usedByLoops;
}
@@ -136,21 +131,16 @@ public class MicroServicePolicy implements Serializable, Policy {
* The constructor that does not make use of ToscaYamlToJsonConvertor but take
* the jsonRepresentation instead.
*
- * @param name
- * The name of the MicroService
- * @param modelType
- * The model type of the MicroService
- * @param policyTosca
- * The policy Tosca of the MicroService
- * @param shared
- * The flag indicate whether the MicroService is shared
- * @param jsonRepresentation
- * The UI representation in json format
- * @param usedByLoops
- * The list of loops that uses this MicroService
+ * @param name The name of the MicroService
+ * @param modelType The model type of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is
+ * shared
+ * @param jsonRepresentation The UI representation in json format
+ * @param usedByLoops The list of loops that uses this MicroService
*/
public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared,
- JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
+ JsonObject jsonRepresentation, Set<Loop> usedByLoops) {
this.name = name;
this.modelType = modelType;
this.policyTosca = policyTosca;
@@ -245,7 +235,7 @@ public class MicroServicePolicy implements Serializable, Policy {
private String getMicroServicePropertyNameFromTosca(JsonObject object) {
return object.getAsJsonObject("policy_types").getAsJsonObject(this.modelType).getAsJsonObject("properties")
- .keySet().toArray(new String[1])[0];
+ .keySet().toArray(new String[1])[0];
}
@Override