Fix too many params issue 21/101721/1
authorParshad Patel <pars.patel@samsung.com>
Fri, 14 Feb 2020 06:27:17 +0000 (15:27 +0900)
committerParshad Patel <pars.patel@samsung.com>
Fri, 14 Feb 2020 06:27:48 +0000 (15:27 +0900)
Methods should not have too many parameters
Either log or rethrow this exception

Issue-ID: SO-1841
Change-Id: Iabe32f4492560703228eb5d115b5e91ebeb17255
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java

index fb95ae3..11707c4 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,9 +27,15 @@ import org.onap.so.client.aai.AAIObjectType;
 import org.onap.so.client.aai.AAIResourcesClient;
 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AAIDeleteServiceInstance implements JavaDelegate {
 
+    private static final Logger logger = LoggerFactory.getLogger(AAIDeleteServiceInstance.class);
+    private static final String ERROR_MESSAGE =
+            "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI.";
+
     ExceptionUtil exceptionUtil = new ExceptionUtil();
 
     public void execute(DelegateExecution execution) throws Exception {
@@ -41,8 +47,8 @@ public class AAIDeleteServiceInstance implements JavaDelegate {
             aaiRC.delete(serviceInstanceURI);
             execution.setVariable("GENDS_SuccessIndicator", true);
         } catch (Exception ex) {
-            String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI."
-                    + ex.getMessage();
+            logger.debug(ERROR_MESSAGE, ex);
+            String msg = ERROR_MESSAGE + ex.getMessage();
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
         }
 
index 2d69351..f7b0c66 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,17 +30,70 @@ public class AAIServiceInstance {
     String environmentContext;
     String workloadContext;
 
-    public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole,
-            String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext,
-            String workloadContext) {
-        this.serviceInstanceName = serviceInstanceName;
-        this.serviceType = serviceType;
-        this.serviceRole = serviceRole;
-        this.orchestrationStatus = orchestrationStatus;
-        this.modelInvariantUuid = modelInvariantUuid;
-        this.modelVersionId = modelVersionId;
-        this.environmentContext = environmentContext;
-        this.workloadContext = workloadContext;
+    public class AAIServiceInstanceBuilder {
+        private String serviceInstanceName;
+        private String serviceType;
+        private String serviceRole;
+        private String orchestrationStatus;
+        private String modelInvariantUuid;
+        private String modelVersionId;
+        private String environmentContext;
+        private String workloadContext;
+
+        public AAIServiceInstanceBuilder setServiceInstanceName(String serviceInstanceName) {
+            this.serviceInstanceName = serviceInstanceName;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setServiceType(String serviceType) {
+            this.serviceType = serviceType;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setServiceRole(String serviceRole) {
+            this.serviceRole = serviceRole;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setOrchestrationStatus(String orchestrationStatus) {
+            this.orchestrationStatus = orchestrationStatus;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setModelInvariantUuid(String modelInvariantUuid) {
+            this.modelInvariantUuid = modelInvariantUuid;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setModelVersionId(String modelVersionId) {
+            this.modelVersionId = modelVersionId;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setEnvironmentContext(String environmentContext) {
+            this.environmentContext = environmentContext;
+            return this;
+        }
+
+        public AAIServiceInstanceBuilder setWorkloadContext(String workloadContext) {
+            this.workloadContext = workloadContext;
+            return this;
+        }
+
+        public AAIServiceInstance createAAIServiceInstance() {
+            return new AAIServiceInstance(this);
+        }
+    }
+
+    public AAIServiceInstance(AAIServiceInstanceBuilder aaiServiceInstanceBuilder) {
+        this.serviceInstanceName = aaiServiceInstanceBuilder.serviceInstanceName;
+        this.serviceType = aaiServiceInstanceBuilder.serviceType;
+        this.serviceRole = aaiServiceInstanceBuilder.serviceRole;
+        this.orchestrationStatus = aaiServiceInstanceBuilder.orchestrationStatus;
+        this.modelInvariantUuid = aaiServiceInstanceBuilder.modelInvariantUuid;
+        this.modelVersionId = aaiServiceInstanceBuilder.modelVersionId;
+        this.environmentContext = aaiServiceInstanceBuilder.environmentContext;
+        this.workloadContext = aaiServiceInstanceBuilder.workloadContext;
     }
 
     public String getServiceInstanceName() {