summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java48
5 files changed, 66 insertions, 15 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index b09d676b57..7ed60384a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -403,7 +403,7 @@ public class E2EServiceInstances {
msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
"Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON,
- null);
+ null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -415,7 +415,7 @@ public class E2EServiceInstances {
ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action,
- ModelType.service.name(), requestJSON, null);
+ ModelType.service.name(), requestJSON, null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -493,7 +493,7 @@ public class E2EServiceInstances {
msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
"Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON,
- null);
+ null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -505,7 +505,7 @@ public class E2EServiceInstances {
ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action,
- ModelType.service.name(), requestJSON, null);
+ ModelType.service.name(), requestJSON, null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -725,7 +725,7 @@ public class E2EServiceInstances {
msoRequest.createErrorRequestRecord(Status.FAILED, requestId,
"No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON,
- null);
+ null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -737,7 +737,7 @@ public class E2EServiceInstances {
MsoException.ServiceException, "Recipe does not exist in catalog DB",
ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action,
- ModelType.service.name(), requestJSON, null);
+ ModelType.service.name(), requestJSON, null, null);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -958,7 +958,7 @@ public class E2EServiceInstances {
ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action,
- ModelType.service.name(), requestJSON, null);
+ ModelType.service.name(), requestJSON, null, null);
throw validateException;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index bf76cd3174..64c42a0498 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -451,7 +451,7 @@ public class MsoRequest {
}
public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action,
- String requestScope, String requestJSON, String serviceInstanceId) {
+ String requestScope, String requestJSON, String serviceInstanceId, ServiceInstancesRequest sir) {
try {
InfraActiveRequests request = new InfraActiveRequests(requestId);
Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
@@ -469,6 +469,17 @@ public class MsoRequest {
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
request.setEndTime(endTimeStamp);
request.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
+ if (sir != null) {
+ if (sir.getRequestDetails() != null && sir.getRequestDetails().getRequestInfo() != null) {
+ request.setRequestorId(sir.getRequestDetails().getRequestInfo().getRequestorId());
+ request.setSource(sir.getRequestDetails().getRequestInfo().getSource());
+ if (ModelType.service.name().equalsIgnoreCase(requestScope)) {
+ if (sir.getRequestDetails().getRequestInfo().getInstanceName() != null) {
+ request.setServiceInstanceName(sir.getRequestDetails().getRequestInfo().getInstanceName());
+ }
+ }
+ }
+ }
requestsDbClient.save(request);
} catch (Exception e) {
logger.error("Exception when updating record in DB", e);
@@ -476,7 +487,6 @@ public class MsoRequest {
}
}
-
public Response buildResponse(int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
return buildResponseWithError(httpResponseCode, errorCode, inProgress, null);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 60e9c3b30a..cddb1ada31 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -326,7 +326,7 @@ public class RequestHandlerUtils extends AbstractRestHandler {
String requestScope = requestScopeFromUri(requestUri);
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action,
- requestScope, requestJSON, null);
+ requestScope, requestJSON, null, null);
throw validateException;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 2c8e92633c..7924ca304a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -830,7 +830,8 @@ public class ServiceInstances extends AbstractRestHandler {
} catch (ApiException e) {
msoRequest.createErrorRequestRecord(Status.FAILED, requestId, e.getMessage(), action, requestScope,
requestJSON, requestHandlerUtils
- .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null));
+ .getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).orElse(null),
+ sir);
throw e;
}
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 17b22ec216..9b42eacfc2 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
@@ -29,6 +29,7 @@ import javax.annotation.PostConstruct;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -42,6 +43,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
@@ -297,17 +299,55 @@ public class RequestsDbClient {
restTemplate.exchange(uri, HttpMethod.PATCH, entity, String.class);
}
+ /**
+ * Required for groovy usage. Cannot use Spring Autowired variables
+ *
+ * @param requestId
+ * @param basicAuth
+ * @param host
+ * @return
+ */
public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
URI uri = getUri(host + "/infraActiveRequests/" + requestId);
-
- return getSingleResponse(uri, InfraActiveRequests.class);
+ try {
+ InfraActiveRequests infraActiveRequests = template
+ .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody();
+ if (infraActiveRequests != null) {
+ infraActiveRequests.setRequestId(requestId);
+ }
+ return infraActiveRequests;
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return null;
+ }
+ throw e;
+ }
}
+ /**
+ * Required for groovy usage. Cannot use Spring Autowired variables
+ *
+ * @param request
+ * @param basicAuth
+ * @param host
+ */
public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ template.getInterceptors().add(new SOSpringClientFilter());
+ template.getInterceptors().add(new SpringClientPayloadFilter());
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId());
- HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders());
- restTemplate.put(uri, entity);
+ HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers);
+ template.put(uri, entity);
}
protected URI getUri(String uri) {