summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorsarada prasad sahoo <sarada.prasad.sahoo@huawei.com>2019-08-08 20:58:14 +0530
committersarada prasad sahoo <sarada.prasad.sahoo@huawei.com>2019-08-08 20:58:14 +0530
commit767d75c00de86e1040c9dede18cf9778990ed5bf (patch)
tree9d456587f538f0a7986732f829d5cacaacd38239 /mso-api-handlers
parentd71881b27a9b37068a514ec0f02c81180e20c63b (diff)
fix sonar issue
fix sonar issues Issue-ID: SO-1811 Signed-off-by: sarada prasad sahoo <sarada.prasad.sahoo@huawei.com> Change-Id: I137e40866ccbfb634b430ea56028fac87cc6b2bc
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java53
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java2
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java2
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java2
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/controller/InstanceNameDuplicateCheckRequest.java10
5 files changed, 33 insertions, 36 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
index b5b548a266..e11732ddc4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
@@ -23,7 +23,7 @@ package org.onap.so.apihandlerinfra.infra.rest.handler;
import java.io.IOException;
import java.net.URL;
import java.sql.Timestamp;
-import java.util.HashMap;
+import java.util.Map;
import java.util.Optional;
import javax.ws.rs.container.ContainerRequestContext;
import org.apache.http.HttpStatus;
@@ -63,7 +63,7 @@ public abstract class AbstractRestHandler {
private static final Logger logger = LoggerFactory.getLogger(AbstractRestHandler.class);
- public static final String conflictFailMessage = "Error: Locked instance - This %s (%s) "
+ public static final String CONFLICT_FAIL_MESSAGE = "Error: Locked instance - This %s (%s) "
+ "already has a request being worked with a status of %s (RequestId - %s). The existing request must finish or be cleaned up before proceeding.";
@@ -95,22 +95,19 @@ public abstract class AbstractRestHandler {
ErrorLoggerInfo errorLoggerInfo =
new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError)
.errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException =
- new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID",
- HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
- .errorInfo(errorLoggerInfo).build();
-
- throw validateException;
+ throw new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID",
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo)
+ .build();
}
}
- public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ public InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, long startTime,
MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq)
throws ApiException {
return duplicateCheck(action, instanceIdMap, startTime, instanceName, requestScope, currentActiveReq);
}
- public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ public InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, long startTime,
String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
InfraActiveRequests dup = null;
try {
@@ -134,19 +131,19 @@ public abstract class AbstractRestHandler {
public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage)
throws RequestDbFailureException {
- if (aq != null) {
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage(errorMessage);
- aq.setProgress(100L);
- aq.setRequestStatus(status.toString());
- Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
- aq.setEndTime(endTimeStamp);
- try {
- infraActiveRequestsClient.updateInfraActiveRequests(aq);
- } catch (Exception e) {
- logger.error("Error updating status", e);
- }
+ if ((aq != null) && ((status == Status.FAILED) || (status == Status.COMPLETE))) {
+
+ aq.setStatusMessage(errorMessage);
+ aq.setProgress(100L);
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ aq.setEndTime(endTimeStamp);
+ try {
+ infraActiveRequestsClient.updateInfraActiveRequests(aq);
+ } catch (Exception e) {
+ logger.error("Error updating status", e);
}
+
}
}
@@ -178,15 +175,15 @@ public abstract class AbstractRestHandler {
selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath));
} catch (Exception e) {
selfLinkUrl = Optional.empty(); // ignore
- logger.info(e.getMessage());
+ logger.error(e.getMessage());
}
return selfLinkUrl;
}
/**
- * @param vfmoduleInstanceId
+ * @param instanceId
* @param requestId
- * @param response
+ * @param requestContext
*/
public ServiceInstancesResponse createResponse(String instanceId, String requestId,
ContainerRequestContext requestContext) {
@@ -202,13 +199,13 @@ public abstract class AbstractRestHandler {
return response;
}
- public void checkDuplicateRequest(HashMap<String, String> instanceIdMap, ModelType modelType, String instanceName,
+ public void checkDuplicateRequest(Map<String, String> instanceIdMap, ModelType modelType, String instanceName,
String requestId) throws RequestConflictedException {
InfraActiveRequests conflictedRequest =
infraActiveRequestsClient.checkInstanceNameDuplicate(instanceIdMap, instanceName, modelType.toString());
if (conflictedRequest != null && !conflictedRequest.getRequestId().equals(requestId)) {
- throw new RequestConflictedException(String.format(conflictFailMessage, modelType.toString(), instanceName,
- conflictedRequest.getRequestStatus(), conflictedRequest.getRequestId()));
+ throw new RequestConflictedException(String.format(CONFLICT_FAIL_MESSAGE, modelType.toString(),
+ instanceName, conflictedRequest.getRequestStatus(), conflictedRequest.getRequestId()));
}
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java
index 47f8c6b50e..5a8e2e2f6c 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java
@@ -33,7 +33,7 @@ public interface InfraActiveRequestsRepositoryCustom {
public InfraActiveRequests getRequestFromInfraActive(String requestId);
- public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName,
+ public InfraActiveRequests checkInstanceNameDuplicate(Map<String, String> instanceIdMap, String instanceName,
String requestScope);
public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap);
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
index d8c7c8f971..13ca33c2cf 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
@@ -152,7 +152,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
* java.lang.String, java.lang.String)
*/
@Override
- public InfraActiveRequests checkInstanceNameDuplicate(final HashMap<String, String> instanceIdMap,
+ public InfraActiveRequests checkInstanceNameDuplicate(final Map<String, String> instanceIdMap,
final String instanceName, final String requestScope) {
final List<Predicate> predicates = new LinkedList<>();
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 4d16d9c272..9be92ad93a 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -217,7 +217,7 @@ public class RequestsDbClient {
return restTemplate.exchange(uri, HttpMethod.GET, entity, InfraActiveRequests.class).getBody();
}
- public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName,
+ public InfraActiveRequests checkInstanceNameDuplicate(Map<String, String> instanceIdMap, String instanceName,
String requestScope) {
HttpHeaders headers = getHttpHeaders();
URI uri = getUri(checkInstanceNameDuplicate);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/controller/InstanceNameDuplicateCheckRequest.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/controller/InstanceNameDuplicateCheckRequest.java
index 548bc25815..169d2353ec 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/controller/InstanceNameDuplicateCheckRequest.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/controller/InstanceNameDuplicateCheckRequest.java
@@ -20,28 +20,28 @@
package org.onap.so.db.request.data.controller;
-import java.util.HashMap;
+import java.util.Map;
public class InstanceNameDuplicateCheckRequest {
- private HashMap<String, String> instanceIdMap;
+ private Map<String, String> instanceIdMap;
private String instanceName;
private String requestScope;
public InstanceNameDuplicateCheckRequest() {}
- public InstanceNameDuplicateCheckRequest(HashMap<String, String> instanceIdMap, String instanceName,
+ public InstanceNameDuplicateCheckRequest(Map<String, String> instanceIdMap, String instanceName,
String requestScope) {
this.instanceIdMap = instanceIdMap;
this.instanceName = instanceName;
this.requestScope = requestScope;
}
- public HashMap<String, String> getInstanceIdMap() {
+ public Map<String, String> getInstanceIdMap() {
return instanceIdMap;
}
- public void setInstanceIdMap(HashMap<String, String> instanceIdMap) {
+ public void setInstanceIdMap(Map<String, String> instanceIdMap) {
this.instanceIdMap = instanceIdMap;
}