Fix check style issues 91/82591/2
authorxg353y <xg353y@intl.att.com>
Mon, 18 Mar 2019 15:03:10 +0000 (16:03 +0100)
committerxg353y <xg353y@intl.att.com>
Mon, 18 Mar 2019 15:26:09 +0000 (16:26 +0100)
Fix the issues raised by the check style

Issue-ID: CLAMP-328
Change-Id: I07f80274968e032d060a7d881f4851568616a832
Signed-off-by: xg353y <xg353y@intl.att.com>
25 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/ClampServlet.java
src/main/java/org/onap/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
src/main/java/org/onap/clamp/clds/client/GuardPolicyDelegate.java
src/main/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegate.java
src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructor.java
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatter.java
src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java
src/main/java/org/onap/clamp/loop/Loop.java
src/main/java/org/onap/clamp/loop/LoopController.java
src/main/java/org/onap/clamp/loop/LoopService.java
src/main/java/org/onap/clamp/loop/log/LoopLog.java
src/main/java/org/onap/clamp/policy/Policy.java
src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java
src/main/java/org/onap/clamp/util/PrincipalUtils.java

index 2061027..568af48 100644 (file)
@@ -58,30 +58,34 @@ public class AuthorizationController {
     private ClampProperties refProp;
 
     private SecurityContext securityContext = SecurityContextHolder.getContext();
-    private final static String permPrefix = "security.permission.type.";
-    private final static String permInstance = "security.permission.instance";
+    private static final String permPrefix = "security.permission.type.";
+    private static final String permInstance = "security.permission.instance";
 
     public AuthorizationController() {
     }
+
     /**
-     * Insert event using process variables.
+     * Insert authorize the api based on the permission
      *
      * @param camelExchange
      *        The Camel Exchange object containing the properties
-     * @param actionState
-     *        The action state that is used instead of the one in exchange property
+     * @param typeVar
+     *        The type of the permissions
+     * @param instanceVar
+     *        The instance of the permissions. e.g. dev
+     * @param action
+     *        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);
-        
+
         if (null == type || type.isEmpty()) {
             //authorization is turned off, since the permission is not defined
             return;
         }
         if (null != instanceVar && !instanceVar.isEmpty()) {
-             instance = instanceVar;
+            instance = instanceVar;
         }
         String principalName = PrincipalUtils.getPrincipalName();
         SecureServicePermission perm = SecureServicePermission.create(type, instance, action);
@@ -105,18 +109,22 @@ public class AuthorizationController {
         // 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());
+            auditLogger.info("{} authorized because user has permission with * for instance: {}", 
+                  principalName, inPermission.getKey());
             authorized = 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());
+            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());
+            auditLogger.info("{} authorized because user has permission with * for instance and * for action: {}", 
+                  principalName, inPermission.getKey());
             authorized = true;
         } else if (hasRole(inPermission.getKeyAllAction())) {
-            auditLogger.info("{} authorized because user has permission with * for action: {}", principalName, inPermission.getKey());
+            auditLogger.info("{} authorized because user has permission with * for action: {}", 
+                  principalName, inPermission.getKey());
             authorized = true;
         } else {
             throw new NotAuthorizedException("");
@@ -124,9 +132,15 @@ public class AuthorizationController {
         return authorized;
     }
 
+    /**
+     * Verify whether the user has the permission
+     *
+     * @param inPermission
+     *        The permissions to verify
+     */
     public boolean isUserPermittedNoException(SecureServicePermission inPermission) {
         try {
-            return isUserPermitted (inPermission);
+            return isUserPermitted(inPermission);
         } catch (NotAuthorizedException e) {
             return false;
         }
@@ -138,8 +152,9 @@ public class AuthorizationController {
             return false;
         }
         for (GrantedAuthority auth : authentication.getAuthorities()) {
-            if (role.equals(auth.getAuthority()))
+            if (role.equals(auth.getAuthority())) {
                 return true;
+            }
         }
         return false;
     }
index 7e78504..025dbab 100644 (file)
@@ -101,7 +101,7 @@ public class Application extends SpringBootServletInitializer {
      * This method is used to declare the camel servlet.
      *
      * @return A servlet bean
-     * @throws IOException
+     * @throws IOException IO Exception
      */
     @Bean
     public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
index 008a9c7..e8fd83e 100644 (file)
@@ -50,7 +50,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
 public class ClampServlet extends CamelHttpTransportServlet {
 
     /**
-     *
+     * The serial version ID.
      */
     private static final long serialVersionUID = -4198841134910211542L;
 
@@ -109,8 +109,8 @@ public class ClampServlet extends CamelHttpTransportServlet {
     @Override
     protected void doService(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
-        Principal p = request.getUserPrincipal();
-        if (loadDynamicAuthenticationClass().isInstance(p)) {
+        Principal principal = request.getUserPrincipal();
+        if (loadDynamicAuthenticationClass().isInstance(principal)) {
             // When AAF is enabled, there is a need to provision the permissions to Spring
             // system
             List<GrantedAuthority> grantedAuths = new ArrayList<>();
@@ -120,7 +120,7 @@ public class ClampServlet extends CamelHttpTransportServlet {
                     grantedAuths.add(new SimpleGrantedAuthority(permString));
                 }
             }
-            Authentication auth = new UsernamePasswordAuthenticationToken(new User(p.getName(), "", grantedAuths), "",
+            Authentication auth = new UsernamePasswordAuthenticationToken(new User(principal.getName(), "", grantedAuths), "",
                 grantedAuths);
             SecurityContextHolder.getContext().setAuthentication(auth);
         }
index 1d9150e..a0109a6 100644 (file)
@@ -32,10 +32,8 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
  * This class is a factory that redirects by default all HTTP to HTTPS
  * connector. It is used by the Application.java class and defined in a Spring
  * Bean.
- *
  * In order to do this, the method postProcessContext has been overridden to
  * provide another behavior.
- *
  */
 public class TomcatEmbeddedServletContainerFactoryRedirection extends TomcatServletWebServerFactory {
 
index 6845452..63caf5a 100644 (file)
@@ -63,6 +63,13 @@ public class DcaeDispatcherServices {
         this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
     }\r
 \r
+    /**\r
+     * Get the Operation Status from a specified URL with retry.\r
+     * @param operationStatusUrl\r
+     *        The URL of the DCAE\r
+     * @return The status\r
+     * @throws InterruptedException Exception during the retry\r
+     */\r
     public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {\r
         String operationStatus = "";\r
         for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {\r
@@ -81,7 +88,6 @@ public class DcaeDispatcherServices {
 \r
     /**\r
      * Get the Operation Status from a specified URL.\r
-     *\r
      * @param statusUrl\r
      *        The URL provided by a previous DCAE Query\r
      * @return The status\r
@@ -112,7 +118,6 @@ public class DcaeDispatcherServices {
 \r
     /**\r
      * Returns status URL for createNewDeployment operation.\r
-     *\r
      * @param deploymentId\r
      *        The deployment ID\r
      * @param serviceTypeId\r
@@ -150,7 +155,6 @@ public class DcaeDispatcherServices {
 \r
     /***\r
      * Returns status URL for deleteExistingDeployment operation.\r
-     *\r
      * @param deploymentId\r
      *        The deployment ID\r
      * @param serviceTypeId\r
index 8781fc3..30afddc 100644 (file)
@@ -42,9 +42,7 @@ import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.stereotype.Component;
 
 /**
- *
  * This class manages the HTTP and HTTPS connections to DCAE.
- *
  */
 @Component
 public class DcaeHttpConnectionManager {
index e5ef3c6..ffd19d8 100644 (file)
@@ -64,6 +64,9 @@ public class DcaeInventoryServices {
     private final CldsDao cldsDao;\r
     private final DcaeHttpConnectionManager dcaeHttpConnectionManager;\r
 \r
+    /**\r
+     * Constructor.\r
+     */\r
     @Autowired\r
     public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
         DcaeHttpConnectionManager dcaeHttpConnectionManager) {\r
@@ -179,7 +182,6 @@ public class DcaeInventoryServices {
      */\r
     public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
         throws IOException, ParseException, InterruptedException {\r
-        Date startTime = new Date();\r
         LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");\r
         String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="\r
             + artifactName;\r
@@ -187,6 +189,7 @@ public class DcaeInventoryServices {
         logger.info("Dcae Inventory Service full url - " + fullUrl);\r
         DcaeInventoryResponse response = queryDcaeInventory(fullUrl);\r
         LoggingUtils.setResponseContext("0", "Get Dcae Information success", this.getClass().getName());\r
+        Date startTime = new Date();\r
         LoggingUtils.setTimeContext(startTime, new Date());\r
         return response;\r
     }\r
index fb91d9c..a758716 100644 (file)
@@ -76,7 +76,8 @@ public class GuardPolicyDelegate {
         Policy policy = prop.getType(Policy.class);
         if (policy.isFound()) {
             for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
-                for(PolicyItem policyItem:GuardPolicyAttributesConstructor.getAllPolicyGuardsFromPolicyChain(policyChain)) {
+                for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+                        .getAllPolicyGuardsFromPolicyChain(policyChain)) {
                     prop.setCurrentModelElementId(policy.getId());
                     prop.setPolicyUniqueId(policyChain.getPolicyId());
                     prop.setGuardUniqueId(policyItem.getId());
index 36eb147..941f519 100644 (file)
@@ -70,7 +70,8 @@ public class GuardPolicyDeleteDelegate {
         String eventAction = (String) camelExchange.getProperty("eventAction");
         if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
             for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
-                for(PolicyItem policyItem:GuardPolicyAttributesConstructor.getAllPolicyGuardsFromPolicyChain(policyChain)) {
+                for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+                        .getAllPolicyGuardsFromPolicyChain(policyChain)) {
                     prop.setCurrentModelElementId(policy.getId());
                     prop.setPolicyUniqueId(policyChain.getPolicyId());
                     prop.setGuardUniqueId(policyItem.getId());
index 39377d4..307c8e5 100644 (file)
@@ -79,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 = OperationalPolicyAttributesConstructor.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) {
index f15d33d..bc82cb3 100644 (file)
@@ -61,6 +61,11 @@ public class GuardPolicyAttributesConstructor {
         return createAttributesMap(matchingAttributes);
     }
 
+    /**
+     * Get all the Guard policies from the policy chain.
+     * @param policyChain The policy chain
+     * @return The list of guard policies
+     */
     public static List<PolicyItem> getAllPolicyGuardsFromPolicyChain(PolicyChain policyChain) {
         List<PolicyItem> listItem = new ArrayList<>();
         for (PolicyItem policyItem : policyChain.getPolicyItems()) {
index c28f700..af23626 100644 (file)
@@ -59,6 +59,16 @@ public class OperationalPolicyAttributesConstructor {
     private OperationalPolicyAttributesConstructor() {
     }
 
+    /**
+     * Format the attributes.
+     * @param refProp The Clamp properties
+     * @param modelProperties The model properties
+     * @param modelElementId The model element ID
+     * @param policyChain The policy chain
+     * @return The attributes map
+     * @throws BuilderException Exception while building up the attributes map
+     * @throws UnsupportedEncodingException Unsupported encoding exception
+     */
     public static Map<AttributeType, Map<String, String>> formatAttributes(ClampProperties refProp,
         ModelProperties modelProperties,
         String modelElementId, PolicyChain policyChain)
@@ -75,7 +85,8 @@ public class OperationalPolicyAttributesConstructor {
         return createAttributesMap(matchingAttributes, ruleAttributes);
     }
 
-    private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties, ModelProperties modelProperties,
+    private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties, 
+        ModelProperties modelProperties,
         String modelElementId, PolicyChain policyChain, String globalService)
             throws BuilderException, UnsupportedEncodingException {
         logger.info("Preparing rule attributes...");
@@ -112,7 +123,8 @@ public class OperationalPolicyAttributesConstructor {
         return attributes;
     }
 
-    private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp, ModelProperties modelProperties,
+    private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp, 
+        ModelProperties modelProperties,
         String modelElementId, PolicyChain policyChain,
         String globalService, String operationTopic)
             throws BuilderException, UnsupportedEncodingException {
@@ -127,7 +139,8 @@ public class OperationalPolicyAttributesConstructor {
         }
     }
 
-    private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem, String recipeTopic) {
+    private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem, 
+        String recipeTopic) {
         logger.info("recipeTopic=" + recipeTopic);
         return ImmutableMap.<String, String>builder()
             .put(RECIPE_TOPIC, recipeTopic)
index b9ed0c0..f2536b1 100644 (file)
@@ -21,6 +21,7 @@
  * ===================================================================
  *
  */
+
 package org.onap.clamp.clds.client.req.policy;
 
 import com.att.eelf.configuration.EELFLogger;
@@ -61,12 +62,12 @@ public class OperationalPolicyYamlFormatter {
     /**
      * Format Operational OpenLoop Policy yaml.
      *
-     * @param prop
-     * @param modelElementId
-     * @param policyChain
-     * @return
-     * @throws BuilderException
-     * @throws UnsupportedEncodingException
+     * @param prop The model properties
+     * @param modelElementId The model element ID
+     * @param policyChain The policy chain
+     * @return The operational openloop policy in yaml format
+     * @throws BuilderException The builder exception
+     * @throws UnsupportedEncodingException The unsupported encoding exception
      */
     public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
         throws BuilderException, UnsupportedEncodingException {
@@ -87,6 +88,15 @@ public class OperationalPolicyYamlFormatter {
         return URLEncoder.encode(results.getSpecification(), "UTF-8");
     }
 
+    /**
+     * Format Operational Policy yaml.
+     * @param prop The model properties
+     * @param modelElementId The model element ID
+     * @param policyChain The policy chain
+     * @return The operational policy properties in yaml format
+     * @throws BuilderException The builder exception
+     * @throws UnsupportedEncodingException The unsupported encoding exception
+     */
     public static String formatYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
         throws BuilderException, UnsupportedEncodingException {
         // get property objects
index c705115..965c90f 100644 (file)
@@ -519,7 +519,7 @@ public class PolicyClient {
     }
 
     /**
-     * Method to return correct policy name with prefix
+     * Method to return correct policy name with prefix.
      *
      * @param prop
      *        The ModelProperties
@@ -527,7 +527,7 @@ public class PolicyClient {
      *        Policy Prefix
      * @param policyNameWithPrefix
      *        Policy Name With Prefix
-     * @return
+     * @return The policy name with the prefix
      */
     protected String selectRightPolicyNameWithPrefix(ModelProperties prop, String policyPrefix,
         String policyNameWithPrefix) {
@@ -561,8 +561,8 @@ public class PolicyClient {
         deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
         deletePolicyParameters.setPolicyType(policyType);
         // send delete request
-        StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
         logger.info("Deleting policy from PAP...");
+        StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
         deletePolicyParameters.setPolicyComponent("PAP");
         deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
         // send delete request
@@ -605,7 +605,7 @@ public class PolicyClient {
     }
 
     /**
-     * Create a temp Tosca model file and perform import model to Policy Engine
+     * Create a temp Tosca model file and perform import model to Policy Engine.
      *
      * @param cldsToscaModel
      *        Policy model details
@@ -636,6 +636,7 @@ public class PolicyClient {
     }
 
     /**
+     * Import the model.
      * @param importParameters
      *        The ImportParameters
      * @return The response message from policy
@@ -671,6 +672,7 @@ public class PolicyClient {
     }
 
     /**
+     * Build file path for tosca file.
      * @param clampToscaPath
      *        Temp directory path for writing tosca files
      * @param toscaModelName
index 6505288..fed2c65 100644 (file)
@@ -216,7 +216,7 @@ public class CsarInstallerImpl implements CsarInstaller {
 
     /**
      * ll get the latest version of the artifact (version can be specified to DCAE
-     * call)
+     * call).
      *
      * @return The DcaeInventoryResponse object containing the dcae values
      */
index 473364a..64e0108 100644 (file)
@@ -57,7 +57,7 @@ import org.onap.clamp.policy.operational.OperationalPolicy;
 public class Loop implements Serializable {
 
     /**
-     *
+     * The serial version id.
      */
     private static final long serialVersionUID = -286522707701388642L;
 
@@ -105,7 +105,8 @@ public class Loop implements Serializable {
 
     @Expose
     @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
-    @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
+    @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), 
+       inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
     private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
 
     @Expose
@@ -115,6 +116,9 @@ public class Loop implements Serializable {
     public Loop() {
     }
 
+    /**
+     * Constructor.
+     */
     public Loop(String name, String blueprint, String svgRepresentation) {
         this.name = name;
         this.svgRepresentation = svgRepresentation;
@@ -234,6 +238,14 @@ public class Loop implements Serializable {
         this.modelPropertiesJson = modelPropertiesJson;
     }
 
+    /**
+     * Generate the loop name.
+     * @param serviceName The service name
+     * @param serviceVersion The service version
+     * @param resourceName The resource name
+     * @param blueprintFileName The blueprint file name
+     * @return The generated loop name
+     */
     public static String generateLoopName(String serviceName, String serviceVersion, String resourceName,
         String blueprintFilename) {
         StringBuilder buffer = new StringBuilder("LOOP_").append(serviceName).append("_v").append(serviceVersion)
@@ -251,18 +263,23 @@ public class Loop implements Serializable {
 
     @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;
+        }
         Loop other = (Loop) 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;
+        }
         return true;
     }
 
index 8b64e9d..a02fa93 100644 (file)
@@ -42,9 +42,9 @@ public class LoopController {
 
     private final LoopService loopService;
     private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken<List<OperationalPolicy>>() {
-    }.getType();
+       }.getType();
     private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken<List<MicroServicePolicy>>() {
-    }.getType();
+       }.getType();
 
     @Autowired
     public LoopController(LoopService loopService) {
@@ -59,26 +59,55 @@ public class LoopController {
         return loopService.getLoop(loopName);
     }
 
+    /**
+     * Update the Operational Policy properties.
+     * @param loopName The loop name
+     * @param operationalPoliciesJson The new Operational Policy properties
+     * @return The updated loop
+     */
     public Loop updateOperationalPolicies(String loopName, JsonArray operationalPoliciesJson) {
         List<OperationalPolicy> operationalPolicies = JsonUtils.GSON
             .fromJson(operationalPoliciesJson, OPERATIONAL_POLICY_TYPE);
         return loopService.updateAndSaveOperationalPolicies(loopName, operationalPolicies);
     }
 
+    /**
+     * Update the whole array of MicroService policies properties
+     * @param loopName The loop name
+     * @param microServicePoliciesJson The array of all MicroService policies properties
+     * @return The updated loop
+     */
     public Loop updateMicroservicePolicies(String loopName, JsonArray microServicePoliciesJson) {
         List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON
             .fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
         return loopService.updateAndSaveMicroservicePolicies(loopName, microservicePolicies);
     }
 
-    public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties){
+    /**
+     * Update the global properties
+     * @param loopName The loop name
+     * @param globalProperties The updated global properties
+     * @return The updated loop
+     */
+    public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties) {
         return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
     }
 
+    /**
+     * Update one MicroService policy properties
+     * @param loopName The loop name
+     * @param newMicroservicePolicy The new MicroService policy properties
+     * @return The updated MicroService policy
+     */
     public MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
         return loopService.updateMicroservicePolicy(loopName, newMicroservicePolicy);
     }
 
+    /**
+     * Get the SVG representation of the loop
+     * @param loopName The loop name
+     * @return The SVG representation
+     */
     public String getSVGRepresentation(String loopName) {
         return loopService.getClosedLoopModelSVG(loopName);
 
index 051ab6e..b499573 100644 (file)
@@ -25,13 +25,15 @@ package org.onap.clamp.loop;
 
 import java.util.List;
 import java.util.Set;
-import javax.persistence.EntityNotFoundException;
 
 import com.google.gson.JsonObject;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
-import org.onap.clamp.policy.operational.OperationalPolicyService;
+
+import javax.persistence.EntityNotFoundException;
+
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
+import org.onap.clamp.policy.microservice.MicroservicePolicyService;
 import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.onap.clamp.policy.operational.OperationalPolicyService;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -41,6 +43,9 @@ public class LoopService {
     private final MicroservicePolicyService microservicePolicyService;
     private final OperationalPolicyService operationalPolicyService;
 
+    /**
+     * Constructor.
+     */
     public LoopService(LoopsRepository loopsRepository,
         MicroservicePolicyService microservicePolicyService,
         OperationalPolicyService operationalPolicyService) {
@@ -57,7 +62,7 @@ public class LoopService {
         return loopsRepository.getAllLoopNames();
     }
 
-    Loop getLoop(String loopName){
+    Loop getLoop(String loopName) {
         return loopsRepository
             .findById(loopName)
             .orElse(null);
@@ -87,7 +92,7 @@ public class LoopService {
     }
 
     MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
-       Loop loop = findClosedLoopByName(loopName);
+        Loop loop = findClosedLoopByName(loopName);
         MicroServicePolicy newPolicies = microservicePolicyService
                 .getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
         return newPolicies;
index 7b7fe1b..0c51c0c 100644 (file)
@@ -43,7 +43,6 @@ import javax.persistence.Table;
 import org.onap.clamp.loop.Loop;
 
 /**
- *
  * This class holds the logs created by the Clamp Backend. The Instant is always
  * rounded to the nearest second as the nano seconds can't be stored in the
  * database. The logs can be therefore exposed to the UI or the client doing
@@ -54,7 +53,7 @@ import org.onap.clamp.loop.Loop;
 @Table(name = "loop_logs")
 public class LoopLog implements Serializable {
     /**
-     *
+     * The serial version ID.
      */
     private static final long serialVersionUID = 1988276670074437631L;
 
@@ -130,18 +129,23 @@ public class LoopLog implements Serializable {
 
     @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;
+        }
         LoopLog other = (LoopLog) obj;
         if (id == null) {
-            if (other.id != null)
+            if (other.id != null) {
                 return false;
-        } else if (!id.equals(other.id))
+            }
+        } else if (!id.equals(other.id)) {
             return false;
+        }
         return true;
     }
 
index c104b13..683881b 100644 (file)
@@ -31,6 +31,15 @@ public interface Policy {
 
     JsonObject getJsonRepresentation();
 
+    /**
+     * Generate the policy name.
+     * @param policyType The policy type
+     * @param serviceName The service name
+     * @param serviceVersion The service version
+     * @param resourceName The resource name
+     * @param blueprintFilename The blueprint file name
+     * @return The generated policy name
+     */
     static String generatePolicyName(String policyType, String serviceName, String serviceVersion, String resourceName,
         String blueprintFilename) {
         StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v")
index 857a3d7..3962a3d 100644 (file)
@@ -50,7 +50,7 @@ import org.onap.clamp.policy.Policy;
 @TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
 public class MicroServicePolicy implements Serializable, Policy {
     /**
-     *
+     * The serial version ID.
      */
     private static final long serialVersionUID = 6271238288583332616L;
 
@@ -83,6 +83,13 @@ public class MicroServicePolicy implements Serializable, Policy {
         // serialization
     }
 
+    /**
+     * The constructor.
+     * @param name The name of the MicroService
+     * @param policyTosca The policy Tosca of the MicroService
+     * @param shared The flag indicate whether the MicroService is shared
+     * @param usedByLoops The list of loops that uses this MicroService
+     */
     public MicroServicePolicy(String name, String policyTosca, Boolean shared, Set<Loop> usedByLoops) {
         this.name = name;
         this.policyTosca = policyTosca;
@@ -92,6 +99,14 @@ public class MicroServicePolicy implements Serializable, Policy {
         this.usedByLoops = usedByLoops;
     }
 
+    /**
+     * The constructor.
+     * @param name The name of the MicroService
+     * @param policyTosca The policy Tosca of the MicroService
+     * @param shared The flag indicate whether the MicroService is shared
+     * @param jsonRepresentation The UI representation in json format
+     * @param usedByLoops The list of loops that uses this MicroService
+     */
     public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
         Set<Loop> usedByLoops) {
         this.name = name;
@@ -157,18 +172,23 @@ public class MicroServicePolicy implements Serializable, Policy {
 
     @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;
+        }
         MicroServicePolicy other = (MicroServicePolicy) 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;
+        }
         return true;
     }
 
index ee9ba53..f473d16 100644 (file)
@@ -57,6 +57,12 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
         return repository.existsById(policyName);
     }
 
+    /**
+     * Get and update the MicroService policy properties.
+     * @param loop The loop
+     * @param policy The new MicroService policy
+     * @return The updated MicroService policy
+     */
     @Transactional
     public MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
         return repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
index 033b539..c1e075d 100644 (file)
@@ -38,16 +38,16 @@ import javax.persistence.Table;
 import org.hibernate.annotations.Type;
 import org.hibernate.annotations.TypeDef;
 import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
 import org.onap.clamp.loop.Loop;
 import org.onap.clamp.policy.Policy;
-import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
 
 @Entity
 @Table(name = "operational_policies")
 @TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
 public class OperationalPolicy implements Serializable, Policy {
     /**
-     *
+     * The serial version ID.
      */
     private static final long serialVersionUID = 6117076450841538255L;
 
@@ -69,6 +69,12 @@ public class OperationalPolicy implements Serializable, Policy {
         //Serialization
     }
 
+    /**
+     * The constructor.
+     * @param name The name of the operational policy
+     * @param loop The loop that uses this operational policy
+     * @param configurationsJson The operational policy property in the format of json
+     */
     public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson) {
         this.name = name;
         this.loop = loop;
@@ -83,7 +89,7 @@ public class OperationalPolicy implements Serializable, Policy {
         this.loop = loopName;
     }
 
-    public Loop getLoop(){
+    public Loop getLoop() {
         return loop;
     }
 
@@ -110,18 +116,23 @@ public class OperationalPolicy implements Serializable, Policy {
 
     @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;
+        }
         OperationalPolicy other = (OperationalPolicy) 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;
+        }
         return true;
     }
 
index b24a2db..95f4f7b 100644 (file)
@@ -27,8 +27,8 @@ import com.google.gson.JsonObject;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.onap.clamp.policy.PolicyService;
 import org.onap.clamp.loop.Loop;
+import org.onap.clamp.policy.PolicyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
index ec08983..d6b20f3 100644 (file)
@@ -40,7 +40,7 @@ public class PrincipalUtils {
     /**
      * Get the Full name.
      *
-     * @return
+     * @return The user name
      */
     public static String getUserName() {
         String name = userNameHandler.retrieveUserName(securityContext);
@@ -53,7 +53,7 @@ public class PrincipalUtils {
     /**
      * Get the userId from AAF/CSP.
      *
-     * @return
+     * @return The user ID
      */
     public static String getUserId() {
         return getUserName();
@@ -62,7 +62,7 @@ public class PrincipalUtils {
     /**
      * Get the principal name.
      *
-     * @return
+     * @return The principal name
      */
     public static String getPrincipalName() {
         String principal = ((UserDetails)securityContext.getAuthentication().getPrincipal()).getUsername();
@@ -72,6 +72,7 @@ public class PrincipalUtils {
         }
         return name;
     }
+
     public static void setSecurityContext(SecurityContext securityContext) {
         PrincipalUtils.securityContext = securityContext;
     }