summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/ClampServlet.java94
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java27
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java4
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java153
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java (renamed from src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java)160
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java46
-rw-r--r--src/main/java/org/onap/clamp/clds/config/AAFConfiguration.java7
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/CldsDao.java371
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionary.java164
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java205
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsEvent.java47
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsInfo.java22
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModel.java36
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java130
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java132
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java144
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java12
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java149
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java8
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsToscaService.java149
-rw-r--r--src/main/java/org/onap/clamp/clds/util/ClampTimer.java54
-rw-r--r--src/main/java/org/onap/clamp/clds/util/LoggingUtils.java46
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html3
-rw-r--r--src/main/resources/application-noaaf.properties3
-rw-r--r--src/main/resources/application.properties9
-rw-r--r--src/main/resources/clds/camel/rest/clds-services.xml272
-rw-r--r--src/main/resources/clds/clds-users.json8
-rw-r--r--src/main/resources/logback.xml4
29 files changed, 1975 insertions, 486 deletions
diff --git a/src/main/java/org/onap/clamp/clds/ClampServlet.java b/src/main/java/org/onap/clamp/clds/ClampServlet.java
index 549b12f9f..516325cbe 100644
--- a/src/main/java/org/onap/clamp/clds/ClampServlet.java
+++ b/src/main/java/org/onap/clamp/clds/ClampServlet.java
@@ -36,9 +36,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
+import org.onap.aaf.cadi.principal.X509Principal;
import org.onap.clamp.clds.service.SecureServicePermission;
-import org.onap.clamp.clds.util.ClampTimer;
import org.springframework.context.ApplicationContext;
+import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
@@ -49,62 +50,79 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
public class ClampServlet extends CamelHttpTransportServlet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4198841134910211542L;
+
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ClampServlet.class);
public static final String PERM_INSTANCE = "clamp.config.security.permission.instance";
public static final String PERM_CL = "clamp.config.security.permission.type.cl";
public static final String PERM_TEMPLATE = "clamp.config.security.permission.type.template";
public static final String PERM_VF = "clamp.config.security.permission.type.filter.vf";
public static final String PERM_MANAGE = "clamp.config.security.permission.type.cl.manage";
+ public static final String PERM_TOSCA = "clamp.config.security.permission.type.tosca";
+ private static List<SecureServicePermission> permissionList;
- @Override
- protected void doService(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- List<SecureServicePermission> permissionList = new ArrayList<>();
-
- // Get Principal info and translate it into Spring Authentication If
- // authenticataion is null: a) the authentication info was set manually
- // in the previous thread b) handled by Spring automatically for the 2
- // cases above, no need for the translation, just skip the following
- // step
- if (null == authentication) {
- logger.debug("Populate Spring Authenticataion info manually.");
+ private synchronized List<SecureServicePermission> getPermissionList() {
+ if (permissionList == null) {
+ permissionList=new ArrayList<>();
ApplicationContext applicationContext = WebApplicationContextUtils
- .getWebApplicationContext(this.getServletContext());
- // Start a timer to clear the authentication after 5 mins, so that
- // the authentication will be reinitialized with AAF DB
- new ClampTimer(300);
- String cldsPersmissionTypeCl = applicationContext.getEnvironment().getProperty(PERM_CL);
- String cldsPermissionTypeTemplate = applicationContext.getEnvironment().getProperty(PERM_TEMPLATE);
+ .getWebApplicationContext(getServletContext());
String cldsPermissionInstance = applicationContext.getEnvironment().getProperty(PERM_INSTANCE);
- String cldsPermissionTypeFilterVf = applicationContext.getEnvironment().getProperty(PERM_VF);
- String cldsPermissionTypeClManage = applicationContext.getEnvironment().getProperty(PERM_MANAGE);
-
- // set the stragety to Mode_Global, so that all thread is able to
- // see the authentication
- SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
- Principal p = request.getUserPrincipal();
+ permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_CL),
+ cldsPermissionInstance, "read"));
+ permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_CL),
+ cldsPermissionInstance, "update"));
+ permissionList.add(SecureServicePermission.create(
+ applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, "read"));
+ permissionList.add(SecureServicePermission.create(
+ applicationContext.getEnvironment().getProperty(PERM_TEMPLATE), cldsPermissionInstance, "update"));
+ permissionList.add(SecureServicePermission.create(applicationContext.getEnvironment().getProperty(PERM_VF),
+ cldsPermissionInstance, "*"));
+ permissionList.add(SecureServicePermission
+ .create(applicationContext.getEnvironment().getProperty(PERM_MANAGE), cldsPermissionInstance, "*"));
+ permissionList.add(SecureServicePermission
+ .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, "read"));
+ permissionList.add(SecureServicePermission
+ .create(applicationContext.getEnvironment().getProperty(PERM_TOSCA), cldsPermissionInstance, "update"));
+ }
+ return permissionList;
+ }
- permissionList.add(SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "read"));
- permissionList.add(SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "update"));
- permissionList
- .add(SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, "read"));
- permissionList
- .add(SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, "update"));
- permissionList.add(SecureServicePermission.create(cldsPermissionTypeFilterVf, cldsPermissionInstance, "*"));
- permissionList.add(SecureServicePermission.create(cldsPermissionTypeClManage, cldsPermissionInstance, "*"));
+ /**
+ * When AAF is enabled, request object will contain a cadi Wrapper, so queries
+ * to isUserInRole will invoke a http call to AAF server.
+ */
+ @Override
+ protected void doService(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ Principal p = request.getUserPrincipal();
+ if (p instanceof X509Principal) {
+ // When AAF is enabled, there is a need to provision the permissions to Spring
+ // system
List<GrantedAuthority> grantedAuths = new ArrayList<>();
- for (SecureServicePermission perm : permissionList) {
+ for (SecureServicePermission perm : getPermissionList()) {
String permString = perm.toString();
if (request.isUserInRole(permString)) {
grantedAuths.add(new SimpleGrantedAuthority(permString));
}
}
Authentication auth = new UsernamePasswordAuthenticationToken(new User(p.getName(), "", grantedAuths), "",
- grantedAuths);
+ grantedAuths);
SecurityContextHolder.getContext().setAuthentication(auth);
}
- super.doService(request, response);
+ try {
+ super.doService(request, response);
+ } catch (ServletException | IOException ioe) {
+ logger.error("Exception caught when executing doService in servlet", ioe);
+ try {
+ response.sendError(HttpStatus.INTERNAL_SERVER_ERROR.value());
+ } catch (IOException e) {
+ logger.error("Exception caught when executing HTTP sendError in servlet", e);
+ }
+ }
+
}
} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
index e324b2d99..39377d4a2 100644
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
@@ -17,8 +17,9 @@
* 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;
@@ -31,7 +32,7 @@ import java.util.Map;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq;
+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;
@@ -52,16 +53,14 @@ public class OperationalPolicyDelegate {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyDelegate.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- /**
- * Automatically injected by Spring, define in CldsConfiguration as a bean.
- */
- @Autowired
- private PolicyClient policyClient;
- /**
- * Automatically injected by Spring, define in CldsConfiguration as a bean.
- */
+ private final PolicyClient policyClient;
+ private final ClampProperties refProp;
+
@Autowired
- private ClampProperties refProp;
+ public OperationalPolicyDelegate(PolicyClient policyClient, ClampProperties refProp) {
+ this.policyClient = policyClient;
+ this.refProp = refProp;
+ }
/**
* Perform activity. Send Operational Policy info to policy api.
@@ -69,7 +68,7 @@ public class OperationalPolicyDelegate {
* @param camelExchange
* The Camel Exchange object containing the properties
* @throws BuilderException
- * In case of issues with OperationalPolicyReq
+ * In case of issues with OperationalPolicyRequestAttributesConstructor
* @throws UnsupportedEncodingException
* In case of issues with the Charset encoding
*/
@@ -80,8 +79,8 @@ public class OperationalPolicyDelegate {
Policy policy = prop.getType(Policy.class);
if (policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- Map<AttributeType, Map<String, String>> attributes = OperationalPolicyReq.formatAttributes(refProp,
- prop, prop.getType(Policy.class).getId(), policyChain);
+ 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) {
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
index 08cfba141..872999356 100644
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
@@ -43,7 +43,7 @@ import org.springframework.stereotype.Component;
public class OperationalPolicyDeleteDelegate {
protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(OperationalPolicyDeleteDelegate.class);
+ .getLogger(OperationalPolicyDeleteDelegate.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
@Autowired
private PolicyClient policyClient;
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
new file mode 100644
index 000000000..c28f700b2
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java
@@ -0,0 +1,153 @@
+/*-
+ * ============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() {
+ }
+
+ 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/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
index f062dfca6..1fc360820 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
@@ -21,7 +21,6 @@
* ===================================================================
*
*/
-
package org.onap.clamp.clds.client.req.policy;
import com.att.eelf.configuration.EELFLogger;
@@ -37,12 +36,10 @@ import java.util.Map;
import javax.ws.rs.BadRequestException;
-import org.onap.clamp.clds.config.ClampProperties;
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.api.AttributeType;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.policy.Target;
@@ -55,83 +52,14 @@ import org.onap.policy.sdc.Resource;
import org.onap.policy.sdc.ResourceType;
import org.onap.policy.sdc.Service;
-/**
- * Construct an Operational Policy request given CLDS objects.
- */
-public class OperationalPolicyReq {
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
+public class OperationalPolicyYamlFormatter {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyYamlFormatter.class);
- protected OperationalPolicyReq() {
+ protected OperationalPolicyYamlFormatter() {
}
-
- /**
- * Format Operational Policy attributes.
- *
- * @param refProp
- * @param prop
- * @param modelElementId
- * @param policyChain
- * @return
- * @throws BuilderException
- * @throws UnsupportedEncodingException
- */
- public static Map<AttributeType, Map<String, String>> formatAttributes(ClampProperties refProp,
- ModelProperties prop, String modelElementId, PolicyChain policyChain)
- throws BuilderException, UnsupportedEncodingException {
- Global global = prop.getGlobal();
- prop.setCurrentModelElementId(modelElementId);
- prop.setPolicyUniqueId(policyChain.getPolicyId());
- String templateName = refProp.getStringValue("op.templateName", global.getService());
- String operationTopic = refProp.getStringValue("op.operationTopic", global.getService());
- String notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService());
- String controller = refProp.getStringValue("op.controller", global.getService());
- String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService());
- // ruleAttributes
- logger.info("templateName=" + templateName);
- logger.info("notificationTopic=" + notificationTopic);
- Map<String, String> ruleAttributes = new HashMap<>();
- ruleAttributes.put("templateName", templateName);
- ruleAttributes.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId());
- ruleAttributes.put("notificationTopic", notificationTopic);
- if (operationTopic == null || operationTopic.isEmpty()) {
- logger.info("recipeTopic=" + recipeTopic);
- // if no operationTopic, then don't format yaml - use first policy
- // from list
- PolicyItem policyItem = policyChain.getPolicyItems().get(0);
- ruleAttributes.put("RecipeTopic", recipeTopic);
- String recipe = policyItem.getRecipe();
- String maxRetries = String.valueOf(policyItem.getMaxRetries());
- String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit());
- String targetResourceId = String.valueOf(policyItem.getTargetResourceId());
- logger.info("recipe=" + recipe);
- logger.info("maxRetries=" + maxRetries);
- logger.info("retryTimeLimit=" + retryTimeLimit);
- logger.info("targetResourceId=" + targetResourceId);
- ruleAttributes.put("Recipe", recipe);
- ruleAttributes.put("MaxRetries", maxRetries);
- ruleAttributes.put("RetryTimeLimit", retryTimeLimit);
- ruleAttributes.put("ResourceId", targetResourceId);
- } else {
- logger.info("operationTopic=" + operationTopic);
- // format yaml
- String yaml = formatYaml(refProp, prop, modelElementId, policyChain);
- ruleAttributes.put("operationTopic", operationTopic);
- ruleAttributes.put("controlLoopYaml", yaml);
- }
- // matchingAttributes
- Map<String, String> matchingAttributes = new HashMap<>();
- matchingAttributes.put("controller", controller);
- Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
- attributes.put(AttributeType.RULE, ruleAttributes);
- attributes.put(AttributeType.MATCHING, matchingAttributes);
- return attributes;
- }
-
/**
* Format Operational OpenLoop Policy yaml.
*
- * @param refProp
* @param prop
* @param modelElementId
* @param policyChain
@@ -139,7 +67,7 @@ public class OperationalPolicyReq {
* @throws BuilderException
* @throws UnsupportedEncodingException
*/
- protected static String formatOpenLoopYaml(ClampProperties refProp, ModelProperties prop, String modelElementId,
+ public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
Global global = prop.getGlobal();
@@ -147,7 +75,7 @@ public class OperationalPolicyReq {
prop.setPolicyUniqueId(policyChain.getPolicyId());
// convert values to SDC objects
Service service = new Service(global.getService());
- Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF);
+ Resource[] vfResources = convertToResources(global.getResourceVf(), ResourceType.VF);
// create builder
ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
policyChain.getTimeout(), service, vfResources);
@@ -158,18 +86,7 @@ public class OperationalPolicyReq {
return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
- /**
- * Format Operational Policy yaml.
- *
- * @param refProp
- * @param prop
- * @param modelElementId
- * @param policyChain
- * @return
- * @throws BuilderException
- * @throws UnsupportedEncodingException
- */
- protected static String formatYaml(ClampProperties refProp, ModelProperties prop, String modelElementId,
+ public static String formatYaml(ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
Global global = prop.getGlobal();
@@ -177,8 +94,8 @@ public class OperationalPolicyReq {
prop.setPolicyUniqueId(policyChain.getPolicyId());
// convert values to SDC objects
Service service = new Service(global.getService());
- Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF);
- Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC);
+ Resource[] vfResources = convertToResources(global.getResourceVf(), ResourceType.VF);
+ Resource[] vfcResources = convertToResources(global.getResourceVfc(), ResourceType.VFC);
// create builder
ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
policyChain.getTimeout(), service, vfResources);
@@ -209,7 +126,7 @@ public class OperationalPolicyReq {
+ parentPolicyObj.getName() + " - created by CLDS";
policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, actor, target,
policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(),
- parentPolicyObj.getId(), convertToPolicyResult(policyItem.getParentPolicyConditions()));
+ parentPolicyObj.getId(), convertToPolicyResults(policyItem.getParentPolicyConditions()));
logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId());
}
policyObjMap.put(policyItem.getId(), policyObj);
@@ -220,29 +137,7 @@ public class OperationalPolicyReq {
return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
- 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());
- }
- }
-
- /**
- * Order list of PolicyItems so that parents come before any of their
- * children
- *
- * @param inOrigList
- * @return
- */
- private static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
+ protected static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
List<PolicyItem> inList = new ArrayList<>();
inList.addAll(inOrigList);
List<PolicyItem> outList = new ArrayList<>();
@@ -286,31 +181,34 @@ public class OperationalPolicyReq {
return outList;
}
- /**
- * Convert a List of resource strings to an array of Resource objects.
- *
- * @param stringList
- * @param resourceType
- * @return
- */
- protected static Resource[] convertToResource(List<String> stringList, ResourceType resourceType) {
+ 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);
}
- /**
- * Convert a List of policy result strings to an array of PolicyResult
- * objects.
- *
- * @param prList
- * @return
- */
- protected static PolicyResult[] convertToPolicyResult(List<String> prList) {
+ 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
index cc97a7ce0..cd387b3c3 100644
--- 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
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client.req.policy;
@@ -26,11 +26,8 @@ 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.Collection;
-import java.util.Collections;
import java.util.Date;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -46,7 +43,6 @@ import org.onap.policy.api.ConfigRequestParameters;
import org.onap.policy.api.DeletePolicyCondition;
import org.onap.policy.api.DeletePolicyParameters;
import org.onap.policy.api.PolicyChangeResponse;
-import org.onap.policy.api.PolicyConfig;
import org.onap.policy.api.PolicyConfigException;
import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyEngine;
@@ -95,7 +91,7 @@ public class PolicyClient {
* @return The response message of policy
*/
public String sendBrmsPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
- String policyRequestUuid) {
+ String policyRequestUuid) {
PolicyParameters policyParameters = new PolicyParameters();
// Set Policy Type(Mandatory)
policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
@@ -160,7 +156,7 @@ public class PolicyClient {
* @return The answer from policy call
*/
public String sendBasePolicyInOther(String configBody, String configPolicyName, ModelProperties prop,
- String policyRequestUuid) {
+ String policyRequestUuid) {
PolicyParameters policyParameters = new PolicyParameters();
// Set Policy Type
policyParameters.setPolicyConfigType(PolicyConfigType.Base);
@@ -181,7 +177,7 @@ public class PolicyClient {
/**
* Perform send of Microservice policy in OTHER type.
- *
+ *
* @param configBody
* The config policy string body
* @param prop
@@ -224,8 +220,7 @@ public class PolicyClient {
String responseMessage = "";
Date startTime = new Date();
try {
- List<Integer> versions = getVersions(policyNamePrefix, prop);
- if (versions.isEmpty()) {
+ if (!checkPolicyExists(policyNamePrefix, prop)) {
LoggingUtils.setTargetContext("Policy", "createPolicy");
logger.info("Attempting to create policy for action=" + prop.getActionCd());
response = getPolicyEngine().createPolicy(policyParameters);
@@ -313,8 +308,8 @@ public class PolicyClient {
}
/**
- * Use Get Config Policy API to retrieve the versions for a policy. Return
- * versions in sorted order. Return empty list if none found.
+ * Use list Policy API to retrieve the policy. Return true if policy exists
+ * otherwise return false.
*
* @param policyNamePrefix
* The Policy Name Prefix
@@ -324,8 +319,8 @@ public class PolicyClient {
* @throws PolicyConfigException
* In case of issues with policy engine
*/
- protected List<Integer> getVersions(String policyNamePrefix, ModelProperties prop) throws PolicyConfigException {
- ArrayList<Integer> versions = new ArrayList<>();
+ protected boolean checkPolicyExists(String policyNamePrefix, ModelProperties prop) throws PolicyConfigException {
+ boolean policyexists = false;
ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
String policyName = "";
if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
@@ -336,27 +331,20 @@ public class PolicyClient {
logger.info("Search in Policy Engine for policyName=" + policyName);
configRequestParameters.setPolicyName(policyName);
try {
- Collection<PolicyConfig> response = getPolicyEngine().getConfig(configRequestParameters);
- for (PolicyConfig policyConfig : response) {
- if (policyConfig.getPolicyVersion() != null) {
- Integer version = Integer.valueOf(policyConfig.getPolicyVersion());
- versions.add(version);
- } else {
- logger.warn("Policy version was null, unable to convert it to Integer");
- }
+ Collection<String> response = getPolicyEngine().listConfig(configRequestParameters);
+ if (response != null && !response.isEmpty()) {
+ policyexists = true;
}
- Collections.sort(versions);
- logger.info("Policy versions.size()=" + versions.size());
} catch (PolicyConfigException e) {
// just print warning - if no policy version found
logger.warn("policy not found...policy name - " + policyName, e);
}
- return versions;
+ return policyexists;
}
/**
* This method create a new policy engine.
- *
+ *
* @return A new policy engine
*/
private synchronized PolicyEngine getPolicyEngine() {
@@ -381,8 +369,7 @@ public class PolicyClient {
String deletePolicyResponse = "";
try {
String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
- List<Integer> versions = getVersions(policyNamePrefix, prop);
- if (!versions.isEmpty()) {
+ if (checkPolicyExists(policyNamePrefix, prop)) {
String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
deletePolicyResponse = deletePolicy(prop, policyType);
}
@@ -415,8 +402,7 @@ public class PolicyClient {
String deletePolicyResponse = "";
try {
String policyNamePrefix = refProp.getStringValue(POLICY_OP_NAME_PREFIX_PROPERTY_NAME);
- List<Integer> versions = getVersions(policyNamePrefix, prop);
- if (!versions.isEmpty()) {
+ if (checkPolicyExists(policyNamePrefix, prop)) {
String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME);
deletePolicyResponse = deletePolicy(prop, policyType);
}
diff --git a/src/main/java/org/onap/clamp/clds/config/AAFConfiguration.java b/src/main/java/org/onap/clamp/clds/config/AAFConfiguration.java
index 13dccdacb..8bc6f69dc 100644
--- a/src/main/java/org/onap/clamp/clds/config/AAFConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/AAFConfiguration.java
@@ -29,7 +29,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
@Configuration
@Profile("clamp-aaf-authentication")
@@ -54,7 +53,11 @@ public class AAFConfiguration {
public FilterRegistrationBean cadiFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(cadiFilter());
- registration.addUrlPatterns("/restservices/*");
+ registration.addUrlPatterns("/restservices/clds/v1/clds/*");
+ registration.addUrlPatterns("/restservices/clds/v1/cldsTempate/*");
+ registration.addUrlPatterns("/restservices/clds/v1/tosca/*");
+ registration.addUrlPatterns("/restservices/clds/v1/dictionary/*");
+ registration.addUrlPatterns("/restservices/clds/v1/user/*");
//registration.addUrlPatterns("*");
registration.setName("cadiFilter");
registration.setOrder(0);
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
index a3771aa54..54a5196c1 100644
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.dao;
@@ -29,13 +29,19 @@ import com.att.eelf.configuration.EELFManager;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.onap.clamp.clds.model.CldsDbServiceCache;
+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;
@@ -43,6 +49,7 @@ import org.onap.clamp.clds.model.CldsModelProp;
import org.onap.clamp.clds.model.CldsMonitoringDetails;
import org.onap.clamp.clds.model.CldsServiceData;
import org.onap.clamp.clds.model.CldsTemplate;
+import org.onap.clamp.clds.model.CldsToscaModel;
import org.onap.clamp.clds.model.ValueItem;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -72,7 +79,13 @@ public class CldsDao {
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
*/
@@ -95,6 +108,11 @@ public class CldsDao {
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");
}
/**
@@ -116,15 +134,14 @@ public class CldsDao {
CldsModel model = new CldsModel();
model.setName(modelName);
SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName)
- .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
+ .addValue(V_CONTROL_NAME_UUID, controlNameUuid);
Map<String, Object> out = logSqlExecution(procGetModel, in);
populateModelProperties(model, out);
return model;
}
/**
- * Get a model and template information from the database given the model
- * name.
+ * Get a model and template information from the database given the model name.
*
* @param modelName
* @return model
@@ -134,14 +151,12 @@ public class CldsDao {
model.setName(modelName);
SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
Map<String, Object> out = logSqlExecution(procGetModelTemplate, in);
- // todo : rationalize
populateModelProperties(model, out);
Map<String, Object> modelResults = logSqlExecution(procGetModel, in);
Object modelResultObject = modelResults.get("#result-set-1");
- if (modelResultObject != null && modelResultObject instanceof ArrayList) {
- List<Object> modelInstanceRs = (List<Object>) modelResultObject;
- for (Object currModelInstance : modelInstanceRs) {
- if (currModelInstance != null && currModelInstance instanceof HashMap) {
+ 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"));
@@ -156,8 +171,8 @@ public class CldsDao {
}
/**
- * Update model in the database using parameter values and return updated
- * model object.
+ * Update model in the database using parameter values and return updated model
+ * object.
*
* @param model
* @param userid
@@ -165,12 +180,12 @@ public class CldsDao {
*/
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_control_name_prefix", model.getControlNamePrefix())
- .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid());
+ .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_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));
@@ -184,8 +199,8 @@ public class CldsDao {
}
/**
- * Inserts new modelInstance in the database using parameter values and
- * return updated model object.
+ * Inserts new modelInstance in the database using parameter values and return
+ * updated model object.
*
* @param model
* @param modelInstancesList
@@ -203,9 +218,9 @@ public class CldsDao {
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());
+ .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();
@@ -230,10 +245,10 @@ public class CldsDao {
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());
+ .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;
@@ -253,7 +268,7 @@ public class CldsDao {
*/
public void updEvent(String eventId, String processInstanceId) {
SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId)
- .addValue("v_process_instance_id", processInstanceId);
+ .addValue("v_process_instance_id", processInstanceId);
logSqlExecution(procUpdEvent, in);
}
@@ -276,9 +291,9 @@ public class CldsDao {
*/
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());
+ .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());
Map<String, Object> out = logSqlExecution(procSetTemplate, in);
template.setId((String) (out.get("v_template_id")));
template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id")));
@@ -333,10 +348,10 @@ public class CldsDao {
try {
String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? ";
cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID },
- new CldsServiceDataMapper());
+ new CldsServiceDataMapper());
if (cldsServiceData != null) {
logger.info("CldsServiceData found in cache for Service Invariant ID:"
- + cldsServiceData.getServiceInvariantUUID());
+ + cldsServiceData.getServiceInvariantUUID());
return cldsServiceData;
} else {
logger.warn("CldsServiceData not found in cache for Service Invariant ID:" + invariantUUID);
@@ -351,13 +366,13 @@ public class CldsDao {
public void setCldsServiceCache(CldsDbServiceCache cldsDBServiceCache) {
if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null
- && cldsDBServiceCache.getServiceId() != null) {
+ && cldsDBServiceCache.getServiceId() != null) {
String invariantUuid = cldsDBServiceCache.getInvariantId();
String serviceUuid = cldsDBServiceCache.getServiceId();
InputStream is = cldsDBServiceCache.getCldsDataInstream();
String insertCldsServiceCacheSql = "INSERT INTO clds_service_cache"
- + "(invariant_service_id,service_id,timestamp,object_data) VALUES"
- + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) ";
+ + "(invariant_service_id,service_id,timestamp,object_data) VALUES"
+ + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) ";
jdbcTemplateObject.update(insertCldsServiceCacheSql, invariantUuid, serviceUuid, is);
}
}
@@ -377,13 +392,13 @@ public class CldsDao {
/**
* 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'";
+ + "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) {
@@ -399,23 +414,22 @@ public class CldsDao {
/**
* Method to get deployed/active models with model properties.
- *
+ *
* @return list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name
- * used in the CLDS application (prefix: ClosedLoop- + unique
- * ClosedLoop ID) MODEL_NAME | Model Name in CLDS application
- * SERVICE_TYPE_ID | TypeId returned from the DCAE application when
- * the ClosedLoop is submitted (DCAEServiceTypeRequest generated in
- * DCAE application). DEPLOYMENT_ID | Id generated when the
- * ClosedLoop is deployed in DCAE. TEMPLATE_NAME | Template used to
- * generate the ClosedLoop model. ACTION_CD | Current state of the
- * ClosedLoop in CLDS application.
+ * used in the CLDS application (prefix: ClosedLoop- + unique ClosedLoop
+ * ID) MODEL_NAME | Model Name in CLDS application SERVICE_TYPE_ID |
+ * TypeId returned from the DCAE application when the ClosedLoop is
+ * submitted (DCAEServiceTypeRequest generated in DCAE application).
+ * DEPLOYMENT_ID | Id generated when the ClosedLoop is deployed in DCAE.
+ * TEMPLATE_NAME | Template used to generate the ClosedLoop model.
+ * ACTION_CD | Current state of the ClosedLoop in CLDS application.
*/
public List<CldsMonitoringDetails> getCLDSMonitoringDetails() {
- SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
- List<CldsMonitoringDetails> cldsMonitoringDetailsList = new ArrayList<CldsMonitoringDetails>();
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+ List<CldsMonitoringDetails> cldsMonitoringDetailsList = new ArrayList<>();
String modelsSql = "SELECT CONCAT(M.CONTROL_NAME_PREFIX, M.CONTROL_NAME_UUID) AS CLOSELOOP_NAME , M.MODEL_NAME, M.SERVICE_TYPE_ID, M.DEPLOYMENT_ID, T.TEMPLATE_NAME, E.ACTION_CD, E.USER_ID, E.TIMESTAMP "
- + "FROM MODEL M, TEMPLATE T, EVENT E "
- + "WHERE M.TEMPLATE_ID = T.TEMPLATE_ID AND M.EVENT_ID = E.EVENT_ID " + "ORDER BY ACTION_CD";
+ + "FROM MODEL M, TEMPLATE T, EVENT E " + "WHERE M.TEMPLATE_ID = T.TEMPLATE_ID AND M.EVENT_ID = E.EVENT_ID "
+ + "ORDER BY ACTION_CD";
List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
CldsMonitoringDetails cldsMonitoringDetails = null;
for (Map<String, Object> row : rows) {
@@ -435,16 +449,15 @@ public class CldsDao {
/**
* Method to delete model from database.
- *
+ *
* @param modelName
*/
public void deleteModel(String modelName) {
SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName);
logSqlExecution(procDeleteModel, in);
}
-
+
private void populateModelProperties(CldsModel model, Map out) {
- // todo : rationalize
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")));
@@ -461,6 +474,252 @@ public class CldsDao {
model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id"));
model.getEvent().setUserid((String) out.get("v_event_user_id"));
model.setTypeId((String) out.get("v_service_type_id"));
- model.setDeploymentId((String) out.get("v_deployment_id"));
- }
+ model.setDeploymentId((String) out.get("v_deployment_id"));
+ }
+
+ /**
+ * Method to retrieve a tosca models by Policy Type from database.
+ *
+ * @param policyType
+ * @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
+ * @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 policyType
+ * @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<>();
+ MapSqlParameterSource params = new MapSqlParameterSource();
+
+ String toscaModelSql = "SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, tmr.tosca_model_revision_id, tmr.version, tmr.user_id, tmr.createdTimestamp, tmr.lastUpdatedTimestamp, tmr.tosca_model_yaml FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id ";
+ if (toscaModelName != null) {
+ toscaModelSql += " AND tm.tosca_model_name = :toscaModelName";
+ params.addValue("toscaModelName", toscaModelName);
+ }
+ if (policyType != null) {
+ toscaModelSql += " AND tm.policy_type = :policyType";
+ params.addValue("policyType", policyType);
+ }
+ toscaModelSql += " AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id=st.tosca_model_id)";
+
+ Optional.ofNullable(jdbcTemplateObject.queryForList(toscaModelSql, params)).orElse(Collections.emptyList()).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.setVersion(((Double) row.get("version")));
+ cldsToscaModel.setCreatedDate(sdf.format(row.get("createdTimestamp")));
+ 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
+ * @param userId
+ * @return CldsToscaModel
+ *
+ */
+ 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
+ * @param userId
+ * @return CldsToscaModel
+ */
+ 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
+ */
+ 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
+ * @param cldsDictionary
+ * @param userId
+ */
+ public void updateDictionary(String dictionaryId, CldsDictionary cldsDictionary, String userId) {
+ String dictionarySql = "UPDATE dictionary SET dictionary_name = :dictionary_name, modified_by = :modified_by WHERE dictionary_id = :dictionary_id";
+ SqlParameterSource namedParameters = new MapSqlParameterSource()
+ .addValue("dictionary_name", cldsDictionary.getDictionaryName()).addValue("modified_by", userId)
+ .addValue("dictionary_id", dictionaryId);
+ jdbcTemplateObject.update(dictionarySql, namedParameters);
+ cldsDictionary.setUpdatedBy(userId);
+ }
+
+ /**
+ * Method to get list of Dictionaries from the Database
+ *
+ * @param dictionaryId
+ * @param dictionaryName
+ * @return
+ */
+ public List<CldsDictionary> getDictionary(String dictionaryId, String dictionaryName) {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+ List<CldsDictionary> dictionaries = new ArrayList<>();
+ String dictionarySql = "SELECT dictionary_id, dictionary_name, created_by, modified_by, timestamp FROM dictionary WHERE ";
+ MapSqlParameterSource namedParameters = new MapSqlParameterSource();
+ Optional.ofNullable(dictionaryName).ifPresent(dn -> namedParameters.addValue("dictionary_name", dn));
+ Optional.ofNullable(dictionaryId).ifPresent(dn -> namedParameters.addValue("dictionary_id", dn));
+ dictionarySql += Optional.ofNullable(namedParameters.getParameterNames()).filter(a -> a.length > 0)
+ .map(Arrays::stream).map(s -> s.map(param -> param + " = :" + param).collect(Collectors.joining(" AND ")))
+ .orElse("1");
+
+ Optional.ofNullable(jdbcTemplateObject.queryForList(dictionarySql, namedParameters)).orElse(Collections.emptyList()).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
+ * @param userId
+ */
+ 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
+ * @param cldsDictionaryItem
+ * @param userId
+ */
+ public void updateDictionaryElements(String dictionaryElementId, CldsDictionaryItem cldsDictionaryItem,
+ String userId) {
+
+ String dictionarySql = "UPDATE dictionary_elements SET dict_element_name = :dict_element_name, dict_element_short_name = :dict_element_short_name, dict_element_description = :dict_element_description,dict_element_type=:dict_element_type, modified_by = :modified_by WHERE dict_element_id = :dict_element_id";
+ SqlParameterSource namedParameters = new MapSqlParameterSource()
+ .addValue("dict_element_name", cldsDictionaryItem.getDictElementName())
+ .addValue("dict_element_short_name", cldsDictionaryItem.getDictElementShortName())
+ .addValue("dict_element_description", cldsDictionaryItem.getDictElementDesc())
+ .addValue("dict_element_type", cldsDictionaryItem.getDictElementType())
+ .addValue("modified_by", userId)
+ .addValue("dict_element_id", dictionaryElementId);
+ jdbcTemplateObject.update(dictionarySql, namedParameters);
+ cldsDictionaryItem.setUpdatedBy(userId);
+ }
+
+ /**
+ * Method to get list of all dictionary elements for a given dictionary in the
+ * Database
+ *
+ * @param dictionaryName
+ * @param dictionaryId
+ * @param dictElementShortName
+ * @return
+ */
+ public List<CldsDictionaryItem> getDictionaryElements(String dictionaryName, String dictionaryId,
+ String dictElementShortName) {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+ List<CldsDictionaryItem> dictionaryItems = new ArrayList<>();
+ MapSqlParameterSource namedParameters = new MapSqlParameterSource();
+ String dictionarySql = "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 ";
+ if (dictionaryId != null) {
+ dictionarySql+=" AND d.dictionary_id = :dictionaryId";
+ namedParameters.addValue("dictionaryId", dictionaryId);
+ }
+ if (dictElementShortName!=null) {
+ dictionarySql+=" AND de.dict_element_short_name = :dictElementShortName";
+ namedParameters.addValue("dictElementShortName", dictElementShortName);
+ }
+ if (dictionaryName!=null) {
+ dictionarySql+=" AND dictionary_name = :dictionaryName";
+ namedParameters.addValue("dictionaryName", dictionaryName);
+ }
+
+ Optional.ofNullable(jdbcTemplateObject.queryForList(dictionarySql,namedParameters)).orElse(Collections.emptyList()).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;
+ }
}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
new file mode 100644
index 000000000..a9b003d4d
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
@@ -0,0 +1,164 @@
+/*-
+ * ============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.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+/**
+ * Represents a CLDS Dictionary.
+ */
+@JsonInclude(Include.NON_NULL)
+public class CldsDictionary {
+
+ private String dictionaryId;
+ private String dictionaryName;
+ private String createdBy;
+ private String updatedBy;
+ private String lastUpdatedDate;
+ private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
+
+ /**
+ * Creates or updates dictionary item for a dictionary in DB
+ *
+ * @param dictionaryName
+ * @param cldsDao
+ * @param userId
+ */
+ 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);
+ }
+ }
+
+ /**
+ * @return the dictionaryId
+ */
+ public String getDictionaryId() {
+ return dictionaryId;
+ }
+
+ /**
+ * @param dictionaryId
+ * the dictionaryId to set
+ */
+ public void setDictionaryId(String dictionaryId) {
+ this.dictionaryId = dictionaryId;
+ }
+
+ /**
+ * @return the dictionaryName
+ */
+ public String getDictionaryName() {
+ return dictionaryName;
+ }
+
+ /**
+ * @param dictionaryName
+ * the dictionaryName to set
+ */
+ public void setDictionaryName(String dictionaryName) {
+ this.dictionaryName = dictionaryName;
+ }
+
+ /**
+ * @return the createdBy
+ */
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * @param createdBy
+ * the createdBy to set
+ */
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * @return the updatedBy
+ */
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ /**
+ * @param updatedby
+ * the updatedBy to set
+ */
+ public void setUpdatedBy(String updatedby) {
+ updatedBy = updatedby;
+ }
+
+ /**
+ * @return the lastUpdatedDate
+ */
+ public String getLastUpdatedDate() {
+ return lastUpdatedDate;
+ }
+
+ /**
+ * @param lastUpdatedDate
+ * the lastUpdatedDate to set
+ */
+ public void setLastUpdatedDate(String lastUpdatedDate) {
+ this.lastUpdatedDate = lastUpdatedDate;
+ }
+
+ /**
+ * @return the cldsDictionaryItems
+ */
+ public List<CldsDictionaryItem> getCldsDictionaryItems() {
+ return cldsDictionaryItems;
+ }
+
+ /**
+ * @param cldsDictionaryItems
+ * the cldsDictionaryItems to set
+ */
+ public void setCldsDictionaryItems(List<CldsDictionaryItem> cldsDictionaryItems) {
+ this.cldsDictionaryItems = cldsDictionaryItems;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
new file mode 100644
index 000000000..87ba9fe84
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
@@ -0,0 +1,205 @@
+/*-
+ * ============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.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+import java.util.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+/**
+ * Represents a CLDS Dictionary Item.
+ */
+@JsonInclude(Include.NON_NULL)
+public class CldsDictionaryItem {
+
+ private String dictElementId;
+ private String dictionaryId;
+ private String dictElementName;
+ private String dictElementShortName;
+ private String dictElementDesc;
+ private String dictElementType;
+ private String createdBy;
+ private String updatedBy;
+ private String lastUpdatedDate;
+
+ 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);
+ }
+ }
+ }
+
+ /**
+ * @return the dictElementId
+ */
+ public String getDictElementId() {
+ return dictElementId;
+ }
+
+ /**
+ * @param dictElementId
+ * the dictElementId to set
+ */
+ public void setDictElementId(String dictElementId) {
+ this.dictElementId = dictElementId;
+ }
+
+ /**
+ * @return the dictionaryId
+ */
+ public String getDictionaryId() {
+ return dictionaryId;
+ }
+
+ /**
+ * @param dictionaryId
+ * the dictionaryId to set
+ */
+ public void setDictionaryId(String dictionaryId) {
+ this.dictionaryId = dictionaryId;
+ }
+
+ /**
+ * @return the dictElementName
+ */
+ public String getDictElementName() {
+ return dictElementName;
+ }
+
+ /**
+ * @param dictElementName
+ * the dictElementName to set
+ */
+ public void setDictElementName(String dictElementName) {
+ this.dictElementName = dictElementName;
+ }
+
+ /**
+ * @return the dictElementShortName
+ */
+ public String getDictElementShortName() {
+ return dictElementShortName;
+ }
+
+ /**
+ * @param dictElementShortName
+ * the dictElementShortName to set
+ */
+ public void setDictElementShortName(String dictElementShortName) {
+ this.dictElementShortName = dictElementShortName;
+ }
+
+ /**
+ * @return the dictElementDesc
+ */
+ public String getDictElementDesc() {
+ return dictElementDesc;
+ }
+
+ /**
+ * @param dictElementDesc
+ * the dictElementDesc to set
+ */
+ public void setDictElementDesc(String dictElementDesc) {
+ this.dictElementDesc = dictElementDesc;
+ }
+
+ /**
+ * @return the dictElementType
+ */
+ public String getDictElementType() {
+ return dictElementType;
+ }
+
+ /**
+ * @param dictElementType
+ * the dictElementType to set
+ */
+ public void setDictElementType(String dictElementType) {
+ this.dictElementType = dictElementType;
+ }
+
+ /**
+ * @return the createdBy
+ */
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * @param createdBy
+ * the createdBy to set
+ */
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * @return the updatedBy
+ */
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ /**
+ * @param updatedby
+ * the updatedBy to set
+ */
+ public void setUpdatedBy(String updatedby) {
+ updatedBy = updatedby;
+ }
+
+ /**
+ * @return the lastUpdatedDate
+ */
+ public String getLastUpdatedDate() {
+ return lastUpdatedDate;
+ }
+
+ /**
+ * @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/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
index 0867b962e..8d3807b76 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java
@@ -29,37 +29,38 @@ import org.onap.clamp.clds.dao.CldsDao;
* Represent a CLDS Event.
*/
public class CldsEvent {
- public static final String ACTION_TEST = "TEST";
- public static final String ACTION_CREATE = "CREATE";
- public static final String ACTION_MODIFY = "MODIFY";
- public static final String ACTION_SUBMIT = "SUBMIT";
+ public static final String ACTION_TEST = "TEST";
+ public static final String ACTION_CREATE = "CREATE";
+ public static final String ACTION_MODIFY = "MODIFY";
+ public static final String ACTION_SUBMIT = "SUBMIT";
// an update before model is active
- public static final String ACTION_RESUBMIT = "RESUBMIT";
+ public static final String ACTION_RESUBMIT = "RESUBMIT";
// For simplified models
- public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
+ public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
+ public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
// only from dcae
- public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
+ public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
// only from dcae
- public static final String ACTION_DEPLOY = "DEPLOY";
+ public static final String ACTION_DEPLOY = "DEPLOY";
// only from dcae
- public static final String ACTION_UNDEPLOY = "UNDEPLOY";
- public static final String ACTION_UPDATE = "UPDATE";
- public static final String ACTION_DELETE = "DELETE";
- public static final String ACTION_STOP = "STOP";
- public static final String ACTION_RESTART = "RESTART";
+ public static final String ACTION_UNDEPLOY = "UNDEPLOY";
+ public static final String ACTION_UPDATE = "UPDATE";
+ public static final String ACTION_DELETE = "DELETE";
+ public static final String ACTION_STOP = "STOP";
+ public static final String ACTION_RESTART = "RESTART";
public static final String ACTION_STATE_INITIATED = "INITIATED";
- public static final String ACTION_STATE_SENT = "SENT";
+ public static final String ACTION_STATE_SENT = "SENT";
public static final String ACTION_STATE_COMPLETED = "COMPLETED";
- public static final String ACTION_STATE_RECEIVED = "RECEIVED";
- public static final String ACTION_STATE_ERROR = "ERROR";
- public static final String ACTION_STATE_ANY = null;
-
- private String id;
- private String actionCd;
- private String actionStateCd;
- private String processInstanceId;
- private String userid;
+ public static final String ACTION_STATE_RECEIVED = "RECEIVED";
+ public static final String ACTION_STATE_ERROR = "ERROR";
+ public static final String ACTION_STATE_ANY = null;
+
+ private String id;
+ private String actionCd;
+ private String actionStateCd;
+ private String processInstanceId;
+ private String userid;
public String getId() {
return id;
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
index 382d4e89a..a24885f73 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java
@@ -25,12 +25,14 @@ package org.onap.clamp.clds.model;
public class CldsInfo {
- private String userName;
- private String cldsVersion;
+ private String userName;
+ private String cldsVersion;
private boolean permissionReadCl;
private boolean permissionUpdateCl;
private boolean permissionReadTemplate;
private boolean permissionUpdateTemplate;
+ private boolean permissionReadTosca;
+ private boolean permissionUpdateTosca;
public String getUserName() {
return userName;
@@ -80,4 +82,20 @@ public class CldsInfo {
this.permissionUpdateTemplate = permissionUpdateTemplate;
}
+ public boolean isPermissionReadTosca() {
+ return permissionReadTosca;
+ }
+
+ public void setPermissionReadTosca(boolean permissionReadTosca) {
+ this.permissionReadTosca = permissionReadTosca;
+ }
+
+ public boolean isPermissionUpdateTosca() {
+ return permissionUpdateTosca;
+ }
+
+ public void setPermissionUpdateTosca(boolean permissionUpdateTosca) {
+ this.permissionUpdateTosca = permissionUpdateTosca;
+ }
+
}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
index 8b2399565..55f4dfd64 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
@@ -139,7 +139,8 @@ public class CldsModel {
} else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED)
|| event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY)
|| event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY)
- || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)) {
+ || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)
+ || event.isActionAndStateCd(CldsEvent.ACTION_SUBMITPOLICY, CldsEvent.ACTION_STATE_ANY)) {
status = STATUS_ACTIVE;
} else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) {
status = STATUS_STOPPED;
@@ -185,14 +186,15 @@ public class CldsModel {
permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST,
CldsEvent.ACTION_DELETE);
if (isSimplifiedModel()) {
- permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_TEST,
- CldsEvent.ACTION_DELETE);
+ permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
+ CldsEvent.ACTION_TEST, CldsEvent.ACTION_DELETE);
}
break;
case CldsEvent.ACTION_MODIFY:
permittedActionCd = Arrays.asList(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_DELETE);
if (isSimplifiedModel()) {
- permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
+ permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_SUBMITPOLICY,
+ CldsEvent.ACTION_DELETE);
}
break;
case CldsEvent.ACTION_SUBMIT:
@@ -202,6 +204,9 @@ public class CldsModel {
case CldsEvent.ACTION_SUBMITDCAE:
permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMITDCAE, CldsEvent.ACTION_DELETE);
break;
+ case CldsEvent.ACTION_SUBMITPOLICY:
+ permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
+ break;
case CldsEvent.ACTION_DISTRIBUTE:
permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT,
CldsEvent.ACTION_DELETE);
@@ -226,10 +231,17 @@ public class CldsModel {
case CldsEvent.ACTION_UPDATE:
permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE,
CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY);
+ if (isPolicyOnly()) {
+ permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
+ }
break;
case CldsEvent.ACTION_STOP:
permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
CldsEvent.ACTION_UNDEPLOY);
+ if (isPolicyOnly()) {
+ permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART,
+ CldsEvent.ACTION_DELETE);
+ }
break;
default:
logger.warn("Invalid current actionCd: " + actionCd);
@@ -252,6 +264,22 @@ public class CldsModel {
return result;
}
+ private boolean isPolicyOnly() {
+ boolean result = false;
+ try {
+ if (propText != null) {
+ JsonNode modelJson = JacksonUtils.getObjectMapperInstance().readTree(propText);
+ JsonNode policyOnlyJson = modelJson.get("policyOnly");
+ if (policyOnlyJson != null && policyOnlyJson.asBoolean()) {
+ result = true;
+ }
+ }
+ } catch (IOException e) {
+ logger.error("Error while parsing propText json", e);
+ }
+ return result;
+ }
+
/**
* Validate requestedActionCd - determine permittedActionCd and then check
* if contained in permittedActionCd Throw IllegalArgumentException if
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
new file mode 100644
index 000000000..4a2352527
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
@@ -0,0 +1,130 @@
+/*-
+ * ============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.List;
+
+import org.onap.clamp.clds.dao.CldsDao;
+
+public class CldsToscaModel extends CldsToscaModelRevision {
+
+ private String id;
+ private String policyType;
+ private String toscaModelName;
+ private String toscaModelYaml;
+
+ /**
+ * Creates or updates Tosca Model to DB
+ *
+ * @param cldsDao
+ * @param userId
+ */
+ public CldsToscaModel save(CldsDao cldsDao, String userId) {
+ CldsToscaModel cldsToscaModel = null;
+ // TODO tosca parsing logic
+ this.setToscaModelJson("{}");
+ this.setPolicyType("Aging");// TODO update with subString or node_type from the model name
+ List<CldsToscaModel> toscaModels = cldsDao.getToscaModelByName(this.getToscaModelName());
+ if (toscaModels != null && !toscaModels.isEmpty()) {
+ CldsToscaModel toscaModel = toscaModels.stream().findFirst().get();
+ // CldsToscaModelRevision modelRevision =
+ // revisions.stream().max(Comparator.comparingDouble(CldsToscaModelRevision::getVersion)).get();
+ this.setVersion(incrementVersion(toscaModel.getVersion()));
+ this.setId(toscaModel.getId());
+ this.setUserId(userId);
+ cldsToscaModel = cldsDao.updateToscaModelWithNewVersion(this, userId);
+ } else {
+ this.setVersion(1);
+ cldsToscaModel = cldsDao.insToscaModel(this, userId);
+ }
+ return cldsToscaModel;
+ }
+
+ private double incrementVersion(double curVersion) {
+ return curVersion + 1;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the policyType
+ */
+ public String getPolicyType() {
+ return policyType;
+ }
+
+ /**
+ * @param policyType
+ * the policyType to set
+ */
+ public void setPolicyType(String policyType) {
+ this.policyType = policyType;
+ }
+
+ /**
+ * @return the toscaModelName
+ */
+ public String getToscaModelName() {
+ return toscaModelName;
+ }
+
+ /**
+ * @param toscaModelName
+ * the toscaModelName to set
+ */
+ public void setToscaModelName(String toscaModelName) {
+ this.toscaModelName = toscaModelName;
+ }
+
+ /**
+ * @return the toscaModelYaml
+ */
+ @Override
+ public String getToscaModelYaml() {
+ return toscaModelYaml;
+ }
+
+ /**
+ * @param toscaModelYaml
+ * the toscaModelYaml to set
+ */
+ @Override
+ public void setToscaModelYaml(String toscaModelYaml) {
+ this.toscaModelYaml = toscaModelYaml;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
new file mode 100644
index 000000000..5c6f4aa5d
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
@@ -0,0 +1,132 @@
+/*-
+ * ============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;
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the toscaModelName
+ */
+ public String getToscaModelName() {
+ return toscaModelName;
+ }
+
+ /**
+ * @param toscaModelName
+ * the toscaModelName to set
+ */
+ public void setToscaModelName(String toscaModelName) {
+ this.toscaModelName = toscaModelName;
+ }
+
+ /**
+ * @return the policyType
+ */
+ public String getPolicyType() {
+ return policyType;
+ }
+
+ /**
+ * @param policyType
+ * the policyType to set
+ */
+ public void setPolicyType(String policyType) {
+ this.policyType = policyType;
+ }
+
+ /**
+ * @return the toscaModelRevisions
+ */
+ public List<CldsToscaModelRevision> getToscaModelRevisions() {
+ return toscaModelRevisions;
+ }
+
+ /**
+ * @param toscaModelRevisions
+ * the toscaModelRevisions to set
+ */
+ public void setToscaModelRevisions(List<CldsToscaModelRevision> toscaModelRevisions) {
+ this.toscaModelRevisions = toscaModelRevisions;
+ }
+
+ /**
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * @param userId
+ * the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * @return the lastUpdatedDate
+ */
+ public String getLastUpdatedDate() {
+ return lastUpdatedDate;
+ }
+
+ /**
+ * @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
new file mode 100644
index 000000000..bfb0536ec
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
@@ -0,0 +1,144 @@
+/*-
+ * ============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;
+
+ /**
+ * @return the revisionId
+ */
+ public String getRevisionId() {
+ return revisionId;
+ }
+
+ /**
+ * @param revisionId
+ * the revisionId to set
+ */
+ public void setRevisionId(String revisionId) {
+ this.revisionId = revisionId;
+ }
+
+ /**
+ * @return the toscaModelYaml
+ */
+ public String getToscaModelYaml() {
+ return toscaModelYaml;
+ }
+
+ /**
+ * @param toscaModelYaml
+ * the toscaModelYaml to set
+ */
+ public void setToscaModelYaml(String toscaModelYaml) {
+ this.toscaModelYaml = toscaModelYaml;
+ }
+
+ /**
+ * @return the version
+ */
+ public double getVersion() {
+ return version;
+ }
+
+ /**
+ * @param version
+ * the version to set
+ */
+ public void setVersion(double version) {
+ this.version = version;
+ }
+
+ /**
+ * @return the toscaModelJson
+ */
+ public String getToscaModelJson() {
+ return toscaModelJson;
+ }
+
+ /**
+ * @param toscaModelJson
+ * the toscaModelJson to set
+ */
+ public void setToscaModelJson(String toscaModelJson) {
+ this.toscaModelJson = toscaModelJson;
+ }
+
+ /**
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * @param userId
+ * the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * @return the createdDate
+ */
+ public String getCreatedDate() {
+ return createdDate;
+ }
+
+ /**
+ * @param createdDate
+ * the createdDate to set
+ */
+ public void setCreatedDate(String createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ /**
+ * @return the lastUpdatedDate
+ */
+ public String getLastUpdatedDate() {
+ return lastUpdatedDate;
+ }
+
+ /**
+ * @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/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
index 6e3e86593..7caba41f0 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
@@ -66,6 +66,7 @@ public class PolicyItem implements Cloneable {
private String targetResourceId;
private String recipeInfo;
private String recipeLevel;
+ private String recipeInput;
private Map<String, String> recipePayload;
private String oapRop;
private String oapLimit;
@@ -76,7 +77,7 @@ public class PolicyItem implements Cloneable {
* @param node
* @throws IOException
*/
- public PolicyItem(JsonNode node) throws IOException {
+ public PolicyItem(JsonNode node) throws IOException {
id = AbstractModelElement.getValueByName(node, "_id");
recipe = AbstractModelElement.getValueByName(node, "recipe");
maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries");
@@ -89,11 +90,10 @@ public class PolicyItem implements Cloneable {
}
recipeInfo = AbstractModelElement.getValueByName(node, "recipeInfo");
recipeLevel = AbstractModelElement.getValueByName(node, "recipeLevel");
- String payload = AbstractModelElement.getValueByName(node, "recipeInput");
-
+ recipeInput = AbstractModelElement.getValueByName(node, "recipeInput");
+ String payload = AbstractModelElement.getValueByName(node, "recipePayload");
if (payload != null && !payload.isEmpty()) {
- //recipePayload = JacksonUtils.getObjectMapperInstance().convertValue(payload, Map.class);
recipePayload = JacksonUtils.getObjectMapperInstance().readValue(payload, new TypeReference<Map<String, String>>(){});
}
oapRop = AbstractModelElement.getValueByName(node, "oapRop");
@@ -215,6 +215,10 @@ public class PolicyItem implements Cloneable {
return recipeLevel;
}
+ public String getRecipeInput() {
+ return recipeInput;
+ }
+
public Map<String, String> getRecipePayload() {
return recipePayload;
}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
new file mode 100644
index 000000000..5d5e218a2
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/service/CldsDictionaryService.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.service;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.model.CldsDictionary;
+import org.onap.clamp.clds.model.CldsDictionaryItem;
+import org.onap.clamp.clds.util.LoggingUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * REST services to manage dictionary and dictionary items for Tosca Model
+ */
+@Component
+public class CldsDictionaryService extends SecureServiceBase {
+
+ @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}")
+ private String cldsPermissionTypeTosca;
+ @Value("${clamp.config.security.permission.instance:dev}")
+ private String cldsPermissionInstance;
+ private SecureServicePermission permissionReadTosca;
+ private SecureServicePermission permissionUpdateTosca;
+
+ @Autowired
+ private CldsDao cldsDao;
+
+ @PostConstruct
+ private final void initConstruct() {
+ permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+ permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "update");
+ }
+
+ /**
+ * REST Service that creates or Updates a Dictionary
+ *
+ * @param dictionaryName
+ * @param cldsDictionary
+ * @return CldsDictionary that was created in DB.
+ */
+ public ResponseEntity<CldsDictionary> createOrUpdateDictionary(String dictionaryName,
+ CldsDictionary cldsDictionary) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionary", getPrincipalName());
+ // TODO revisit based on new permissions
+ isAuthorized(permissionUpdateTosca);
+ if (cldsDictionary == null) {
+ cldsDictionary = new CldsDictionary();
+ cldsDictionary.setDictionaryName(dictionaryName);
+ }
+ cldsDictionary.save(dictionaryName, cldsDao, getUserId());
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "createOrUpdateDictionary success", this.getClass().getName());
+ auditLogger.info("createOrUpdateDictionary completed");
+ return new ResponseEntity<>(cldsDictionary, HttpStatus.OK);
+ }
+
+ /**
+ * REST Service that creates or Updates a Dictionary Elements for dictionary in DB
+ *
+ * @param dictionaryName
+ * @param dictionaryItem
+ * @return CldsDictionaryItem
+ * A dictionary items that was created or updated in DB
+ */
+ public ResponseEntity<CldsDictionaryItem> createOrUpdateDictionaryElements(String dictionaryName,
+ CldsDictionaryItem dictionaryItem) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsDictionaryService: createOrUpdateDictionaryElements", getPrincipalName());
+ // TODO revisit based on new permissions
+ isAuthorized(permissionUpdateTosca);
+ dictionaryItem.save(dictionaryName, cldsDao, getUserId());
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "createOrUpdateDictionaryElements success", this.getClass().getName());
+ auditLogger.info("createOrUpdateDictionaryElements completed");
+ return new ResponseEntity<>(dictionaryItem, HttpStatus.OK);
+ }
+
+ /**
+ * Rest Service that retrieves all CLDS dictionary in DB
+ *
+ * @return CldsDictionary List
+ * List of CldsDictionary available in DB
+ */
+ public ResponseEntity<List<CldsDictionary>> getAllDictionaryNames() {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsDictionaryService: getAllDictionaryNames", getPrincipalName());
+ // TODO revisit based on new permissions
+ isAuthorized(permissionReadTosca);
+ List<CldsDictionary> dictionaries = cldsDao.getDictionary(null, null);
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "getAllDictionaryNames success", this.getClass().getName());
+ auditLogger.info("getAllDictionaryNames completed");
+ return new ResponseEntity<>(dictionaries, HttpStatus.OK);
+ }
+
+ /**
+ * Rest Service that retrieves all CLDS dictionary items in DB for a give dictionary name
+ *
+ * @param dictionaryName
+ * @return CldsDictionaryItem list
+ * List of CLDS Dictionary items for a given dictionary name
+ */
+ public ResponseEntity<List<CldsDictionaryItem>> getDictionaryElementsByName(String dictionaryName) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsDictionaryService: getDictionaryElementsByName", getPrincipalName());
+ // TODO revisit based on new permissions
+ isAuthorized(permissionReadTosca);
+ List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName, null, null);
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "getAllDictionaryNames success", this.getClass().getName());
+ auditLogger.info("getAllDictionaryNames completed");
+ return new ResponseEntity<>(dictionaryItems, HttpStatus.OK);
+ }
+
+ public ResponseEntity<?> deleteDictionary() {
+ return null;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java b/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
index 6bebde921..7027cf1b5 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsInfoProvider.java
@@ -45,6 +45,8 @@ class CldsInfoProvider {
cldsInfo.setPermissionUpdateCl(cldsService.isAuthorizedNoException(cldsService.permissionUpdateCl));
cldsInfo.setPermissionReadTemplate(cldsService.isAuthorizedNoException(cldsService.permissionReadTemplate));
cldsInfo.setPermissionUpdateTemplate(cldsService.isAuthorizedNoException(cldsService.permissionUpdateTemplate));
+ cldsInfo.setPermissionReadTosca(cldsService.isAuthorizedNoException(cldsService.permissionReadTosca));
+ cldsInfo.setPermissionUpdateTosca(cldsService.isAuthorizedNoException(cldsService.permissionUpdateTosca));
return cldsInfo;
}
}
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index bc58ee69f..521f3ce27 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -105,6 +105,8 @@ public class CldsService extends SecureServiceBase {
final SecureServicePermission permissionUpdateCl;
final SecureServicePermission permissionReadTemplate;
final SecureServicePermission permissionUpdateTemplate;
+ final SecureServicePermission permissionReadTosca;
+ final SecureServicePermission permissionUpdateTosca;
private final CldsDao cldsDao;
private final XslTransformer cldsBpmnTransformer;
@@ -125,6 +127,7 @@ public class CldsService extends SecureServiceBase {
@Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}") String cldsPermissionTypeClEvent,
@Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}") String cldsPermissionTypeFilterVf,
@Value("${clamp.config.security.permission.type.template:permission-type-template}") String cldsPermissionTypeTemplate,
+ @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}") String cldsPermissionTypeTosca,
@Value("${clamp.config.security.permission.instance:dev}") String cldsPermissionInstance) {
this.cldsDao = cldsDao;
this.cldsBpmnTransformer = cldsBpmnTransformer;
@@ -144,6 +147,9 @@ public class CldsService extends SecureServiceBase {
"read");
permissionUpdateTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance,
"update");
+ permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+ permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance,
+ "update");
}
/*
@@ -401,7 +407,7 @@ public class CldsService extends SecureServiceBase {
retrievedModel = CldsModel.retrieve(cldsDao, modelName, false);
}
if (retrievedModel != null) {
- if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
+ if (!isTest && !errorCase && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
new file mode 100644
index 000000000..f33039f01
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.model.CldsToscaModel;
+import org.onap.clamp.clds.util.LoggingUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * REST services to manage Tosca Model
+ */
+@Component
+public class CldsToscaService extends SecureServiceBase {
+
+ @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}")
+ private String cldsPermissionTypeTosca;
+ @Value("${clamp.config.security.permission.instance:dev}")
+ private String cldsPermissionInstance;
+ private SecureServicePermission permissionReadTosca;
+ private SecureServicePermission permissionUpdateTosca;
+
+ @Autowired
+ private CldsDao cldsDao;
+
+ @PostConstruct
+ private final void initConstruct() {
+ permissionReadTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "read");
+ permissionUpdateTosca = SecureServicePermission.create(cldsPermissionTypeTosca, cldsPermissionInstance, "update");
+ }
+
+ /**
+ * REST service to upload a new Tosca Model or update an existing Tosca model with new version.
+ * This API will parse the Tosca model yaml and generates a JSON schema out of it.
+ *
+ * @param toscaModelName
+ * Tosca model name to be used as a key
+ * @param cldsToscaModel
+ * Object containing the tosca model yaml
+ *
+ * @return clds tosca models - list of CLDS tosca models for a given policy type
+ */
+ public ResponseEntity<?> parseToscaModelAndSave(String toscaModelName, CldsToscaModel cldsToscaModel ) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsToscaService: Parse Tosca model and save", getPrincipalName());
+ //TODO revisit based on new permissions
+ isAuthorized(permissionUpdateTosca);
+ cldsToscaModel.setToscaModelName(toscaModelName);
+ cldsToscaModel = cldsToscaModel.save(cldsDao, getUserId());
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "Parse Tosca model and save success", this.getClass().getName());
+ auditLogger.info("Parse Tosca model and save completed");
+ return new ResponseEntity<>(cldsToscaModel, HttpStatus.CREATED);
+ }
+
+ /**
+ * REST service to retrieve all Tosca models from the CLDS database.
+ *
+ * @return clds tosca models - list of CLDS tosca models
+ */
+ public ResponseEntity<List<CldsToscaModel>> getAllToscaModels() {
+
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsToscaService: Get All tosca models", getPrincipalName());
+ //TODO revisit based on new permissions
+ isAuthorized(permissionReadTosca);
+ List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getAllToscaModels()).get();
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "Get All tosca models success", this.getClass().getName());
+ auditLogger.info("Get All tosca models");
+ return new ResponseEntity<>(cldsToscaModels, HttpStatus.OK);
+ }
+
+ /**
+ * REST service that retrieves a CLDS Tosca model by model name from the database.
+ *
+ * @param toscaModelName
+ * Path param with tosca model name
+ *
+ * @return clds tosca model - CLDS tosca model for a given tosca model name
+ */
+ public ResponseEntity<CldsToscaModel> getToscaModel(String toscaModelName) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by model name", getPrincipalName());
+ //TODO revisit based on new permissions
+ isAuthorized(permissionReadTosca);
+ List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getToscaModelByName(toscaModelName)).get();
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "Get tosca models by model name success", this.getClass().getName());
+ auditLogger.info("GET tosca models by model name completed");
+ return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(), HttpStatus.OK);
+ }
+
+
+ /**
+ * REST service that retrieves a CLDS Tosca model lists for a policy type from the database.
+ *
+ * @param policyType
+ * @return clds tosca model - CLDS tosca model for a given policy type
+ */
+ public ResponseEntity<CldsToscaModel> getToscaModelsByPolicyType(String policyType) {
+ Date startTime = new Date();
+ LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by policyType", getPrincipalName());
+ //TODO revisit based on new permissions
+ isAuthorized(permissionReadTosca);
+ List<CldsToscaModel> cldsToscaModels = Optional.ofNullable(cldsDao.getToscaModelByPolicyType(policyType)).get();
+ LoggingUtils.setTimeContext(startTime, new Date());
+ LoggingUtils.setResponseContext("0", "Get tosca models by policyType success", this.getClass().getName());
+ auditLogger.info("GET tosca models by policyType completed");
+ return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(), HttpStatus.OK);
+ }
+
+ public ResponseEntity<?> deleteToscaModelById(String toscaModeId) {
+ //TODO
+ return null;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/ClampTimer.java b/src/main/java/org/onap/clamp/clds/util/ClampTimer.java
deleted file mode 100644
index 794e2b486..000000000
--- a/src/main/java/org/onap/clamp/clds/util/ClampTimer.java
+++ /dev/null
@@ -1,54 +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.util;
-
-import java.util.Timer;
-import java.util.TimerTask;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.springframework.security.core.context.SecurityContextHolder;
-
-/**
- * Define the ClampTimer and CleanupTask, to clear up the Spring Authenticataion info when time is up.
- */
-
-public class ClampTimer {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ClampTimer.class);
- Timer timer;
-
- public ClampTimer(int seconds) {
- timer = new Timer();
- timer.schedule(new CleanupTask(), seconds*1000);
- }
-
- class CleanupTask extends TimerTask {
- public void run() {
- logger.debug("Time is up, clear the Spring authenticataion settings");
- //Clear up the spring authentication
- SecurityContextHolder.getContext().setAuthentication(null);
- //Terminate the timer thread
- timer.cancel();
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
index cdb2e29c5..759edb1d9 100644
--- a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
+++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.util;
@@ -31,21 +31,21 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
+
import javax.servlet.http.HttpServletRequest;
+import javax.validation.constraints.NotNull;
+import org.onap.clamp.clds.service.DefaultUserNameHandler;
import org.slf4j.MDC;
import org.slf4j.event.Level;
import org.springframework.security.core.context.SecurityContextHolder;
-import org.onap.clamp.clds.service.DefaultUserNameHandler;
-
/**
* This class handles the special info that appear in the log, like RequestID,
* time context, ...
@@ -66,7 +66,7 @@ public class LoggingUtils {
* Constructor
*/
public LoggingUtils(final EELFLogger loggerP) {
- this.mLogger = checkNotNull(loggerP);
+ this.mLogger = checkNotNull(loggerP);
}
/**
@@ -86,7 +86,7 @@ public class LoggingUtils {
MDC.put("ServerIPAddress", InetAddress.getLocalHost().getHostAddress());
} catch (UnknownHostException e) {
logger.error("Failed to initiate setRequestContext", e);
- }
+ }
}
/**
@@ -149,7 +149,7 @@ public class LoggingUtils {
* @return A string with the request ID
*/
public static String getRequestId() {
- String requestId = (String) MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
if (requestId == null || requestId.isEmpty()) {
requestId = UUID.randomUUID().toString();
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
@@ -162,9 +162,9 @@ public class LoggingUtils {
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat;
}
-
-
-
+
+
+
/*********************************************************************************************
* Method for ONAP Application Logging Specification v1.2
********************************************************************************************/
@@ -181,7 +181,7 @@ public class LoggingUtils {
final String requestID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.REQUEST_ID));
final String invocationID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.INVOCATION_ID));
final String partnerName = defaultToEmpty(request.getHeader(ONAPLogConstants.Headers.PARTNER_NAME));
-
+
// Default the partner name to the user name used to login to clamp
if (partnerName.equalsIgnoreCase(EMPTY_MESSAGE)) {
MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, new DefaultUserNameHandler().retrieveUserName(SecurityContextHolder.getContext()));
@@ -192,8 +192,8 @@ public class LoggingUtils {
// depending on where you need them to appear, OR extend the
// ServiceDescriptor to add them.
MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC)
- .format(DateTimeFormatter.ISO_INSTANT));
+ ZonedDateTime.now(ZoneOffset.UTC)
+ .format(DateTimeFormatter.ISO_INSTANT));
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestID);
MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationID);
MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, defaultToEmpty(request.getRemoteAddr()));
@@ -203,7 +203,7 @@ public class LoggingUtils {
// Default the service name to the requestURI, in the event that
// no value has been provided.
if (serviceName == null ||
- serviceName.equalsIgnoreCase(EMPTY_MESSAGE)) {
+ serviceName.equalsIgnoreCase(EMPTY_MESSAGE)) {
MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
}
@@ -217,7 +217,7 @@ public class LoggingUtils {
*/
public void exiting(String code, String descrption, Level severity, ONAPLogConstants.ResponseStatus status) {
try {
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, defaultToEmpty(code));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, defaultToEmpty(code));
MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, defaultToEmpty(descrption));
MDC.put(ONAPLogConstants.MDCs.RESPONSE_SEVERITY, defaultToEmpty(severity));
MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, defaultToEmpty(status));
@@ -241,11 +241,11 @@ public class LoggingUtils {
// Set standard HTTP headers on (southbound request) builder.
con.setRequestProperty(ONAPLogConstants.Headers.REQUEST_ID,
- defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));
+ defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));
con.setRequestProperty(ONAPLogConstants.Headers.INVOCATION_ID,
- invocationID);
+ invocationID);
con.setRequestProperty(ONAPLogConstants.Headers.PARTNER_NAME,
- defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));
+ defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));
invokeContext(targetEntity, targetServiceName, invocationID);
@@ -314,8 +314,8 @@ public class LoggingUtils {
MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, defaultToEmpty(targetServiceName));
MDC.put(ONAPLogConstants.MDCs.INVOCATIONID_OUT, invocationID);
MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC)
- .format(DateTimeFormatter.ISO_INSTANT));
+ ZonedDateTime.now(ZoneOffset.UTC)
+ .format(DateTimeFormatter.ISO_INSTANT));
}
/**
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html
index bf151d7fb..c66047ccc 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html
@@ -38,7 +38,10 @@
<b style="font-size:14px;">User Permissions:</b>
<div ng-if="userInfo['permissionReadTemplate']">Read Template</div>
<div ng-if="userInfo['permissionReadCl']">Read Model</div>
+ <div ng-if="userInfo['permissionReadTosca']">Read Tosca</div>
<div ng-if="userInfo['permissionUpdateCl']">Edit Model</div>
+ <div ng-if="userInfo['permissionUpdateTemplate']">Edit Template</div>
+ <div ng-if="userInfo['permissionUpdateTosca']">Edit Tosca</div>
</div>
</div>
<div attribute-test="extrauserinfof" class="modal-footer">
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 35895539b..fe7eabc5e 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -102,7 +102,7 @@ async.queue.capacity=500
#For EELF logback file
#com.att.eelf.logging.path=
-com.att.eelf.logging.file=logback-default.xml
+clamp.config.logback.filename=logback-default.xml
#The log folder that will be used in logback.xml file
clamp.config.log.path=/var/log/ONAP/clamp
clamp.config.files.systemProperties=classpath:/system.properties
@@ -211,5 +211,6 @@ clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage
clamp.config.security.permission.type.cl.event=org.onap.clds.cl.event
clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf
clamp.config.security.permission.type.template=org.onap.clamp.clds.template
+clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b5069159f..9e2e3c979 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -64,7 +64,7 @@ server.ssl.key-store-type=PKCS12
server.ssl.key-alias=clamp@clamp.onap.org
## Config part for Client certificates
-server.ssl.client-auth=need
+server.ssl.client-auth=want
server.ssl.trust-store=classpath:/clds/aaf/truststoreONAPall.jks
server.ssl.trust-store-password=changeit
@@ -118,8 +118,8 @@ async.max.pool.size=20
async.queue.capacity=500
#For EELF logback file
-#com.att.eelf.logging.path=
-com.att.eelf.logging.file=logback-default.xml
+#clamp.config.logback.path=
+clamp.config.logback.filename=logback-default.xml
#The log folder that will be used in logback.xml file
clamp.config.log.path=/var/log/ONAP/clamp
clamp.config.files.systemProperties=classpath:/system.properties
@@ -228,6 +228,7 @@ clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage
clamp.config.security.permission.type.cl.event=org.onap.clds.cl.event
clamp.config.security.permission.type.filter.vf=org.onap.clamp.clds.filter.vf
clamp.config.security.permission.type.template=org.onap.clamp.clds.template
+clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
@@ -236,7 +237,7 @@ clamp.config.cadi.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
clamp.config.cadi.cadiLoglevel=DEBUG
clamp.config.cadi.cadiLatitude=37.78187
clamp.config.cadi.cadiLongitude=-122.26147
-clamp.config.cadi.aafLocateUrl=https://aaf-onap-beijing-test.osaaf.org
+clamp.config.cadi.aafLocateUrl=https://aaf-onap-test.osaaf.org:8095
clamp.config.cadi.cadiKeystorePassword=enc:V_kq_EwDNb4itWp_lYfDGXIWJzemHGkhkZOxAQI9IHs
clamp.config.cadi.cadiTruststorePassword=enc:Mj0YQqNCUKbKq2lPp1kTFQWeqLxaBXKNwd5F1yB1ukf
#clamp.config.cadi.oauthTokenUrl=https://AAF_LOCATE_URL/AAF_NS.token:2.0/token
diff --git a/src/main/resources/clds/camel/rest/clds-services.xml b/src/main/resources/clds/camel/rest/clds-services.xml
index 1ea8213f5..e67fb162d 100644
--- a/src/main/resources/clds/camel/rest/clds-services.xml
+++ b/src/main/resources/clds/camel/rest/clds-services.xml
@@ -1,95 +1,181 @@
<rests xmlns="http://camel.apache.org/schema/spring">
- <rest>
- <get uri="/clds/cldsDetails" outType="org.onap.clamp.clds.model.CldsMonitoringDetails" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getCLDSDetails()" />
- </get>
- <get uri="/clds/cldsInfo" outType="org.onap.clamp.clds.model.CldsInfo" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getCldsInfo()" />
- </get>
- <get uri="/healthcheck" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsHealthcheckService?method=gethealthcheck()" />
- </get>
- <get uri="/clds/model/bpmn/{modelName}" produces="text/xml">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getBpmnXml(${header.modelName})" />
- </get>
- <get uri="/clds/model/image/{modelName}" produces="text/xml">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getImageXml(${header.modelName})" />
- </get>
- <get uri="/clds/model/{modelName}" outType="org.onap.clamp.clds.model.CldsModel" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getModel(${header.modelName})" />
- </get>
- <put uri="/clds/model/{modelName}" type="org.onap.clamp.clds.model.CldsModel" consumes="application/json" outType="org.onap.clamp.clds.model.CldsModel" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=putModel(${header.modelName},${body})" />
- </put>
- <get uri="/clds/model-names" outType="org.onap.clamp.clds.model.ValueItem" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getModelNames()" />
- </get>
- <put uri="/clds/action/{action}/{modelName}?test={test}" type="org.onap.clamp.clds.model.CldsModel" consumes="application/json" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=putModelAndProcessAction(${header.action},${header.modelName},${header.test},${body})" />
- </put>
- <post uri="/clds/dcae/event?test={test}" type="org.onap.clamp.clds.model.DcaeEvent" consumes="application/json" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=postDcaeEvent(${header.test},${body})" />
- </post>
- <get uri="/clds/sdc/services" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcServices()" />
- </get>
- <get uri="/clds/properties" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcProperties()" />
- </get>
- <get uri="/clds/properties/{serviceInvariantUUID}?refresh={refresh}" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcPropertiesByServiceUUIDForRefresh(${header.serviceInvariantUUID},${header.refresh})" />
- </get>
- <put uri="/clds/deploy/{modelName}" type="org.onap.clamp.clds.model.CldsModel" consumes="application/json" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=deployModel(${header.modelName},${body})" />
- </put>
- <put uri="/clds/undeploy/{modelName}" type="org.onap.clamp.clds.model.CldsModel" consumes="application/json" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsService?method=unDeployModel(${header.modelName},${body})" />
- </put>
-
-
-
-
- <get uri="/cldsTempate/template/bpmn/{templateName}" produces="text/xml">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getBpmnTemplate(${header.templateName})" />
- </get>
- <get uri="/cldsTempate/template/image/{templateName}" produces="text/xml">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getImageXml(${header.templateName})" />
- </get>
- <get uri="/cldsTempate/template/{templateName}" outType="org.onap.clamp.clds.model.CldsTemplate" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getTemplate(${header.templateName})" />
- </get>
- <put uri="/cldsTempate/template/{templateName}" type="org.onap.clamp.clds.model.CldsTemplate" consumes="application/json" outType="org.onap.clamp.clds.model.CldsTemplate" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=putTemplate(${header.templateName},${body})" />
- </put>
- <get uri="/cldsTempate/template-names" outType="org.onap.clamp.clds.model.ValueItem" produces="application/json">
- <to
- uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getTemplateNames()" />
- </get>
-
-
-
- <get uri="/user/getUser" produces="text/plain">
- <to
- uri="bean:org.onap.clamp.clds.service.UserService?method=getUser()" />
- </get>
- </rest>
+ <rest>
+ <get uri="/clds/cldsDetails"
+ outType="org.onap.clamp.clds.model.CldsMonitoringDetails"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getCLDSDetails()" />
+ </get>
+ <get uri="/clds/cldsInfo"
+ outType="org.onap.clamp.clds.model.CldsInfo"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getCldsInfo()" />
+ </get>
+ <get uri="/healthcheck" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsHealthcheckService?method=gethealthcheck()" />
+ </get>
+ <get uri="/clds/model/bpmn/{modelName}" produces="text/xml">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getBpmnXml(${header.modelName})" />
+ </get>
+ <get uri="/clds/model/image/{modelName}" produces="text/xml">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getImageXml(${header.modelName})" />
+ </get>
+ <get uri="/clds/model/{modelName}"
+ outType="org.onap.clamp.clds.model.CldsModel"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getModel(${header.modelName})" />
+ </get>
+ <put uri="/clds/model/{modelName}"
+ type="org.onap.clamp.clds.model.CldsModel"
+ consumes="application/json"
+ outType="org.onap.clamp.clds.model.CldsModel"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=putModel(${header.modelName},${body})" />
+ </put>
+ <get uri="/clds/model-names"
+ outType="org.onap.clamp.clds.model.ValueItem"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getModelNames()" />
+ </get>
+ <put uri="/clds/action/{action}/{modelName}?test={test}"
+ type="org.onap.clamp.clds.model.CldsModel"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=putModelAndProcessAction(${header.action},${header.modelName},${header.test},${body})" />
+ </put>
+ <post uri="/clds/dcae/event?test={test}"
+ type="org.onap.clamp.clds.model.DcaeEvent"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=postDcaeEvent(${header.test},${body})" />
+ </post>
+ <get uri="/clds/sdc/services" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcServices()" />
+ </get>
+ <get uri="/clds/properties" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcProperties()" />
+ </get>
+ <get
+ uri="/clds/properties/{serviceInvariantUUID}?refresh={refresh}"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=getSdcPropertiesByServiceUUIDForRefresh(${header.serviceInvariantUUID},${header.refresh})" />
+ </get>
+ <put uri="/clds/deploy/{modelName}"
+ type="org.onap.clamp.clds.model.CldsModel"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=deployModel(${header.modelName},${body})" />
+ </put>
+ <put uri="/clds/undeploy/{modelName}"
+ type="org.onap.clamp.clds.model.CldsModel"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsService?method=unDeployModel(${header.modelName},${body})" />
+ </put>
+
+
+
+
+ <get uri="/cldsTempate/template/bpmn/{templateName}"
+ produces="text/xml">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getBpmnTemplate(${header.templateName})" />
+ </get>
+ <get uri="/cldsTempate/template/image/{templateName}"
+ produces="text/xml">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getImageXml(${header.templateName})" />
+ </get>
+ <get uri="/cldsTempate/template/{templateName}"
+ outType="org.onap.clamp.clds.model.CldsTemplate"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getTemplate(${header.templateName})" />
+ </get>
+ <put uri="/cldsTempate/template/{templateName}"
+ type="org.onap.clamp.clds.model.CldsTemplate"
+ consumes="application/json"
+ outType="org.onap.clamp.clds.model.CldsTemplate"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=putTemplate(${header.templateName},${body})" />
+ </put>
+ <get uri="/cldsTempate/template-names"
+ outType="org.onap.clamp.clds.model.ValueItem"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsTemplateService?method=getTemplateNames()" />
+ </get>
+
+
+ <put uri="/tosca/models/{toscaModelName}"
+ type="org.onap.clamp.clds.model.CldsToscaModel"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=parseToscaModelAndSave(${header.toscaModelName},${body})" />
+ </put>
+ <get uri="/tosca/models/policyType/{policyType}"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModelsByPolicyType(${header.policyType})" />
+ </get>
+ <get uri="/tosca/models"
+ outType="org.onap.clamp.clds.model.CldsToscaModel"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getAllToscaModels()" />
+ </get>
+ <get uri="/tosca/models/{toscaModelName}"
+ outType="org.onap.clamp.clds.model.CldsToscaModel"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModel(${header.toscaModelName})" />
+ </get>
+
+
+ <put uri="/dictionary/{dictionaryName}"
+ type="org.onap.clamp.clds.model.CldsDictionary"
+ outType="org.onap.clamp.clds.model.CldsDictionary"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=createOrUpdateDictionary(${header.dictionaryName},${body})" />
+ </put>
+
+ <get uri="/dictionary"
+ outType="org.onap.clamp.clds.model.CldsDictionary"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=getAllDictionaryNames()" />
+ </get>
+
+ <put uri="/dictionary/{dictionaryName}/items"
+ type="org.onap.clamp.clds.model.CldsDictionaryItem"
+ outType="org.onap.clamp.clds.model.CldsDictionaryItem"
+ consumes="application/json" produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=createOrUpdateDictionaryElements(${header.dictionaryName},${body})" />
+ </put>
+
+ <get uri="/dictionary/{dictionaryName}/items"
+ outType="org.onap.clamp.clds.model.CldsDictionary"
+ produces="application/json">
+ <to
+ uri="bean:org.onap.clamp.clds.service.CldsDictionaryService?method=getDictionaryElementsByName(${header.dictionaryName})" />
+ </get>
+
+ <get uri="/user/getUser" produces="text/plain">
+ <to
+ uri="bean:org.onap.clamp.clds.service.UserService?method=getUser()" />
+ </get>
+ </rest>
</rests>
diff --git a/src/main/resources/clds/clds-users.json b/src/main/resources/clds/clds-users.json
index 18ab7d394..b4d73a29f 100644
--- a/src/main/resources/clds/clds-users.json
+++ b/src/main/resources/clds/clds-users.json
@@ -8,7 +8,9 @@
"org.onap.clamp.clds.cl.manage|dev|*",
"org.onap.clamp.clds.filter.vf|dev|*",
"org.onap.clamp.clds.template|dev|read",
- "org.onap.clamp.clds.template|dev|update"
+ "org.onap.clamp.clds.template|dev|update",
+ "org.onap.clamp.clds.tosca|dev|read",
+ "org.onap.clamp.clds.tosca|dev|update"
]
},
{
@@ -21,7 +23,9 @@
"org.onap.clamp.clds.cl.manage|dev|*",
"org.onap.clamp.clds.filter.vf|dev|*",
"org.onap.clamp.clds.template|dev|read",
- "org.onap.clamp.clds.template|dev|update"
+ "org.onap.clamp.clds.template|dev|update",
+ "org.onap.clamp.clds.tosca|dev|read",
+ "org.onap.clamp.clds.tosca|dev|update"
]
}
]
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index dae39d3ac..086cc5356 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,9 +1,9 @@
<configuration scan="true" scanPeriod="60 seconds"
debug="true">
<springProperty name="logbackFilePath"
- source="com.att.eelf.logging.path" />
+ source="clamp.config.logback.path" />
<springProperty name="logbackFileName"
- source="com.att.eelf.logging.file" />
+ source="clamp.config.logback.filename" />
<springProperty name="logDirectory"
source="clamp.config.log.path" />