Merge "Replacing the VFC with VFModule"
authorSébastien Determe <sebastien.determe@intl.att.com>
Tue, 23 Apr 2019 09:16:11 +0000 (09:16 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 23 Apr 2019 09:16:11 +0000 (09:16 +0000)
38 files changed:
src/main/java/org/onap/clamp/authorization/AuthorizationController.java
src/main/java/org/onap/clamp/clds/Application.java
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java
src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java
src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java
src/main/java/org/onap/clamp/clds/dao/CldsDao.java
src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
src/main/java/org/onap/clamp/clds/model/CldsTemplate.java
src/main/java/org/onap/clamp/clds/model/CldsToscaModelDetails.java
src/main/java/org/onap/clamp/clds/model/CldsToscaModelRevision.java
src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
src/main/java/org/onap/clamp/clds/model/sdc/SdcResource.java
src/main/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfo.java
src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceInfo.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintArtifact.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
src/main/java/org/onap/clamp/clds/transform/XslTransformer.java
src/main/java/org/onap/clamp/clds/util/ClampVersioning.java
src/main/java/org/onap/clamp/clds/util/CryptoUtils.java
src/main/java/org/onap/clamp/clds/util/LogMessages.java
src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
src/main/java/org/onap/clamp/clds/util/XmlTools.java
src/main/java/org/onap/clamp/clds/util/drawing/AwtUtils.java
src/main/java/org/onap/clamp/clds/util/drawing/ClampGraph.java
src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java

index 511b950..4a35f45 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2019 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -39,8 +41,6 @@ import org.onap.clamp.util.PrincipalUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Component;
 
 /**
@@ -57,12 +57,8 @@ public class AuthorizationController {
     @Autowired
     private ClampProperties refProp;
 
-    private SecurityContext securityContext = SecurityContextHolder.getContext();
-    private static final String permPrefix = "security.permission.type.";
-    private static final String permInstance = "security.permission.instance";
-
-    public AuthorizationController() {
-    }
+    private static final String PERM_PREFIX = "security.permission.type.";
+    private static final String PERM_INSTANCE = "security.permission.instance";
 
     /**
      * Insert authorize the api based on the permission
@@ -77,8 +73,8 @@ public class AuthorizationController {
      *        The action of the permissions. e.g. read
      */
     public void authorize(Exchange camelExchange, String typeVar, String instanceVar, String action) {
-        String type = refProp.getStringValue(permPrefix + typeVar);
-        String instance = refProp.getStringValue(permInstance);
+        String type = refProp.getStringValue(PERM_PREFIX + typeVar);
+        String instance = refProp.getStringValue(PERM_INSTANCE);
 
         if (null == type || type.isEmpty()) {
             //authorization is turned off, since the permission is not defined
@@ -93,9 +89,8 @@ public class AuthorizationController {
         LoggingUtils.setTargetContext("Clamp", "authorize");
         LoggingUtils.setTimeContext(startTime, new Date());
         securityLogger.debug("checking if {} has permission: {}", principalName, perm);
-        try {
-            isUserPermitted(perm);
-        } catch (NotAuthorizedException nae) {
+
+        if (!isUserPermitted(perm)){
             String msg = principalName + " does not have permission: " + perm;
             LoggingUtils.setErrorContext("100", "Authorization Error");
             securityLogger.warn(msg);
@@ -103,45 +98,26 @@ public class AuthorizationController {
         }
     }
 
-    private boolean isUserPermitted(SecureServicePermission inPermission) {
-        boolean authorized = false;
+    public boolean isUserPermitted(SecureServicePermission inPermission) {
+
         String principalName = PrincipalUtils.getPrincipalName();
         // check if the user has the permission key or the permission key with a
         // combination of  all instance and/or all action.
-        if (hasRole(inPermission.getKey())) {
-            auditLogger.info("{} authorized because user has permission with * for instance: {}", 
-                  principalName, inPermission.getKey());
-            authorized = true;
+        if (hasRole(inPermission.getKey()) || hasRole(inPermission.getKeyAllInstance())) {
+            auditLogger.info("{} authorized because user has permission with * for instance: {}",
+                    principalName, inPermission.getKey());
+            return true;
             // the rest of these don't seem to be required - isUserInRole method
             // appears to take * as a wildcard
-        } else if (hasRole(inPermission.getKeyAllInstance())) {
-            auditLogger.info("{} authorized because user has permission with * for instance: {}", 
-                  principalName, inPermission.getKey());
-            authorized = true;
         } else if (hasRole(inPermission.getKeyAllInstanceAction())) {
-            auditLogger.info("{} authorized because user has permission with * for instance and * for action: {}", 
-                  principalName, inPermission.getKey());
-            authorized = true;
+            auditLogger.info("{} authorized because user has permission with * for instance and * for action: {}",
+                    principalName, inPermission.getKey());
+            return true;
         } else if (hasRole(inPermission.getKeyAllAction())) {
             auditLogger.info("{} authorized because user has permission with * for action: {}",
-                  principalName, inPermission.getKey());
-            authorized = true;
+                    principalName, inPermission.getKey());
+            return true;
         } else {
-            throw new NotAuthorizedException("");
-        }
-        return authorized;
-    }
-
-    /**
-     * Verify whether the user has the permission.
-     *
-     * @param inPermission
-     *        The permissions to verify
-     */
-    public boolean isUserPermittedNoException(SecureServicePermission inPermission) {
-        try {
-            return isUserPermitted(inPermission);
-        } catch (NotAuthorizedException e) {
             return false;
         }
     }
index 025dbab..f6dfdc0 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -54,9 +56,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
-@SpringBootApplication
 @ComponentScan(basePackages = { "org.onap.clamp" })
-@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
+@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
     UserDetailsServiceAutoConfiguration.class })
 @EnableJpaRepositories(basePackages = { "org.onap.clamp" })
 @EntityScan(basePackages = { "org.onap.clamp" })
@@ -135,7 +136,8 @@ public class Application extends SpringBootServletInitializer {
     private Connector createRedirectConnector(int redirectSecuredPort) {
         if (redirectSecuredPort <= 0) {
             eelfLogger.warn(
-                "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1 (Connector disabled)");
+                "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1"
+                  + " (Connector disabled)");
             return null;
         }
         Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
index f74af49..f7aff0e 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights\r
  *                             reserved.\r
  * ================================================================================\r
+ * Modifications Copyright (c) 2019 Samsung\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -54,7 +56,6 @@ public class DcaeDispatcherServices {
     private static final String STATUS_URL_LOG = "Status URL extracted: ";\r
     private static final String DCAE_URL_PREFIX = "/dcae-deployments/";\r
     private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";\r
-    public static final String DCAE_REQUESTID_PROPERTY_NAME = "dcae.header.requestId";\r
     private static final String DCAE_LINK_FIELD = "links";\r
     private static final String DCAE_STATUS_FIELD = "status";\r
 \r
@@ -99,7 +100,9 @@ public class DcaeDispatcherServices {
         Date startTime = new Date();\r
         LoggingUtils.setTargetContext("DCAE", "getOperationStatus");\r
         try {\r
-            String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null, null, "DCAE", null, null);\r
+            String responseStr = dcaeHttpConnectionManager.doHttpRequest(statusUrl, "GET", null,\r
+                                                                         null, "DCAE", null,\r
+                                                                         null);\r
             JSONObject jsonObj = parseResponse(responseStr);\r
             String operationType = (String) jsonObj.get("operationType");\r
             String status = (String) jsonObj.get(DCAE_STATUS_FIELD);\r
@@ -156,6 +159,7 @@ public class DcaeDispatcherServices {
 \r
     /***\r
      * Returns status URL for deleteExistingDeployment operation.\r
+     *\r
      * @param deploymentId\r
      *        The deployment ID\r
      * @param serviceTypeId\r
index dcf0542..7f20919 100644 (file)
@@ -70,7 +70,7 @@ public class DcaeInventoryServices {
      */\r
     @Autowired\r
     public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
-               HttpConnectionManager httpConnectionManager) {\r
+                                 HttpConnectionManager httpConnectionManager) {\r
         this.refProp = refProp;\r
         this.cldsDao = cldsDao;\r
         this.httpConnectionManager = httpConnectionManager;\r
@@ -97,8 +97,8 @@ public class DcaeInventoryServices {
         }\r
         try {\r
             // Below are the properties required for calling the dcae inventory\r
-            ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null, false,\r
-                "{}", cldsModel.getPropText());\r
+            ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null,\r
+                                                       false, "{}", cldsModel.getPropText());\r
             Global global = prop.getGlobal();\r
             String invariantServiceUuid = global.getService();\r
             List<String> resourceUuidList = global.getResourceVf();\r
index bc82cb3..e996ae8 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -30,6 +32,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.EnumMap;
 
 import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.PolicyChain;
@@ -99,7 +102,7 @@ public class GuardPolicyAttributesConstructor {
     }
 
     private static Map<AttributeType, Map<String, String>> createAttributesMap(Map<String, String> matchingAttributes) {
-        Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
+        Map<AttributeType, Map<String, String>> attributes = new EnumMap<>(AttributeType.class);
         attributes.put(AttributeType.MATCHING, matchingAttributes);
         return attributes;
     }
index c884891..43209b2 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -84,7 +86,6 @@ public class PolicyClient {
     public static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix";
     public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix";
     public static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type";
-    public static final String POLICY_GUARD_SUFFIX = "_Guard";
     public static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath";
 
     @Autowired
@@ -382,10 +383,12 @@ public class PolicyClient {
      * Use list Policy API to retrieve the policy. Return true if policy exists
      * otherwise return false.
      *
-     * @param policyNamePrefix
-     *        The Policy Name Prefix
      * @param prop
      *        The ModelProperties
+     * @param policyPrefix
+     *        The Policy Name Prefix
+     * @param policyNameWithPrefix
+     *        The Policy Full Name
      * @return The response message from policy
      * @throws PolicyConfigException
      *         In case of issues with policy engine
index 6b8f043..ae0de07 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -173,7 +175,7 @@ public class TcaRequestFormatter {
     /**
      * This method updates the blueprint that is received in the UI with the TCA
      * Json.
-     * 
+     *
      * @param refProp
      *            * The refProp generally created by Spring, it's an access on
      *            the clds-references.properties file
@@ -188,11 +190,11 @@ public class TcaRequestFormatter {
         String jsonPolicy = JsonUtils.GSON.toJson(createPolicyContent(refProp, modelProperties, null, null, null));
         logger.info("Yaml that will be updated:" + yamlValue);
         Yaml yaml = new Yaml();
-        Map<String, Object> loadedYaml = (Map<String, Object>) yaml.load(yamlValue);
-        Map<String, Object> nodeTemplates = (Map<String, Object>) loadedYaml.get("node_templates");
-        Map<String, Object> tcaObject = (Map<String, Object>) nodeTemplates.get("tca_tca");
-        Map<String, Object> propsObject = (Map<String, Object>) tcaObject.get("properties");
-        Map<String, Object> appPreferences = (Map<String, Object>) propsObject.get("app_preferences");
+        Map<String, Map> loadedYaml = yaml.load(yamlValue);
+        Map<String, Map> nodeTemplates = loadedYaml.get("node_templates");
+        Map<String, Map> tcaObject = nodeTemplates.get("tca_tca");
+        Map<String, Map> propsObject = tcaObject.get("properties");
+        Map<String, String> appPreferences = propsObject.get("app_preferences");
         appPreferences.put("tca_policy", jsonPolicy);
         String blueprint = yaml.dump(loadedYaml);
         logger.info("Yaml updated:" + blueprint);
index 602ee62..876acc8 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -36,6 +38,9 @@ import org.onap.clamp.clds.util.JsonUtils;
 
 public class CldsUserJsonDecoder {
 
+    private CldsUserJsonDecoder() {
+    }
+
     /**
      * This method decodes the JSON file provided to a CldsUser Array. The stream is
      * closed after this call, this is not possible to reuse it.
@@ -68,7 +73,4 @@ public class CldsUserJsonDecoder {
             throw new CldsUsersException("Exception occurred during the decoding of the clds-users.json", e);
         }
     }
-
-    private CldsUserJsonDecoder() {
-    }
 }
index 529753f..20d5d69 100644 (file)
@@ -23,9 +23,6 @@
 
 package org.onap.clamp.clds.config.sdc;
 
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
 import com.google.gson.reflect.TypeToken;
 import java.io.InputStream;
 import java.io.InputStreamReader;
index b7a7f0e..ad2751b 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2018 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,9 +25,6 @@
 
 package org.onap.clamp.clds.config.sdc;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
 import com.google.gson.JsonObject;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -49,8 +48,7 @@ import org.springframework.core.io.Resource;
  */
 public class SdcControllersConfiguration {
 
-    private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcControllersConfiguration.class);
-    public static final String CONTROLLER_SUBTREE_KEY = "sdc-connections";
+    private static final String CONTROLLER_SUBTREE_KEY = "sdc-connections";
     @Autowired
     protected ApplicationContext appContext;
     /**
index 8378af8..44228b2 100644 (file)
@@ -199,17 +199,13 @@ public class CldsDao {
             .addValue("v_model_blueprint_text", model.getBlueprintText())
             .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId())
             .addValue("v_deployment_status_url", model.getDeploymentStatusUrl())
-            .addValue("v_control_name_prefix", model.getControlNamePrefix())
+            .addValue(V_CONTROL_NAME_PREFIX, model.getControlNamePrefix())
             .addValue(V_CONTROL_NAME_UUID, model.getControlNameUuid());
         Map<String, Object> out = logSqlExecution(procSetModel, in);
         model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
         model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
         model.setId((String) (out.get("v_model_id")));
-        model.getEvent().setId((String) (out.get("v_event_id")));
-        model.getEvent().setActionCd((String) out.get("v_action_cd"));
-        model.getEvent().setActionStateCd((String) out.get("v_action_state_cd"));
-        model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id"));
-        model.getEvent().setUserid((String) out.get("v_event_user_id"));
+        setEventProp(model.getEvent(), out);
         return model;
     }
 
@@ -318,14 +314,9 @@ public class CldsDao {
             .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")));
-        template.setBpmnId((String) (out.get("v_template_bpmn_id")));
-        template.setImageId((String) (out.get("v_template_image_id")));
-        template.setImageUserid((String) out.get("v_template_image_user_id"));
-        template.setPropId((String) (out.get("v_template_doc_id")));
-        template.setPropUserid((String) out.get("v_template_doc_user_id"));
+
+        // properties to setup the template is return from the logSqlExecution method
+        setTemplateBaseProp(template, logSqlExecution(procSetTemplate, in));
     }
 
     /**
@@ -349,20 +340,35 @@ public class CldsDao {
         CldsTemplate template = new CldsTemplate();
         template.setName(templateName);
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName);
+
         Map<String, Object> out = logSqlExecution(procGetTemplate, in);
-        template.setId((String) (out.get("v_template_id")));
-        template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id")));
-        template.setBpmnId((String) (out.get("v_template_bpmn_id")));
-        template.setBpmnText((String) (out.get("v_template_bpmn_text")));
-        template.setImageId((String) (out.get("v_template_image_id")));
-        template.setImageUserid((String) out.get("v_template_image_user_id"));
-        template.setImageText((String) out.get("v_template_image_text"));
-        template.setPropId((String) (out.get("v_template_doc_id")));
-        template.setPropUserid((String) out.get("v_template_doc_user_id"));
+        setTemplateBaseProp(template, out);
+
+        // additional template setting's
         template.setPropText((String) out.get("v_template_doc_text"));
+        template.setBpmnText((String) out.get("v_template_bpmn_text"));
+        template.setImageText((String) out.get("v_template_image_text"));
         return template;
     }
 
+    /**
+     * Helper method to setup the base template properties
+     *
+     * @param template
+     *  the template
+     * @param prop
+     *  collection with the properties
+     */
+    private void setTemplateBaseProp(CldsTemplate template, Map prop) {
+        template.setId((String) prop.get("v_template_id"));
+        template.setBpmnUserid((String) prop.get("v_template_bpmn_user_id"));
+        template.setBpmnId((String) prop.get("v_template_bpmn_id"));
+        template.setImageId((String) prop.get("v_template_image_id"));
+        template.setImageUserid((String) prop.get("v_template_image_user_id"));
+        template.setPropId((String) prop.get("v_template_doc_id"));
+        template.setPropUserid((String) prop.get("v_template_doc_user_id"));
+    }
+
     private static Map<String, Object> logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) {
         try {
             return call.execute(source);
@@ -452,22 +458,35 @@ public class CldsDao {
     private void populateModelProperties(CldsModel model, Map out) {
         model.setControlNamePrefix((String) out.get(V_CONTROL_NAME_PREFIX));
         model.setControlNameUuid((String) out.get(V_CONTROL_NAME_UUID));
-        model.setId((String) (out.get("v_model_id")));
-        model.setTemplateId((String) (out.get("v_template_id")));
+        model.setId((String) out.get("v_model_id"));
+        model.setTemplateId((String) out.get("v_template_id"));
         model.setTemplateName((String) (out.get("v_template_name")));
         model.setBpmnText((String) out.get("v_template_bpmn_text"));
         model.setPropText((String) out.get("v_model_prop_text"));
         model.setImageText((String) out.get("v_template_image_text"));
         model.setDocText((String) out.get("v_template_doc_text"));
         model.setBlueprintText((String) out.get("v_model_blueprint_text"));
-        model.getEvent().setId((String) (out.get("v_event_id")));
-        model.getEvent().setActionCd((String) out.get("v_action_cd"));
-        model.getEvent().setActionStateCd((String) out.get("v_action_state_cd"));
-        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.setDeploymentStatusUrl((String) out.get("v_deployment_status_url"));
+
+        setEventProp(model.getEvent(), out);
+    }
+
+    /**
+     * Helper method to setup the event prop to the CldsEvent class
+     *
+     * @param event
+     *  the clds event
+     * @param prop
+     *  collection with the configuration
+     */
+    private void setEventProp(CldsEvent event, Map prop) {
+        event.setId((String) prop.get("v_event_id"));
+        event.setActionCd((String) prop.get("v_action_cd"));
+        event.setActionStateCd((String) prop.get("v_action_state_cd"));
+        event.setProcessInstanceId((String) prop.get("v_event_process_instance_id"));
+        event.setUserid((String) prop.get("v_event_user_id"));
     }
 
     /**
@@ -507,14 +526,14 @@ public class CldsDao {
         SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
         List<CldsToscaModel> cldsToscaModels = new ArrayList<>();
 
-        String toscaModelSql = new StringBuilder("SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, " +
-                "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp, " +
-                "tmr.lastUpdatedTimestamp")
-                .append(toscaModelName != null ? (", tmr.tosca_model_yaml") : "")
+        String toscaModelSql = new StringBuilder("SELECT tm.tosca_model_name, tm.tosca_model_id, tm.policy_type, "
+                + "tmr.tosca_model_revision_id, tmr.tosca_model_json, tmr.version, tmr.user_id, tmr.createdTimestamp,"
+                + "tmr.lastUpdatedTimestamp").append(toscaModelName != null ? (", tmr.tosca_model_yaml") : "")
                 .append(" FROM tosca_model tm, tosca_model_revision tmr WHERE tm.tosca_model_id = tmr.tosca_model_id")
                 .append(toscaModelName != null ? (" AND tm.tosca_model_name = '" + toscaModelName + "'") : "")
                 .append(policyType != null ? (" AND tm.policy_type = '" + policyType + "'") : "")
-                .append(" AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id=st.tosca_model_id)")
+                .append(" AND tmr.version = (select max(version) from tosca_model_revision st where tmr.tosca_model_id"
+                + "=st.tosca_model_id)")
                 .toString();
 
         List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(toscaModelSql);
@@ -555,7 +574,7 @@ public class CldsDao {
             .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")));
+        cldsToscaModel.setRevisionId((String) out.get("v_revision_id"));
         return cldsToscaModel;
     }
 
@@ -593,7 +612,7 @@ public class CldsDao {
             .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")));
+        cldsDictionary.setDictionaryId((String) out.get("v_dictionary_id"));
     }
 
     /**
@@ -633,7 +652,7 @@ public class CldsDao {
         String whereFilter = " WHERE ";
         if (dictionaryName != null) {
             whereFilter += "dictionary_name = '" + dictionaryName + "'";
-            if (dictionaryId != null){
+            if (dictionaryId != null) {
                 whereFilter += " AND dictionary_id = '" + dictionaryId + "'";
             }
         } else if (dictionaryId != null) {
@@ -641,8 +660,8 @@ public class CldsDao {
         } else {
             whereFilter = "";
         }
-        String dictionarySql = new StringBuilder("SELECT dictionary_id, dictionary_name, created_by, " +
-                "modified_by, timestamp FROM dictionary")
+        String dictionarySql = new StringBuilder("SELECT dictionary_id, dictionary_name, created_by, "
+                "modified_by, timestamp FROM dictionary")
                 .append(whereFilter).toString();
 
         List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(dictionarySql);
@@ -677,7 +696,7 @@ public class CldsDao {
             .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")));
+        cldsDictionaryItem.setDictElementId((String) out.get("v_dict_element_id"));
     }
 
     /**
index f058a9e..586899a 100644 (file)
@@ -20,6 +20,7 @@
  * ===================================================================
  *
  */
+
 package org.onap.clamp.clds.filter;
 
 import com.att.eelf.configuration.EELFLogger;
index 8f66204..8f34083 100644 (file)
@@ -73,7 +73,7 @@ public class CldsTemplate {
      * @param name The template name to retrieve
      * @param okIfNotFound 
      *     The flag indicating whether exception will be returned in case nothing is found
-     * @return
+     * @return Clds template from DB
      */
     public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
         // get from db
index a4ee734..4ee1deb 100644 (file)
@@ -27,8 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * Represents a CLDS Tosca model
- *
+ * Represents a CLDS Tosca model.
  */
 public class CldsToscaModelDetails {
 
index 68cd496..b9a7e0d 100644 (file)
@@ -22,8 +22,7 @@
  */
 
 /**
- * Represents a CLDS Tosca model revision
- *
+ * Represents a CLDS Tosca model revision.
  */
 
 package org.onap.clamp.clds.model;
index a880893..9b7f85d 100644 (file)
@@ -279,8 +279,8 @@ public class ModelProperties {
     /**
      * Replace all '-' with '_' within policy scope and name.
      *
-     * @param inName
-     * @return
+     * @param inName policy scope and name
+     * @return policy scope and name with "-" replaced with "_"
      */
     private String normalizePolicyScopeName(String inName) {
         return inName.replaceAll("-", "_");
@@ -359,6 +359,12 @@ public class ModelProperties {
         return global;
     }
 
+    /**
+     * Registers model element.
+     *
+     * @param modelElementClass model element class
+     * @param type model element type
+     */
     public static final synchronized void registerModelElement(Class<? extends AbstractModelElement> modelElementClass,
         String type) {
         if (!modelElementClasses.containsKey(modelElementClass.getClass())) {
index 6d766be..1855468 100644 (file)
@@ -83,10 +83,10 @@ public class PolicyItem implements Cloneable {
     private String guardActiveEnd;
 
     /**
-     * Parse Policy given json node.
+     * Parse Policy given JSON node.
      *
-     * @param item
-     * @throws IOException
+     * @param item policy in JSON format
+     * @throws IOException IO exception
      */
     public PolicyItem(JsonElement item) throws IOException {
         id = JsonUtils.getStringValueByName(item, "_id");
index 2474da0..515e77d 100644 (file)
@@ -126,31 +126,38 @@ public class SdcResource implements Comparable<SdcResource> {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         SdcResource other = (SdcResource) obj;
         if (resourceInstanceName == null) {
-            if (other.resourceInstanceName != null)
+            if (other.resourceInstanceName != null) {
                 return false;
-        } else if (!resourceInstanceName.equals(other.resourceInstanceName))
+            }
+        } else if (!resourceInstanceName.equals(other.resourceInstanceName)) {
             return false;
+        }
         if (resourceVersion == null) {
-            if (other.resourceVersion != null)
+            if (other.resourceVersion != null) {
                 return false;
-        } else if (!resourceVersion.equals(other.resourceVersion))
+            }
+        } else if (!resourceVersion.equals(other.resourceVersion)) {
             return false;
+        }
         return true;
     }
 
     /**
-     * Convert version String into a BigDecimal
+     * Convert version String into a BigDecimal.
      *
-     * @param versionText
-     * @return
+     * @param versionText version
+     * @return version in BigDecimal
      */
     private BigDecimal convertVersion(String versionText) {
         BigDecimal rtn = BigDecimal.valueOf(0.0);
index e853621..47192a5 100644 (file)
@@ -71,31 +71,38 @@ public class SdcResourceBasicInfo implements Comparable<SdcResourceBasicInfo> {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         SdcResourceBasicInfo other = (SdcResourceBasicInfo) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         if (version == null) {
-            if (other.version != null)
+            if (other.version != null) {
                 return false;
-        } else if (!version.equals(other.version))
+            }
+        } else if (!version.equals(other.version)) {
             return false;
+        }
         return true;
     }
 
     /**
-     * Convert version String into a BigDecimal
+     * Convert version String into a BigDecimal.
      *
-     * @param version
-     * @return
+     * @param version version
+     * @return version in BigDecimal
      */
     private BigDecimal convertVersion(String version) {
         BigDecimal rtn = BigDecimal.valueOf(0.0);
index a9c1e64..bb9f3f8 100644 (file)
@@ -146,31 +146,38 @@ public class SdcServiceInfo implements Comparable<SdcServiceInfo> {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         SdcServiceInfo other = (SdcServiceInfo) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         if (version == null) {
-            if (other.version != null)
+            if (other.version != null) {
                 return false;
-        } else if (!version.equals(other.version))
+            }
+        } else if (!version.equals(other.version)) {
             return false;
+        }
         return true;
     }
 
     /**
-     * Convert version String into a BigDecimal
+     * Convert version String into a BigDecimal.
      *
-     * @param versionText
-     * @return
+     * @param versionText version
+     * @return version in BigDecimal
      */
     private BigDecimal convertVersion(String versionText) {
         try {
index 6c7bfbb..35bc909 100644 (file)
  * ===================================================================
  * 
  */
-/**
- * This class is useful to store the information concerning
- * blueprint artifact extracted from SDC CSAR
- */
 
 package org.onap.clamp.clds.sdc.controller.installer;
 
 import org.onap.sdc.api.notification.IResourceInstance;
 
+/**
+ * This class is useful to store the information concerning
+ * blueprint artifact extracted from SDC CSAR.
+ */
 public class BlueprintArtifact {
 
     private String dcaeBlueprint;
index 5a8ccca..5dcffd6 100644 (file)
@@ -21,6 +21,7 @@
  * ===================================================================
  *
  */
+
 package org.onap.clamp.clds.sdc.controller.installer;
 
 import com.google.gson.Gson;
index 65d5592..5a21a1f 100644 (file)
@@ -75,10 +75,10 @@ public class CsarHandler {
     public static final String DATA_DEFINITION_NAME_SUFFIX = "Definitions/data.yml";
     public static final String DATA_DEFINITION_KEY = "data_types:";
 
-    public CsarHandler(INotificationData iNotif, String controller, String clampCsarPath) throws CsarHandlerException {
-        this.sdcNotification = iNotif;
+    public CsarHandler(INotificationData data, String controller, String clampCsarPath) throws CsarHandlerException {
+        this.sdcNotification = data;
         this.controllerName = controller;
-        this.artifactElement = searchForUniqueCsar(iNotif);
+        this.artifactElement = searchForUniqueCsar(data);
         this.csarFilePath = buildFilePathForCsar(artifactElement, clampCsarPath);
     }
 
index a785f41..ac4daef 100644 (file)
@@ -21,6 +21,7 @@
  * ===================================================================
  *
  */
+
 package org.onap.clamp.clds.sdc.controller.installer;
 
 import java.util.Objects;
@@ -58,8 +59,9 @@ public class MicroService {
 
     @Override
     public String toString() {
-        return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='" + inputFrom + '\'' + ", mappedNameJpa='"
-            + mappedNameJpa + '\'' + ", blueprintName='" + blueprintName + '\'' + '}';
+        return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='"
+                + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + ", blueprintName='"
+                + blueprintName + '\'' + '}';
     }
 
     public String getMappedNameJpa() {
index 2a89b19..bf7c502 100644 (file)
@@ -32,18 +32,15 @@ import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
 import java.io.IOException;
 import java.lang.reflect.Type;
-import java.security.GeneralSecurityException;
 import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.BadRequestException;
-import javax.ws.rs.NotAuthorizedException;
 import javax.xml.transform.TransformerException;
 
 import org.apache.camel.Produce;
-import org.apache.commons.codec.DecoderException;
 import org.json.simple.parser.ParseException;
 import org.onap.clamp.clds.camel.CamelProxy;
 import org.onap.clamp.clds.client.DcaeDispatcherServices;
index 16a817e..ea4e097 100644 (file)
@@ -40,7 +40,7 @@ import org.yaml.snakeyaml.Yaml;
 
 /**
  * Tosca Model Yaml parser and convertor to JSON Schema consumable for JSON
- * Editor
+ * Editor.
  *
  */
 public class ToscaYamlToJsonConvertor {
@@ -68,6 +68,8 @@ public class ToscaYamlToJsonConvertor {
     }
 
     /**
+     * Returns the CldsDao.
+     *
      * @return the cldsDao
      */
     public CldsDao getCldsDao() {
@@ -75,13 +77,20 @@ public class ToscaYamlToJsonConvertor {
     }
 
     /**
-     * @param cldsDao
-     *        the cldsDao to set
+     * Sets the CldsDao.
+     *
+     * @param cldsDao the cldsDao to set
      */
     public void setCldsDao(CldsDao cldsDao) {
         this.cldsDao = cldsDao;
     }
 
+    /**
+     * Parses Tosca YAML string.
+     *
+     * @param yamlString YAML string
+     * @return JSON string
+     */
     public String parseToscaYaml(String yamlString) {
 
         Yaml yaml = new Yaml();
@@ -91,7 +100,6 @@ public class ToscaYamlToJsonConvertor {
         }
         LinkedHashMap<String, Object> nodeTypes = new LinkedHashMap<>();
         LinkedHashMap<String, Object> dataNodes = new LinkedHashMap<>();
-        JSONObject jsonEditorObject = new JSONObject();
         JSONObject jsonParentObject = new JSONObject();
         JSONObject jsonTempObject = new JSONObject();
         parseNodeAndDataType(loadedYaml, nodeTypes, dataNodes);
@@ -99,6 +107,7 @@ public class ToscaYamlToJsonConvertor {
         if (jsonTempObject.length() > 0) {
             jsonParentObject = jsonTempObject;
         }
+        JSONObject jsonEditorObject = new JSONObject();
         jsonEditorObject.put(JsonEditorSchemaConstants.SCHEMA, jsonParentObject);
         return jsonEditorObject.toString();
     }
@@ -138,8 +147,8 @@ public class ToscaYamlToJsonConvertor {
                                     boolean isListNode = false;
                                     parseDescription((LinkedHashMap<String, Object>) ntPropertiesElement.getValue(),
                                         jsonParentObject);
-                                    LinkedHashMap<String, Object> parentPropertiesMap = (LinkedHashMap<String, Object>) ntPropertiesElement
-                                        .getValue();
+                                    LinkedHashMap<String, Object> parentPropertiesMap =
+                                            (LinkedHashMap<String, Object>) ntPropertiesElement.getValue();
                                     if (parentPropertiesMap.containsKey(ToscaSchemaConstants.TYPE)
                                         && ((String) parentPropertiesMap.get(ToscaSchemaConstants.TYPE))
                                             .contains(ToscaSchemaConstants.TYPE_MAP)
index a8f233e..85b3f5c 100644 (file)
@@ -45,6 +45,12 @@ public class XslTransformer {
 
     private Templates templates;
 
+    /**
+     * Sets Xsl Resource name.
+     *
+     * @param xslResourceName xsl resource name
+     * @throws TransformerConfigurationException exception if there is configuration error
+     */
     public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException {
         TransformerFactory tfactory = new TransformerFactoryImpl();
         tfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
@@ -55,8 +61,8 @@ public class XslTransformer {
     /**
      * Given xml input, return the transformed result.
      *
-     * @param xml
-     * @throws TransformerException
+     * @param xml xml string
+     * @throws TransformerException exception during transformation
      */
     public String doXslTransformToString(String xml) throws TransformerException {
         StringWriter output = new StringWriter(4096);
index 0633009..fd7a9a0 100644 (file)
@@ -43,6 +43,11 @@ public class ClampVersioning {
     private ClampVersioning() {
     }
 
+    /**
+     * Returns Clds version from properties.
+     *
+     * @return Clds version from properties
+     */
     public static String getCldsVersionFromProps() {
         String cldsVersion = "";
         Properties props = new Properties();
@@ -50,7 +55,7 @@ public class ClampVersioning {
             props.load(resourceStream);
             cldsVersion = props.getProperty(CLDS_VERSION_PROPERTY);
         } catch (Exception ex) {
-            LOGGER.error("Exception caught during the "+CLDS_VERSION_PROPERTY+" property reading", ex);
+            LOGGER.error("Exception caught during the " + CLDS_VERSION_PROPERTY + " property reading", ex);
         }
         return cldsVersion;
     }
index 07c4147..f08bf7b 100644 (file)
@@ -153,7 +153,7 @@ public final class CryptoUtils {
     }
 
     /**
-     * Reads SecretKeySpec from file specified by propertiesFileName
+     * Reads SecretKeySpec from file specified by propertiesFileName.
      *
      * @param propertiesFileName
      *            File name with properties
@@ -162,15 +162,15 @@ public final class CryptoUtils {
     private static SecretKeySpec readSecretKeySpec(String propertiesFileName) {
         Properties props = new Properties();
         try {
-               //Workaround fix to make encryption key configurable.
-               //System environment variable takes precedence for over clds/key.properties
-               String encryptionKey = System.getenv(AES_ENCRYPTION_KEY);
-               if(encryptionKey != null && encryptionKey.trim().length() > 0) {
-                       return getSecretKeySpec(encryptionKey);
-               } else {
-                       props.load(ResourceFileUtil.getResourceAsStream(propertiesFileName));
+            //Workaround fix to make encryption key configurable
+            // System environment variable takes precedence for over clds/key.properties
+            String encryptionKey = System.getenv(AES_ENCRYPTION_KEY);
+            if(encryptionKey != null && encryptionKey.trim().length() > 0) {
+                return getSecretKeySpec(encryptionKey);
+            } else {
+                props.load(ResourceFileUtil.getResourceAsStream(propertiesFileName));
                 return getSecretKeySpec(props.getProperty(KEY_PARAM));
-               }
+            }
         } catch (IOException | DecoderException e) {
             logger.error("Exception occurred during the key reading", e);
             return null;
index eaa1b2a..7f4c878 100644 (file)
@@ -27,7 +27,8 @@ import com.att.eelf.i18n.EELFResolvableErrorEnum;
 import com.att.eelf.i18n.EELFResourceManager;
 
 public enum LogMessages implements EELFResolvableErrorEnum {
-    LOGSERVICE_HELLO_MESSAGE, LOGSERVICE_EMAIL_ERROR, LOGSERVICE_EMAIL_CLASS, LOGSERVICE_EMAIL_CLASS_NULL, PROCESS_INSTANCE_ID;
+    LOGSERVICE_HELLO_MESSAGE, LOGSERVICE_EMAIL_ERROR, LOGSERVICE_EMAIL_CLASS, LOGSERVICE_EMAIL_CLASS_NULL,
+    PROCESS_INSTANCE_ID;
 
     static {
         EELFResourceManager.loadMessageBundle("logmessages");
index 47b4f9a..08bb976 100644 (file)
@@ -60,14 +60,15 @@ public class LoggingUtils {
     private static final String EMPTY_MESSAGE = "";\r
 \r
     /** Logger delegate. */\r
-    private EELFLogger mLogger;\r
+    private EELFLogger mlogger;\r
     /** Automatic UUID, overrideable per adapter or per invocation. */\r
     private static UUID sInstanceUUID = UUID.randomUUID();\r
+\r
     /**\r
-     * Constructor\r
+     * Constructor.\r
      */\r
     public LoggingUtils(final EELFLogger loggerP) {\r
-        this.mLogger = checkNotNull(loggerP);\r
+        this.mlogger = checkNotNull(loggerP);\r
     }\r
 \r
     /**\r
@@ -173,20 +174,21 @@ public class LoggingUtils {
     /**\r
      * Report <tt>ENTERING</tt> marker.\r
      *\r
-     * @param request non-null incoming request (wrapper).\r
-     * @return this.\r
+     * @param request non-null incoming request (wrapper)\r
+     * @param serviceName service name\r
      */\r
     public void entering(HttpServletRequest request, String serviceName) {\r
         MDC.clear();\r
         checkNotNull(request);\r
         // Extract MDC values from standard HTTP headers.\r
-        final String requestID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.REQUEST_ID));\r
-        final String invocationID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.INVOCATION_ID));\r
+        final String requestId = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.REQUEST_ID));\r
+        final String invocationId = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.INVOCATION_ID));\r
         final String partnerName = defaultToEmpty(request.getHeader(ONAPLogConstants.Headers.PARTNER_NAME));\r
 \r
         // Default the partner name to the user name used to login to clamp\r
         if (partnerName.equalsIgnoreCase(EMPTY_MESSAGE)) {\r
-            MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, new DefaultUserNameHandler().retrieveUserName(SecurityContextHolder.getContext()));\r
+            MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, new DefaultUserNameHandler()\r
+                    .retrieveUserName(SecurityContextHolder.getContext()));\r
         }\r
 \r
         // Set standard MDCs. Override this entire method if you want to set\r
@@ -196,28 +198,31 @@ public class LoggingUtils {
         MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,\r
             ZonedDateTime.now(ZoneOffset.UTC)\r
             .format(DateTimeFormatter.ISO_INSTANT));\r
-        MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestID);\r
-        MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationID);\r
+        MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);\r
+        MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);\r
         MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, defaultToEmpty(request.getRemoteAddr()));\r
         MDC.put(ONAPLogConstants.MDCs.SERVER_FQDN, defaultToEmpty(request.getServerName()));\r
         MDC.put(ONAPLogConstants.MDCs.INSTANCE_UUID, defaultToEmpty(sInstanceUUID));\r
 \r
         // Default the service name to the requestURI, in the event that\r
         // no value has been provided.\r
-        if (serviceName == null ||\r
-            serviceName.equalsIgnoreCase(EMPTY_MESSAGE)) {\r
+        if (serviceName == null\r
+                || serviceName.equalsIgnoreCase(EMPTY_MESSAGE)) {\r
             MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());\r
         } else {\r
             MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);\r
         }\r
 \r
-        this.mLogger.info(ONAPLogConstants.Markers.ENTRY);\r
+        this.mlogger.info(ONAPLogConstants.Markers.ENTRY);\r
     }\r
 \r
     /**\r
      * Report <tt>EXITING</tt> marker.\r
      *\r
-     * @return this.\r
+     * @param code response code\r
+     * @param descrption response description\r
+     * @param severity response severity\r
+     * @param status response status code\r
      */\r
     public void exiting(String code, String descrption, Level severity, ONAPLogConstants.ResponseStatus status) {\r
         try {\r
@@ -225,7 +230,7 @@ public class LoggingUtils {
             MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, defaultToEmpty(descrption));\r
             MDC.put(ONAPLogConstants.MDCs.RESPONSE_SEVERITY, defaultToEmpty(severity));\r
             MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, defaultToEmpty(status));\r
-            this.mLogger.info(ONAPLogConstants.Markers.EXIT);\r
+            this.mlogger.info(ONAPLogConstants.Markers.EXIT);\r
         }\r
         finally {\r
             MDC.clear();\r
@@ -236,28 +241,29 @@ public class LoggingUtils {
      * Report pending invocation with <tt>INVOKE</tt> marker,\r
      * setting standard ONAP logging headers automatically.\r
      *\r
-     * @param builder request builder, for setting headers.\r
-     * @param sync whether synchronous, nullable.\r
-     * @return invocation ID to be passed with invocation.\r
+     * @param con http URL connection\r
+     * @param targetEntity target entity\r
+     * @param targetServiceName target service name\r
+     * @return invocation ID to be passed with invocation\r
      */\r
     public HttpURLConnection invoke(final HttpURLConnection con, String targetEntity, String targetServiceName) {\r
-        final String invocationID = UUID.randomUUID().toString();\r
+        final String invocationId = UUID.randomUUID().toString();\r
 \r
         // Set standard HTTP headers on (southbound request) builder.\r
         con.setRequestProperty(ONAPLogConstants.Headers.REQUEST_ID,\r
             defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));\r
         con.setRequestProperty(ONAPLogConstants.Headers.INVOCATION_ID,\r
-            invocationID);\r
+            invocationId);\r
         con.setRequestProperty(ONAPLogConstants.Headers.PARTNER_NAME,\r
             defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));\r
 \r
-        invokeContext(targetEntity, targetServiceName, invocationID);\r
+        invokeContext(targetEntity, targetServiceName, invocationId);\r
 \r
         // Log INVOKE*, with the invocationID as the message body.\r
         // (We didn't really want this kind of behavior in the standard,\r
         // but is it worse than new, single-message MDC?)\r
-        this.mLogger.info(ONAPLogConstants.Markers.INVOKE);\r
-        this.mLogger.info(ONAPLogConstants.Markers.INVOKE_SYNC + "{"+ invocationID +"}");\r
+        this.mlogger.info(ONAPLogConstants.Markers.INVOKE);\r
+        this.mlogger.info(ONAPLogConstants.Markers.INVOKE_SYNC + "{" + invocationId + "}");\r
         return con;\r
     }\r
 \r
@@ -265,43 +271,47 @@ public class LoggingUtils {
      * Report pending invocation with <tt>INVOKE</tt> marker,\r
      * setting standard ONAP logging headers automatically.\r
      *\r
-     * @param builder request builder, for setting headers.\r
-     * @param sync whether synchronous, nullable.\r
-     * @return invocation ID to be passed with invocation.\r
+     * @param con http URL connection\r
+     * @param targetEntity target entity\r
+     * @param targetServiceName target service name\r
+     * @return invocation ID to be passed with invocation\r
      */\r
     public HttpsURLConnection invokeHttps(final HttpsURLConnection con, String targetEntity, String targetServiceName) {\r
-        final String invocationID = UUID.randomUUID().toString();\r
+        final String invocationId = UUID.randomUUID().toString();\r
 \r
         // Set standard HTTP headers on (southbound request) builder.\r
         con.setRequestProperty(ONAPLogConstants.Headers.REQUEST_ID,\r
             defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));\r
         con.setRequestProperty(ONAPLogConstants.Headers.INVOCATION_ID,\r
-            invocationID);\r
+            invocationId);\r
         con.setRequestProperty(ONAPLogConstants.Headers.PARTNER_NAME,\r
             defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));\r
 \r
-        invokeContext(targetEntity, targetServiceName, invocationID);\r
+        invokeContext(targetEntity, targetServiceName, invocationId);\r
 \r
         // Log INVOKE*, with the invocationID as the message body.\r
         // (We didn't really want this kind of behavior in the standard,\r
         // but is it worse than new, single-message MDC?)\r
-        this.mLogger.info(ONAPLogConstants.Markers.INVOKE);\r
-        this.mLogger.info(ONAPLogConstants.Markers.INVOKE_SYNC + "{"+ invocationID +"}");\r
+        this.mlogger.info(ONAPLogConstants.Markers.INVOKE);\r
+        this.mlogger.info(ONAPLogConstants.Markers.INVOKE_SYNC + "{" + invocationId + "}");\r
         return con;\r
     }\r
 \r
+    /**\r
+     * Invokes return context.\r
+     */\r
     public void invokeReturn() {\r
         // Add the Invoke-return marker and clear the needed MDC\r
-        this.mLogger.info(ONAPLogConstants.Markers.INVOKE_RETURN);\r
+        this.mlogger.info(ONAPLogConstants.Markers.INVOKE_RETURN);\r
         invokeReturnContext();\r
     }\r
 \r
     /**\r
      * Dependency-free nullcheck.\r
      *\r
-     * @param in to be checked.\r
-     * @param <T> argument (and return) type.\r
-     * @return input arg.\r
+     * @param in to be checked\r
+     * @param <T> argument (and return) type\r
+     * @return input arg\r
      */\r
     private static <T> T checkNotNull(final T in) {\r
         if (in == null) {\r
@@ -313,8 +323,8 @@ public class LoggingUtils {
     /**\r
      * Dependency-free string default.\r
      *\r
-     * @param in to be filtered.\r
-     * @return input string or null.\r
+     * @param in to be filtered\r
+     * @return input string or null\r
      */\r
     private static String defaultToEmpty(final Object in) {\r
         if (in == null) {\r
@@ -326,8 +336,8 @@ public class LoggingUtils {
     /**\r
      * Dependency-free string default.\r
      *\r
-     * @param in to be filtered.\r
-     * @return input string or null.\r
+     * @param in to be filtered\r
+     * @return input string or null\r
      */\r
     private static String defaultToUUID(final String in) {\r
         if (in == null) {\r
@@ -337,13 +347,13 @@ public class LoggingUtils {
     }\r
 \r
     /**\r
-     * Set target related logging variables in thread local data via MDC\r
+     * Set target related logging variables in thread local data via MDC.\r
      *\r
      * @param targetEntity Target entity (an external/sub component, for ex. "sdc")\r
      * @param targetServiceName Target service name (name of API invoked on target)\r
-     * @param invocationId The invocation ID\r
+     * @param invocationID The invocation ID\r
      */\r
-    private void invokeContext (String targetEntity, String targetServiceName, String invocationID) {\r
+    private void invokeContext(String targetEntity, String targetServiceName, String invocationID) {\r
         MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, defaultToEmpty(targetEntity));\r
         MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, defaultToEmpty(targetServiceName));\r
         MDC.put(ONAPLogConstants.MDCs.INVOCATIONID_OUT, invocationID);\r
@@ -353,10 +363,9 @@ public class LoggingUtils {
     }\r
 \r
     /**\r
-     * Clear target related logging variables in thread local data via MDC\r
-     *\r
+     * Clear target related logging variables in thread local data via MDC.\r
      */\r
-    private void invokeReturnContext () {\r
+    private void invokeReturnContext() {\r
         MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY);\r
         MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);\r
         MDC.remove(ONAPLogConstants.MDCs.INVOCATIONID_OUT);\r
index 391f008..a812fa1 100644 (file)
@@ -37,6 +37,13 @@ import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 
 public class XmlTools {
+
+    /**
+     * Transforms document to XML string.
+     *
+     * @param doc XML document
+     * @return XML string
+     */
     public static String exportXmlDocumentAsString(Document doc) {
         try {
             TransformerFactory tf = TransformerFactory.newInstance();
@@ -49,9 +56,15 @@ public class XmlTools {
             throw new RuntimeException(e);
         }
     }
+
+    /**
+     * Creates empty svg document.
+     *
+     * @return Document
+     */
     public static Document createEmptySvgDocument() {
         DOMImplementation domImplementation = GenericDOMImplementation.getDOMImplementation();
-        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-        return domImplementation.createDocument(svgNS, SVGConstants.SVG_SVG_TAG, null);
+        String svgNs = SVGDOMImplementation.SVG_NAMESPACE_URI;
+        return domImplementation.createDocument(svgNs, SVGConstants.SVG_SVG_TAG, null);
     }
 }
index e9e589e..1ece484 100755 (executable)
@@ -5,6 +5,8 @@
  * Copyright (C) 2019 Nokia. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -39,6 +41,9 @@ public class AwtUtils {
     private static final String FONT_FACE = "SansSerif";
     private static final Color TRANSPARENT = new Color(0.0f, 0.0f, 0.0f, 0.0f);
 
+    private AwtUtils() {
+    }
+
     static void rectWithText(Graphics2D g2d, String text, Point point, int width, int height) {
         Rectangle rect = new Rectangle(point.x, point.y, width, height);
         g2d.draw(rect);
index f49e735..46aa67b 100755 (executable)
@@ -34,8 +34,13 @@ public class ClampGraph {
         this.documentBuilder = documentBuilder;
     }
 
+    /**
+     * Returns svg string.
+     *
+     * @return svg string
+     */
     public String getAsSVG() {
-        if(Objects.isNull(svg) || svg.isEmpty()) {
+        if (Objects.isNull(svg) || svg.isEmpty()) {
             svg = XmlTools.exportXmlDocumentAsString(this.documentBuilder.getGroupingDocument());
         }
         return svg;
index ef4c4e4..c4ced5e 100755 (executable)
@@ -40,13 +40,13 @@ public class ClampGraphBuilder {
         this.painter = painter;
     }
 
-    public ClampGraphBuilder collector(String c) {
-        collector = c;
+    public ClampGraphBuilder collector(String collector) {
+        this.collector = collector;
         return this;
     }
 
-    public ClampGraphBuilder policy(String p) {
-        policy = p;
+    public ClampGraphBuilder policy(String policy) {
+        this.policy = policy;
         return this;
     }
 
index 4d76581..ce21c4c 100644 (file)
@@ -57,9 +57,9 @@ public class ImageBuilder {
 
     ImageBuilder rectangle(String dataElementId, RectTypes rectType, String text) {
         Point next = new Point(currentPoint.x + baseLength, currentPoint.y);
-        Point p = coordinatesForRectangle(currentPoint, next);
+        Point point = coordinatesForRectangle(currentPoint, next);
 
-        handleBasedOnRectType(rectType, text, p, baseLength, rectHeight);
+        handleBasedOnRectType(rectType, text, point, baseLength, rectHeight);
 
         documentBuilder.pushChangestoDocument(g2d, dataElementId);
         currentPoint = next;
@@ -94,36 +94,37 @@ public class ImageBuilder {
         return documentBuilder;
     }
 
-    private void handleBasedOnRectType(RectTypes rectType, String text, Point p, int w, int h) {
-        AwtUtils.rectWithText(g2d, text, p, w, h);
+    private void handleBasedOnRectType(RectTypes rectType, String text, Point point, int width, int height) {
+        AwtUtils.rectWithText(g2d, text, point, width, height);
         switch (rectType) {
             case COLECTOR:
-                drawVerticalLineForCollector(p, w, h);
+                drawVerticalLineForCollector(point, width, height);
                 break;
             case MICROSERVICE:
-                drawHorizontalLineForMicroService(p, w, h);
+                drawHorizontalLineForMicroService(point, width, height);
                 break;
             case POLICY:
-                drawDiagonalLineForPolicy(p, w, h);
+                drawDiagonalLineForPolicy(point, width, height);
                 break;
         }
     }
 
-    private void drawVerticalLineForCollector(Point p, int w, int h) {
-        g2d.drawLine(p.x + w / COLLECTOR_LINE_RATIO, p.y, p.x + w / COLLECTOR_LINE_RATIO, p.y + h);
+    private void drawVerticalLineForCollector(Point point, int width, int height) {
+        g2d.drawLine(point.x + width / COLLECTOR_LINE_RATIO, point.y, point.x + width / COLLECTOR_LINE_RATIO,
+                     point.y + height);
     }
 
-    private void drawHorizontalLineForMicroService(Point p, int w, int h) {
-        int y = calculateMsHorizontalLineYCoordinate(p,h);
-        g2d.drawLine(p.x, y, p.x + w, y);
+    private void drawHorizontalLineForMicroService(Point point, int width, int height) {
+        int y = calculateMsHorizontalLineYCoordinate(point,height);
+        g2d.drawLine(point.x, y, point.x + width, y);
     }
 
-    private void drawDiagonalLineForPolicy(Point p, int w, int h) {
-        g2d.drawLine(p.x, p.y + h / POLICY_LINE_RATIO, p.x + w / POLICY_LINE_RATIO, p.y);
+    private void drawDiagonalLineForPolicy(Point point, int width, int height) {
+        g2d.drawLine(point.x, point.y + height / POLICY_LINE_RATIO, point.x + width / POLICY_LINE_RATIO, point.y);
     }
 
-    private int calculateMsHorizontalLineYCoordinate(Point p, int h) {
-        return (int)(p.y * h * MS_LINE_TO_HEIGHT_RATIO);
+    private int calculateMsHorizontalLineYCoordinate(Point point, int height) {
+        return (int)(point.y * height * MS_LINE_TO_HEIGHT_RATIO);
     }
 
     private Point coordinatesForRectangle(Point from, Point next) {
index 6263f30..fe2d5cb 100755 (executable)
@@ -44,6 +44,12 @@ public class Painter {
     private static final double RECT_RATIO = 3.0 / 2.0;
     private static final int CIRCLE_RADIUS = 17;
 
+    /**
+     * Constructor to create instance of Painter.
+     *
+     * @param svgGraphics2D svg graphics
+     * @param documentBuilder document builder
+     */
     public Painter(SVGGraphics2D svgGraphics2D, DocumentBuilder documentBuilder) {
         this.g2d = svgGraphics2D;
         this.documentBuilder = documentBuilder;
index a15c556..58d9468 100644 (file)
@@ -87,9 +87,9 @@ public class AuthorizationControllerItCase {
         PrincipalUtils.setSecurityContext(securityContext);
 
         AuthorizationController auth = new AuthorizationController();
-        assertTrue(auth.isUserPermittedNoException(new SecureServicePermission("permission-type-cl","dev","read")));
-        assertTrue(auth.isUserPermittedNoException(new SecureServicePermission("permission-type-cl-manage","dev","DEPLOY")));
-        assertTrue(auth.isUserPermittedNoException(new SecureServicePermission("permission-type-filter-vf","dev","12345-55555-55555-5555")));
-        assertFalse(auth.isUserPermittedNoException(new SecureServicePermission("permission-type-cl","test","read")));
+        assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","dev","read")));
+        assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage","dev","DEPLOY")));
+        assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-filter-vf","dev","12345-55555-55555-5555")));
+        assertFalse(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","test","read")));
     }
 }