aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java56
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java4
10 files changed, 80 insertions, 48 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
index ff8516ea5..dc6e56f4a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,12 @@ import org.onap.vid.mso.model.RequestInfo;
* Created by Oren on 9/5/17.
*/
public class UpdateRequestInfo {
+
+ public String source;
+
+ public Boolean suppressRollback;
+
+ public String requestorId;
public UpdateRequestInfo() {
}
@@ -36,11 +43,6 @@ public class UpdateRequestInfo {
this.suppressRollback = requestInfo.getSuppressRollback();
this.source = requestInfo.getSource();
}
- public String source;
-
- public Boolean suppressRollback;
-
- public String requestorId;
-
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
index fc718f0d2..535c97ce7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -302,7 +302,6 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
-
public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable("vnfInstanceId") String vnfInstanceId,
HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
@@ -449,7 +448,6 @@ public class MsoController extends RestrictedBaseController {
* @return the response entity
* @throws Exception the exception
*/
- //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
@RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVfModule(
@PathVariable("serviceInstanceId") String serviceInstanceId,
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
index cc8fff614..cd6942ee8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +34,11 @@ public class RequestReferencesContainer {
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<>();
-
+
+ public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
+ this.requestReferences = requestReferences;
+ }
+
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
@@ -44,10 +49,6 @@ public class RequestReferencesContainer {
this.additionalProperties.put(name, value);
}
- public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
- this.requestReferences = requestReferences;
- }
-
public RequestReferences getRequestReferences() {
return requestReferences;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
index febd8e0fd..f5c1428fe 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +31,10 @@ public class RelatedVnf extends Node {
private String serviceInstanceName;
private String tenantName;
+ public RelatedVnf(AAITreeNode node) {
+ super(node);
+ }
+
public String getServiceInstanceId() {
return serviceInstanceId;
}
@@ -54,10 +59,6 @@ public class RelatedVnf extends Node {
this.tenantName = tenantName;
}
- public RelatedVnf(AAITreeNode node) {
- super(node);
- }
-
public static RelatedVnf from(AAITreeNode node) {
RelatedVnf vnf = new RelatedVnf(node);
if (node.getParent() != null && node.getParent().getType() == NodeType.SERVICE_INSTANCE) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
index b284b01d9..984c0d766 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java
@@ -21,6 +21,8 @@
package org.onap.vid.model.probes;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
import com.google.common.base.MoreObjects;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
@@ -32,8 +34,6 @@ import org.onap.vid.mso.RestObjectWithRequestInfo;
import org.onap.vid.utils.Logging;
import org.springframework.http.HttpMethod;
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-
public class HttpRequestMetadata extends StatusMetadata {
private final HttpMethod httpMethod;
private final int httpCode;
@@ -90,6 +90,7 @@ public class HttpRequestMetadata extends StatusMetadata {
this.httpCode = response.getResponse().getStatus();
if (readRawData) {
try {
+ response.getResponse().getRawBody().reset();
this.rawData = IOUtils.toString(response.getResponse().getRawBody(), StandardCharsets.UTF_8.name());
} catch (Exception e) {
//Nothing to do here
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 9146e8f1b..4d0d4ee74 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -60,6 +60,8 @@ import javax.ws.rs.BadRequestException;
import org.apache.commons.collections4.ListUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
@@ -67,6 +69,7 @@ import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
+import org.onap.vid.model.probes.ErrorMetadata;
import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.model.probes.HttpRequestMetadata;
import org.onap.vid.model.probes.StatusMetadata;
@@ -84,8 +87,8 @@ import org.onap.vid.mso.rest.RequestList;
import org.onap.vid.mso.rest.RequestWrapper;
import org.onap.vid.mso.rest.Task;
import org.onap.vid.mso.rest.TaskList;
+import org.onap.vid.utils.Logging;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@@ -383,12 +386,13 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
private List<RequestWrapper> getOrchestrationRequestsByFilter(String filterName, String filterValue) {
+ HttpResponseWithRequestInfo<String> msoResponseWrapper = getRawOrchestrationRequestsByFilter(filterName, filterValue);
+ return deserializeOrchestrationRequestsJson(msoResponseWrapper.getResponse().getBody());
+ }
+
+ private HttpResponseWithRequestInfo<String> getRawOrchestrationRequestsByFilter(String filterName, String filterValue) {
String orchestrationReqPath = constructOrchestrationRequestFilter(filterName, filterValue);
- RestObject<String> restObjStr = new RestObject<>();
- String str = new String();
- restObjStr.set(str);
- MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequest(str, "", orchestrationReqPath, restObjStr, true);
- return deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
+ return msoClientInterface.getOrchestrationRequest(orchestrationReqPath, true);
}
private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) {
@@ -837,22 +841,38 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@Override
public ExternalComponentStatus probeComponent() {
- String url = SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL) + "/" + SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
- long startTime = System.currentTimeMillis();
- ExternalComponentStatus externalComponentStatus;
-
+ final long startTime = System.currentTimeMillis();
+ HttpResponseWithRequestInfo<String> responseWithRequestInfo = null;
try {
- String rawBody = objectMapper.writeValueAsString(getOrchestrationRequestsForDashboard());
- StatusMetadata statusMetadata=new HttpRequestMetadata(HttpMethod.GET,200,url,rawBody,"VID-SO",System.currentTimeMillis() - startTime);
+ responseWithRequestInfo = getRawOrchestrationRequestsByFilter("requestExecutionDate", "01-01-2100" );
+ int httpCode = responseWithRequestInfo.getResponse().getStatus();
+ boolean isAvailable = httpCode == 200 || httpCode == 202;
+ if (isAvailable) {
+ //make sure response can be parsed to RequestList.class
+ JACKSON_OBJECT_MAPPER.readValue(responseWithRequestInfo.getResponse().getBody(), RequestList.class);
+ }
+
+ HttpRequestMetadata metadata = new HttpRequestMetadata(responseWithRequestInfo,
+ isAvailable ? "OK" : "MSO returned no orchestration requests",
+ System.currentTimeMillis() - startTime, true);
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, isAvailable, metadata);
- externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, true, statusMetadata);
+ } catch (ExceptionWithRequestInfo e) {
+ long duration = System.currentTimeMillis() - startTime;
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false,
+ new HttpRequestMetadata(e, duration));
} catch (Exception e) {
- StatusMetadata statusMetadata = new HttpRequestMetadata(HttpMethod.GET, HttpStatus.INTERNAL_SERVER_ERROR.value(), url, "", e.getMessage(), System.currentTimeMillis() - startTime);
- externalComponentStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, statusMetadata);
- }
+ StatusMetadata metadata;
+ long duration = System.currentTimeMillis() - startTime;
- return externalComponentStatus;
+ if (responseWithRequestInfo == null) {
+ metadata = new ErrorMetadata(Logging.exceptionToDescription(e), duration);
+ } else {
+ metadata = new HttpRequestMetadata(responseWithRequestInfo, Logging.exceptionToDescription(e), duration, true);
+ }
+
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.MSO, false, metadata);
+ }
}
private void validateUpdateVnfConfig(RequestDetails requestDetails) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 46bd2731d..d1cb3a37b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -21,6 +21,7 @@
package org.onap.vid.mso;
import io.joshworks.restclient.http.HttpResponse;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
@@ -89,7 +90,7 @@ public interface MsoInterface {
MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint);
- MsoResponseWrapper getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject, boolean warpException);
+ HttpResponseWithRequestInfo<String> getOrchestrationRequest(String endpoint, boolean warpException);
MsoResponseWrapper getOrchestrationRequest(String endpoint);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index df8034b22..cc6d6123d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -35,6 +35,7 @@ import org.apache.commons.codec.binary.Base64;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.MsoRequestDetails;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
@@ -51,6 +52,7 @@ import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.RestObject;
import org.onap.vid.utils.Logging;
import org.onap.vid.utils.SystemPropertiesWrapper;
+import org.springframework.http.HttpMethod;
/**
@@ -216,11 +218,11 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
@Override
- public MsoResponseWrapper getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject, boolean warpException) {
+ public HttpResponseWithRequestInfo<String> getOrchestrationRequest(String endpoint, boolean warpException) {
String path = baseUrl + endpoint;
HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
- return MsoUtil.wrapResponse(response);
+ return new HttpResponseWithRequestInfo<>(response, path, HttpMethod.GET);
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
index 78b3e9709..7878c2fb8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
@@ -21,6 +21,7 @@
package org.onap.vid.scheduler;
import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
@@ -43,6 +44,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
@Service
@@ -90,15 +92,19 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
.putAll(commonHeaders)
.put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId())
.build();
- final HttpResponse<T> response = ((HttpResponse<T>) syncRestClient.get(url, requestHeaders,
- Collections.emptyMap(), t.getClass()));
+ final HttpResponse<String> response = syncRestClient.get(url, requestHeaders,
+ Collections.emptyMap(), String.class);
Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
status = response.getStatus();
restObject.setStatusCode(status);
-
+ rawData = response.getBody();
if (status == 200) {
- t = response.getBody();
- restObject.set(t);
+ if (t instanceof String) {
+ restObject.set((T)rawData);
+ }
+ else {
+ restObject.set(JACKSON_OBJECT_MAPPER.readValue(rawData, new TypeReference<T>() {}));
+ }
logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
logger.info(EELFLoggerDelegate.errorLogger, "<== " + methodName + SUCCESSFUL_API_MESSAGE);
} else {
@@ -106,7 +112,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
}
return new RestObjectWithRequestInfo<>(HttpMethod.GET, url, restObject, status, rawData);
}
- catch (RuntimeException e) {
+ catch (Exception e) {
throw new ExceptionWithRequestInfo(HttpMethod.GET, url, rawData, status, e);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
index df7f20e49..71478fcf1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
@@ -119,7 +119,7 @@ public class Logging {
response.bufferEntity();
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.readEntity(entityClass));
}
- catch (ProcessingException | IllegalStateException e) {
+ catch (Exception e) {
logger.debug("Received {} {} Status: {} . Failed to read response as {}", method.name(), url, response.getStatus(), entityClass.getName());
}
}
@@ -128,7 +128,7 @@ public class Logging {
try {
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody());
}
- catch (ProcessingException | IllegalStateException e) {
+ catch (Exception e) {
logger.debug("Received {} {} Status: {} . Failed to read response", method.name(), url, response.getStatus());
}
}