From 6ad41e3ccd398a2721f41ad61c80b7bb03f7d127 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Mon, 31 Dec 2018 17:21:27 +0200 Subject: Merge from ECOMP's repository Main Features -------------- - Async-Instantiation jobs mechanism major update; still WIP (package `org.onap.vid.job`) - New features in View/Edit: Activate fabric configuration; show related networks; soft delete - Support AAI service-tree traversal (`AAIServiceTree`) - In-memory cache for SDC models and certain A&AI queries (`CacheProviderWithLoadingCache`) - Upgrade TOSCA Parser and add parsing options; fix malformed TOSCA models - Resolve Cloud-Owner values for MSO - Pass X-ONAP headers to MSO Infrastructure -------------- - Remove codehaus' jackson mapper; use soley fasterxml 2.9.7 - Surefire invokes both TestNG and JUnit tests - Support Kotlin source files - AaiController2 which handles errors in a "Spring manner" - Inline generated-sources and remove jsonschema2pojo Quality -------- - Cumulative bug fixes (A&AI API, UI timeouts, and many more) - Many Sonar issues cleaned-up - Some unused classes removed - Minor changes in vid-automation project, allowing some API verification to run Hard Merges ------------ - HTTP Clients (MSO, A&AI, WebConfig, OutgoingRequestHeadersTest) - Moved `package org.onap.vid.controllers` to `controller`, without plural -- just to keep semantic sync with ECOMP. Reference commit in ECOMP: 3d1141625 Issue-ID: VID-378 Change-Id: I9c8d1e74caa41815891d441fc0760bb5f29c5788 Signed-off-by: Ittay Stern --- .../org/onap/vid/mso/rest/AsyncRequestStatus.java | 27 ++- .../onap/vid/mso/rest/AsyncRequestStatusList.java | 17 ++ .../java/org/onap/vid/mso/rest/InstanceIds.java | 202 ++++++++++++++++++ .../org/onap/vid/mso/rest/MsoRestClientNew.java | 186 ++++++++--------- .../org/onap/vid/mso/rest/RelatedInstance.java | 84 ++++++-- .../java/org/onap/vid/mso/rest/RelatedModel.java | 125 ----------- .../main/java/org/onap/vid/mso/rest/Request.java | 231 ++++++++++++++++++--- .../java/org/onap/vid/mso/rest/RequestDetails.java | 41 ++-- .../java/org/onap/vid/mso/rest/RequestList.java | 23 +- .../java/org/onap/vid/mso/rest/RequestStatus.java | 208 +++++++++++++++++++ .../java/org/onap/vid/mso/rest/RestInterface.java | 25 +-- .../java/org/onap/vid/mso/rest/SubscriberInfo.java | 144 +++++++++++++ 12 files changed, 1000 insertions(+), 313 deletions(-) create mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatusList.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/rest/InstanceIds.java delete mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/mso/rest/SubscriberInfo.java (limited to 'vid-app-common/src/main/java/org/onap/vid/mso/rest') diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java index 4c3dca26f..7d844feed 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java @@ -23,7 +23,6 @@ package org.onap.vid.mso.rest; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import org.onap.vid.domain.mso.RequestStatus; /** * Represent response for: GET orchestrationRequests @@ -53,16 +52,29 @@ public class AsyncRequestStatus { } public String requestId; + public String requestScope; /** * The instance ids. */ public InstanceReferences instanceReferences; + + /** + * The request details. + */ + public RequestDetails requestDetails; + /** * The request status. */ public RequestStatus requestStatus; + + /** + * The time of start. + */ + public String startTime; + } @JsonIgnoreProperties(ignoreUnknown = true) @@ -71,5 +83,18 @@ public class AsyncRequestStatus { public String serviceInstanceId; } + @JsonIgnoreProperties(ignoreUnknown = true) + public static class RequestDetails { + + public RequestInfo requestInfo; + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class RequestInfo { + + public String instanceName; + } + + } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatusList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatusList.java new file mode 100644 index 000000000..04ced39fb --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatusList.java @@ -0,0 +1,17 @@ +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class AsyncRequestStatusList { + AsyncRequestStatusList(@JsonProperty("requestList") List requestList) { + this.requestList = requestList; + } + + public List getRequestList() { + return requestList; + } + + private final List requestList; +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/InstanceIds.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/InstanceIds.java new file mode 100644 index 000000000..5e1c5ce88 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/InstanceIds.java @@ -0,0 +1,202 @@ + +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.*; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.HashMap; +import java.util.Map; + + +/** + * instanceIds that may be associated with a particular request + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "networkInstanceId", + "serviceInstanceId", + "vfModuleInstanceId", + "vnfInstanceId", + "volumeGroupInstanceId" +}) +public class InstanceIds { + + /** + * UUID for the network instance (if any) + * + */ + @JsonProperty("networkInstanceId") + private String networkInstanceId; + /** + * UUID for the service instance + * + */ + @JsonProperty("serviceInstanceId") + private String serviceInstanceId; + /** + * UUID for the vfModule instance (if any) + * + */ + @JsonProperty("vfModuleInstanceId") + private String vfModuleInstanceId; + /** + * UUID for the vnf instance (if any) + * + */ + @JsonProperty("vnfInstanceId") + private String vnfInstanceId; + /** + * UUID for the volume group instance (if any) + * + */ + @JsonProperty("volumeGroupInstanceId") + private String volumeGroupInstanceId; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + /** + * UUID for the network instance (if any) + * + * @return + * The networkInstanceId + */ + @JsonProperty("networkInstanceId") + public String getNetworkInstanceId() { + return networkInstanceId; + } + + /** + * UUID for the network instance (if any) + * + * @param networkInstanceId + * The networkInstanceId + */ + @JsonProperty("networkInstanceId") + public void setNetworkInstanceId(String networkInstanceId) { + this.networkInstanceId = networkInstanceId; + } + + /** + * UUID for the service instance + * + * @return + * The serviceInstanceId + */ + @JsonProperty("serviceInstanceId") + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * UUID for the service instance + * + * @param serviceInstanceId + * The serviceInstanceId + */ + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + /** + * UUID for the vfModule instance (if any) + * + * @return + * The vfModuleInstanceId + */ + @JsonProperty("vfModuleInstanceId") + public String getVfModuleInstanceId() { + return vfModuleInstanceId; + } + + /** + * UUID for the vfModule instance (if any) + * + * @param vfModuleInstanceId + * The vfModuleInstanceId + */ + @JsonProperty("vfModuleInstanceId") + public void setVfModuleInstanceId(String vfModuleInstanceId) { + this.vfModuleInstanceId = vfModuleInstanceId; + } + + /** + * UUID for the vnf instance (if any) + * + * @return + * The vnfInstanceId + */ + @JsonProperty("vnfInstanceId") + public String getVnfInstanceId() { + return vnfInstanceId; + } + + /** + * UUID for the vnf instance (if any) + * + * @param vnfInstanceId + * The vnfInstanceId + */ + @JsonProperty("vnfInstanceId") + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + /** + * UUID for the volume group instance (if any) + * + * @return + * The volumeGroupInstanceId + */ + @JsonProperty("volumeGroupInstanceId") + public String getVolumeGroupInstanceId() { + return volumeGroupInstanceId; + } + + /** + * UUID for the volume group instance (if any) + * + * @param volumeGroupInstanceId + * The volumeGroupInstanceId + */ + @JsonProperty("volumeGroupInstanceId") + public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(networkInstanceId).append(serviceInstanceId).append(vfModuleInstanceId).append(vnfInstanceId).append(volumeGroupInstanceId).append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof InstanceIds)) { + return false; + } + InstanceIds rhs = ((InstanceIds) other); + return new EqualsBuilder().append(networkInstanceId, rhs.networkInstanceId).append(serviceInstanceId, rhs.serviceInstanceId).append(vfModuleInstanceId, rhs.vfModuleInstanceId).append(vnfInstanceId, rhs.vnfInstanceId).append(volumeGroupInstanceId, rhs.volumeGroupInstanceId).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} 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 37600f7b9..2ff337653 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 @@ -22,10 +22,6 @@ package org.onap.vid.mso.rest; import com.google.common.collect.ImmutableMap; import io.joshworks.restclient.http.HttpResponse; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; import org.apache.commons.codec.binary.Base64; import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -35,17 +31,21 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.client.SyncRestClient; import org.onap.vid.model.RequestReferencesContainer; import org.onap.vid.mso.*; +import org.onap.vid.utils.Logging; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import org.onap.vid.utils.Logging; +import java.util.HashMap; +import java.util.Map; /** * Created by pickjonathan on 21/06/2017. */ -public class MsoRestClientNew implements MsoInterface { +public class MsoRestClientNew extends RestMsoImplementation implements MsoInterface { /** * The Constant dateFormat. @@ -70,7 +70,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) { String methodName = "createSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -79,7 +79,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper createE2eSvcInstance(Object requestDetails, String endpoint) { String methodName = "createE2eSvcInstance "; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -89,7 +89,7 @@ public class MsoRestClientNew implements MsoInterface { public MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) { String methodName = "createVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -99,7 +99,7 @@ public class MsoRestClientNew implements MsoInterface { public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) { String methodName = "createNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -108,7 +108,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String endpoint) { String methodName = "createVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -117,7 +117,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) { String methodName = "createVfModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetails, path); @@ -126,7 +126,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) { String methodName = "scaleOutVFModuleInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetailsWrapper, path); } @@ -134,7 +134,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper createConfigurationInstance(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) { String methodName = "createConfigurationInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return createInstance(requestDetailsWrapper, path); @@ -143,7 +143,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String endpoint) { String methodName = "deleteE2eSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); } @@ -151,7 +151,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) { String methodName = "deleteSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); } @@ -159,15 +159,17 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint) { String methodName = "unassignSvcInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); - HttpResponse response = client.post(endpoint, commonHeaders, requestDetails, String.class); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); + String path = baseUrl + endpoint; + + HttpResponse response = client.post(path, commonHeaders, requestDetails, String.class); return MsoUtil.wrapResponse(response); } @Override public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) { String methodName = "deleteVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); @@ -176,7 +178,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) { String methodName = "deleteVfModule"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); @@ -185,7 +187,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) { String methodName = "deleteVolumeGroupInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); @@ -194,59 +196,50 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) { String methodName = "deleteNwInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return deleteInstance(requestDetails, path); } @Override - public MsoResponseWrapper getOrchestrationRequest(String endpoint) { + public MsoResponseWrapper getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject, boolean warpException) { String path = baseUrl + endpoint; HttpResponse response = client.get(path, commonHeaders, new HashMap<>(), String.class); return MsoUtil.wrapResponse(response); } - public MsoResponseWrapper getManualTasks(String endpoint) { + @Override + public MsoResponseWrapper getOrchestrationRequest(String endpoint) { String path = baseUrl + endpoint; HttpResponse response = client.get(path, commonHeaders, new HashMap<>(), String.class); return MsoUtil.wrapResponse(response); } - public MsoResponseWrapper getOrchestrationRequestsForDashboard(String t, String sourceId, String path, RestObject restObject) { - String methodName = "getOrchestrationRequestsForDashboard"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); - - try { - MsoResponseWrapper w = getOrchestrationRequest(path); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); - - return w; + public MsoResponseWrapper getManualTasks(String endpoint) { + String path = baseUrl + endpoint; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - throw e; - } + HttpResponse response = client.get(path, commonHeaders, new HashMap<>(), String.class); + return MsoUtil.wrapResponse(response); } public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) { String methodName = "getManualTasksByRequestId"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(methodName + START); try { String path = baseUrl + endpoint; MsoResponseWrapper w =getManualTasks(path); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -254,19 +247,19 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) { String methodName = "completeManualTask"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Complete "); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Complete "); try { String path = baseUrl + endpoint; HttpResponse response = client.post(path, commonHeaders, requestDetails, String.class); MsoResponseWrapper w = MsoUtil.wrapResponse(response); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -274,7 +267,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) { String methodName = "replaceVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; return replaceInstance(requestDetails, path); } @@ -283,7 +276,7 @@ public class MsoRestClientNew implements MsoInterface { public MsoResponseWrapper deleteConfiguration(org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String pmc_endpoint) { String methodName = "deleteConfiguration"; logger.debug(EELFLoggerDelegate.debugLogger, - dateFormat.format(new Date()) + "<== " + methodName + START); + methodName + START); String path = baseUrl + pmc_endpoint; return deleteInstance(requestDetailsWrapper, path); @@ -292,7 +285,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper setConfigurationActiveStatus(RequestDetails request, String endpoint) { String methodName = "setConfigurationActiveStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { String path = baseUrl + endpoint; @@ -302,8 +295,8 @@ public class MsoRestClientNew implements MsoInterface { HttpResponse response = client.post(path, commonHeaders, request, String.class); return MsoUtil.wrapResponse(response); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -311,7 +304,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails request, String endpoint) { String methodName = "setPortOnConfigurationStatus"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { String path = baseUrl + endpoint; @@ -320,8 +313,8 @@ public class MsoRestClientNew implements MsoInterface { HttpResponse response = client.post(path, commonHeaders, request, String.class); return MsoUtil.wrapResponse(response); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -335,28 +328,29 @@ public class MsoRestClientNew implements MsoInterface { public MsoResponseWrapper replaceInstance(org.onap.vid.changeManagement.RequestDetails request, String path) { String methodName = "replaceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Replace VNF, path =[" + path + "]"); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Replace VNF, path =[" + path + "]"); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = new MsoRequestDetails(request); - HttpResponse response = client.post(path, commonHeaders, request, String.class); + HttpResponse response = client.post(path, commonHeaders, requestDetailsWrapper, String.class); MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(response); int status = msoResponseWrapperObject.getStatus(); if (status == 202) { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + + logger.debug(EELFLoggerDelegate.debugLogger, methodName + ",post succeeded, msoResponseWrapperObject response:" + msoResponseWrapperObject.getResponse()); } else { - logger.error(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + + logger.error(EELFLoggerDelegate.debugLogger, methodName + ": post failed, msoResponseWrapperObject status" + status + ", response:" + msoResponseWrapperObject.getResponse()); - // TODO } return msoResponseWrapperObject; } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } @@ -365,7 +359,7 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) { String methodName = "updateVnf"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); String path = baseUrl + endpoint; RequestDetailsWrapper wrapper = new RequestDetailsWrapper(); @@ -375,20 +369,22 @@ public class MsoRestClientNew implements MsoInterface { public MsoResponseWrapper updateInstance(org.onap.vid.changeManagement.RequestDetails request, String path) { String methodName = "updateInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Delete, path =[" + path + "]"); - HttpResponse response = client.post(path, commonHeaders, request, String.class); + RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper(); + requestDetailsWrapper.requestDetails = new MsoRequestDetails(request); + HttpResponse response = client.put(path, commonHeaders, requestDetailsWrapper, String.class); MsoResponseWrapper w = MsoUtil.wrapResponse(response); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } @@ -396,16 +392,16 @@ public class MsoRestClientNew implements MsoInterface { public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) { String methodName = "activateServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start "); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start "); try { String path = baseUrl + endpoint; HttpResponse response = client.post(path, commonHeaders, requestDetails, String.class); MsoResponseWrapper w = MsoUtil.wrapResponse(response); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w =" + w.getResponse()); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w =" + w.getResponse()); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -413,16 +409,16 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) { String methodName = "removeRelationshipFromServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]"); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]"); String path = baseUrl + endpoint; HttpResponse response = client.post(path, commonHeaders, requestDetails, String.class); return MsoUtil.wrapResponse(response); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -430,43 +426,45 @@ public class MsoRestClientNew implements MsoInterface { @Override public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) { String methodName = "addRelationshipToServiceInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]"); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]"); String path = baseUrl + addRelationshipsPath; HttpResponse response = client.post(path, commonHeaders, requestDetails, String.class); return MsoUtil.wrapResponse(response); } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @Override - public HttpResponse get(String path, Class responseClass) { + public HttpResponse get(String endpoint, Class responseClass) { + String path = baseUrl + endpoint; return client.get(path, commonHeaders, new HashMap<>(), responseClass); } @Override - public HttpResponse post(String path, RequestDetailsWrapper requestDetailsWrapper, - Class responseClass) { + public HttpResponse post(String endpoint, RequestDetailsWrapper requestDetailsWrapper, Class responseClass) { + String path = baseUrl + endpoint; + return client.post(path, commonHeaders, requestDetailsWrapper, responseClass); } - private MsoResponseWrapper createInstance(Object request, String endpoint) { + private MsoResponseWrapper createInstance(Object request, String path) { String methodName = "createInstance"; - logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(methodName + START); try { - HttpResponse response = client.post(endpoint, commonHeaders, request, String.class); + HttpResponse response = client.post(path, commonHeaders, request, String.class); return MsoUtil.wrapResponse(response); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } } @@ -481,20 +479,20 @@ public class MsoRestClientNew implements MsoInterface { */ private MsoResponseWrapper deleteInstance(Object request, String path) { String methodName = "deleteInstance"; - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + START); try { - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]"); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Delete, path =[" + path + "]"); HttpResponse response = client.delete(path, commonHeaders, request, String.class); MsoResponseWrapper w = MsoUtil.wrapResponse(response); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse()); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString()); + logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString()); + logger.debug(EELFLoggerDelegate.debugLogger, "." + methodName + e.toString()); throw e; } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java index 3fd4cd4d1..2f64e3a56 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java @@ -20,40 +20,92 @@ package org.onap.vid.mso.rest; -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.*; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; +import org.onap.vid.mso.model.ModelInfo; + +import java.util.HashMap; +import java.util.Map; /** * modelInfo and optional instanceId and instanceName for a model related to the modelInfo being operated on. */ @JsonInclude(JsonInclude.Include.NON_NULL) -@Generated("org.jsonschema2pojo") @JsonPropertyOrder({ "instanceName", "instanceId", "modelInfo" }) -public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{ +public class RelatedInstance { + + /** + * optional name for the instance Id of the related model + * + */ + @JsonProperty("instanceName") + private String instanceName; + /** + * instance Id for the related model + * + */ + @JsonProperty("instanceId") + private String instanceId; /** The model info. */ @JsonProperty("modelInfo") - private org.onap.vid.domain.mso.ModelInfo modelInfo; + private ModelInfo modelInfo; /** The additional properties. */ @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); + + /** + * optional name for the instance Id of the related model + * + * @return + * The instanceName + */ + @JsonProperty("instanceName") + public String getInstanceName() { + return instanceName; + } + + /** + * optional name for the instance Id of the related model + * + * @param instanceName + * The instanceName + */ + @JsonProperty("instanceName") + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + /** + * instance Id for the related model + * + * @return + * The instanceId + */ + @JsonProperty("instanceId") + public String getInstanceId() { + return instanceId; + } + + /** + * instance Id for the related model + * + * @param instanceId + * The instanceId + */ + @JsonProperty("instanceId") + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } /** * (Required). @@ -61,7 +113,7 @@ public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{ * @return The modelInfo */ @JsonProperty("modelInfo") - public org.onap.vid.domain.mso.ModelInfo getModelInfo() { + public ModelInfo getModelInfo() { return modelInfo; } @@ -71,7 +123,7 @@ public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{ * @param modelInfo The modelInfo */ @JsonProperty("modelInfo") - public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) { + public void setModelInfo(ModelInfo modelInfo) { this.modelInfo = modelInfo; } @@ -115,7 +167,7 @@ public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{ if (other == this) { return true; } - if ((other instanceof RelatedInstance) == false) { + if (!(other instanceof RelatedInstance)) { return false; } RelatedInstance rhs = ((RelatedInstance) other); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java deleted file mode 100644 index 36487c596..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.vid.mso.rest; - -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - - -/** - * modelInfo and optional instance id for a model related to the modelInfo being operated on. - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "instanceId", - "modelInfo" -}) -public class RelatedModel extends org.onap.vid.domain.mso.RelatedModel { - - /** (Required). */ - @JsonProperty("modelInfo") - private org.onap.vid.domain.mso.ModelInfo modelInfo; - -// /** The related model object instance list. */ -// @JsonProperty("instanceId") -// private org.onap.vid.domain.mso.InstanceIds instanceId; - - /** The additional properties. */ - @JsonIgnore - private Map additionalProperties = new HashMap(); - - /** - * (Required). - * - * @return The modelInfo - */ - @JsonProperty("modelInfo") - public org.onap.vid.domain.mso.ModelInfo getModelInfo() { - return modelInfo; - } - - /** - * (Required). - * - * @param modelInfo The modelInfo - */ - @JsonProperty("modelInfo") - public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) { - this.modelInfo = modelInfo; - } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.RelatedModel#toString() - */ - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.RelatedModel#getAdditionalProperties() - */ - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.RelatedModel#setAdditionalProperty(java.lang.String, java.lang.Object) - */ - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.RelatedModel#hashCode() - */ - @Override - public int hashCode() { - return new HashCodeBuilder().append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode(); - } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.RelatedModel#equals(java.lang.Object) - */ - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - if ((other instanceof RelatedModel) == false) { - return false; - } - RelatedModel rhs = ((RelatedModel) other); - return new EqualsBuilder().append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.modelInfo).append(additionalProperties, rhs.additionalProperties).isEquals(); - } - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java index ee1652e75..91739937a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java @@ -20,44 +20,89 @@ package org.onap.vid.mso.rest; -//import java.util.HashMap; -//import java.util.Map; -//import javax.annotation.Generated; - -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.onap.vid.domain.mso.InstanceIds; -import org.onap.vid.domain.mso.RequestStatus; -//import com.fasterxml.jackson.annotation.JsonAnyGetter; -//import com.fasterxml.jackson.annotation.JsonAnySetter; -//import com.fasterxml.jackson.annotation.JsonCreator; -//import com.fasterxml.jackson.annotation.JsonIgnore; -//import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -//import com.fasterxml.jackson.annotation.JsonPropertyOrder; -//import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.*; import org.apache.commons.lang.builder.EqualsBuilder; -//import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import java.util.HashMap; +import java.util.Map; /** * request structure. */ -public class Request extends org.onap.vid.domain.mso.Request { +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "finishTime", + "instanceIds", + "requestDetails", + "requestId", + "requestScope", + "requestStatus", + "requestType", + "startTime" +}) +public class Request { /** The instance ids. */ + @JsonProperty("instanceIds") private InstanceIds instanceIds; /** The request details. */ + @JsonProperty("requestDetails") private RequestDetails requestDetails; /** The request status. */ + @JsonProperty("requestStatus") private RequestStatus requestStatus; - - + + /** + * Date and time the request was finished in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * + */ + @JsonProperty("finishTime") + private String finishTime; + + /** + * UUID for the request generated by the instantiation service + * (Required) + * + */ + @JsonProperty("requestId") + private String requestId; + + /** + * short description of the entity being operated on + * (Required) + * + */ + @JsonProperty("requestScope") + private String requestScope; + + /** + * short description of the action being performed on the requestScope + * (Required) + * + */ + @JsonProperty("requestType") + private String requestType; + + /** + * Date and time the request was created in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + */ + @JsonProperty("startTime") + private String startTime; + + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + /* (non-Javadoc) - * @see org.onap.vid.domain.mso.Request#getInstanceIds() + * @see org.openecomp.vid.domain.mso.Request#getInstanceIds() */ @JsonProperty("instanceIds") public InstanceIds getInstanceIds() { @@ -115,32 +160,154 @@ public class Request extends org.onap.vid.domain.mso.Request { this.requestStatus = requestStatus; } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.Request#toString() + /** + * Date and time the request was finished in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * + * @return + * The finishTime + */ + @JsonProperty("finishTime") + public String getFinishTime() { + return finishTime; + } + + /** + * Date and time the request was finished in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * + * @param finishTime + * The finishTime + */ + @JsonProperty("finishTime") + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + /** + * UUID for the request generated by the instantiation service + * (Required) + * + * @return + * The requestId + */ + @JsonProperty("requestId") + public String getRequestId() { + return requestId; + } + + /** + * UUID for the request generated by the instantiation service + * (Required) + * + * @param requestId + * The requestId */ + @JsonProperty("requestId") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + /** + * short description of the entity being operated on + * (Required) + * + * @return + * The requestScope + */ + @JsonProperty("requestScope") + public String getRequestScope() { + return requestScope; + } + + /** + * short description of the entity being operated on + * (Required) + * + * @param requestScope + * The requestScope + */ + @JsonProperty("requestScope") + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + /** + * short description of the action being performed on the requestScope + * (Required) + * + * @return + * The requestType + */ + @JsonProperty("requestType") + public String getRequestType() { + return requestType; + } + + /** + * short description of the action being performed on the requestScope + * (Required) + * + * @param requestType + * The requestType + */ + @JsonProperty("requestType") + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + /** + * Date and time the request was created in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + * @return + * The startTime + */ + @JsonProperty("startTime") + public String getStartTime() { + return startTime; + } + + /** + * Date and time the request was created in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + * @param startTime + * The startTime + */ + @JsonProperty("startTime") + public void setStartTime(String startTime) { + this.startTime = startTime; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this); } - - /* (non-Javadoc) - * @see org.onap.vid.domain.mso.Request#equals(java.lang.Object) - */ + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37).append(getFinishTime()).append(getInstanceIds()).append(getRequestDetails()).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode(); + } + @Override public boolean equals(Object other) { if (other == this) { return true; } - if ((other instanceof Request) == false) { + if (!(other instanceof Request)) { return false; } Request rhs = ((Request) other); return new EqualsBuilder().append(getFinishTime(), rhs.getFinishTime()).append(getInstanceIds(), rhs.getInstanceIds()).append(getRequestDetails(), rhs.getRequestDetails()).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals(); } - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37).append(getFinishTime()).append(getInstanceIds()).append(getRequestDetails()).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode(); - } } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java index 2b159f812..da6d46da5 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java @@ -20,20 +20,15 @@ package org.onap.vid.mso.rest; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.*; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.onap.vid.domain.mso.CloudConfiguration; -import org.onap.vid.domain.mso.ModelInfo; -import org.onap.vid.domain.mso.RequestInfo; -import org.onap.vid.domain.mso.RequestParameters; -import org.onap.vid.domain.mso.SubscriberInfo; +import org.onap.vid.exceptions.NotFoundException; +import org.onap.vid.mso.model.CloudConfiguration; +import org.onap.vid.mso.model.ModelInfo; +import org.onap.vid.mso.model.RequestInfo; +import org.onap.vid.mso.model.RequestParameters; import java.util.HashMap; import java.util.List; @@ -86,7 +81,7 @@ public class RequestDetails{ /** The additional properties. */ @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); /** * Gets the cloud configuration. @@ -269,4 +264,26 @@ public class RequestDetails{ public void setRequestParameters(RequestParameters requestParameters) { this.requestParameters = requestParameters; } + + public T extractValueByPathUsingAdditionalProperties (List keys, Class clazz) { + Object result = getAdditionalProperties(); + for (String key : keys) { + if (result instanceof Map) { + result = ((Map) result).get(key); + } + + else { + throw new NotFoundException("failed to find key: "+key+" in path: "+String.join("\\", keys)); + } + } + if (clazz.isInstance(result)) { + return clazz.cast(result); + } + + throw new NotFoundException( + String.format("failed to extract value from path:%s because %s is not of type %s", + String.join("\\", keys), String.valueOf(result) , clazz)); + } + + } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java index 8f8272c07..00289da65 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java @@ -20,30 +20,19 @@ package org.onap.vid.mso.rest; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Generated; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -//import com.fasterxml.jackson.annotation.JsonInclude; -//import com.fasterxml.jackson.annotation.JsonProperty; -//import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.*; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * List of relatedModel structures that are related to a modelInfo being operated on. */ @JsonInclude(JsonInclude.Include.NON_NULL) -@Generated("org.jsonschema2pojo") @JsonPropertyOrder({ "finishTime", "instanceIds", @@ -62,7 +51,7 @@ public class RequestList { /** The additional properties. */ @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); /** * (Required). @@ -127,7 +116,7 @@ public class RequestList { if (other == this) { return true; } - if ((other instanceof RequestList) == false) { + if (!(other instanceof RequestList)) { return false; } RequestList rhs = ((RequestList) other); diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java new file mode 100644 index 000000000..f9c890454 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java @@ -0,0 +1,208 @@ + +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.*; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.HashMap; +import java.util.Map; + + +/** + * fields describing the status of a request + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "percentProgress", + "requestState", + "statusMessage", + "timestamp", + "wasRolledBack" +}) +public class RequestStatus { + + /** + * percentage complete estimate from 0 to 100 + * + */ + @JsonProperty("percentProgress") + private Double percentProgress; + /** + * short description of the instantiation state + * (Required) + * + */ + @JsonProperty("requestState") + private String requestState; + /** + * additional descriptive information about the status + * + */ + @JsonProperty("statusMessage") + private String statusMessage; + /** + * GMT Datetime the requestStatus was created e.g.: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + */ + @JsonProperty("timestamp") + private String timestamp; + /** + * true or false boolean indicating whether the request was rolled back + * + */ + @JsonProperty("wasRolledBack") + private Boolean wasRolledBack; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + /** + * percentage complete estimate from 0 to 100 + * + * @return + * The percentProgress + */ + @JsonProperty("percentProgress") + public Double getPercentProgress() { + return percentProgress; + } + + /** + * percentage complete estimate from 0 to 100 + * + * @param percentProgress + * The percentProgress + */ + @JsonProperty("percentProgress") + public void setPercentProgress(Double percentProgress) { + this.percentProgress = percentProgress; + } + + /** + * short description of the instantiation state + * (Required) + * + * @return + * The requestState + */ + @JsonProperty("requestState") + public String getRequestState() { + return requestState; + } + + /** + * short description of the instantiation state + * (Required) + * + * @param requestState + * The requestState + */ + @JsonProperty("requestState") + public void setRequestState(String requestState) { + this.requestState = requestState; + } + + /** + * additional descriptive information about the status + * + * @return + * The statusMessage + */ + @JsonProperty("statusMessage") + public String getStatusMessage() { + return statusMessage; + } + + /** + * additional descriptive information about the status + * + * @param statusMessage + * The statusMessage + */ + @JsonProperty("statusMessage") + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + /** + * GMT Datetime the requestStatus was created e.g.: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + * @return + * The timestamp + */ + @JsonProperty("timestamp") + public String getTimestamp() { + return timestamp; + } + + /** + * GMT Datetime the requestStatus was created e.g.: Wed, 15 Oct 2014 13:01:52 GMT + * (Required) + * + * @param timestamp + * The timestamp + */ + @JsonProperty("timestamp") + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + /** + * true or false boolean indicating whether the request was rolled back + * + * @return + * The wasRolledBack + */ + @JsonProperty("wasRolledBack") + public Boolean getWasRolledBack() { + return wasRolledBack; + } + + /** + * true or false boolean indicating whether the request was rolled back + * + * @param wasRolledBack + * The wasRolledBack + */ + @JsonProperty("wasRolledBack") + public void setWasRolledBack(Boolean wasRolledBack) { + this.wasRolledBack = wasRolledBack; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(percentProgress).append(requestState).append(statusMessage).append(timestamp).append(wasRolledBack).append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof RequestStatus)) { + return false; + } + RequestStatus rhs = ((RequestStatus) other); + return new EqualsBuilder().append(percentProgress, rhs.percentProgress).append(requestState, rhs.requestState).append(statusMessage, rhs.statusMessage).append(timestamp, rhs.timestamp).append(wasRolledBack, rhs.wasRolledBack).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java index feb3f3c1e..ec117cf04 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java @@ -1,30 +1,25 @@ package org.onap.vid.mso.rest; +import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.mso.RestObject; - -import javax.ws.rs.core.MultivaluedHashMap; +import org.onap.vid.mso.RestObjectWithRequestInfo; /** * Created by pickjonathan on 26/06/2017. */ public interface RestInterface { - /** - * Inits the rest client. - */ - MultivaluedHashMap initMsoClient(); - /** * Gets the. * * @param the generic type * @param t the t - * @param sourceId the source id * @param path the path * @param restObject the rest object + * @param warpException * @throws Exception the exception */ - void Get (T t, String sourceId, String path, RestObject restObject ); + RestObjectWithRequestInfo Get(T t, String path, RestObject restObject, boolean warpException); /** * Delete. @@ -32,25 +27,22 @@ public interface RestInterface { * @param the generic type * @param t the t * @param r the r - * @param sourceID the source ID * @param path the path * @param restObject the rest object * @throws Exception the exception */ - void Delete(T t, Object r, String sourceID, String path, RestObject restObject); + void Delete(T t, Object r, String path, RestObject restObject); /** * Post. * - * @param the generic type * @param t the t * @param r the r - * @param sourceID the source ID * @param path the path * @param restObject the rest object * @throws Exception the exception */ - void Post(T t, Object r, String sourceID, String path, RestObject restObject); + void Post(String t, Object r, String path, RestObject restObject); /** * Put. @@ -58,11 +50,12 @@ public interface RestInterface { * @param the generic type * @param t the t * @param r the r - * @param sourceID the source ID * @param path the path * @param restObject the rest object * @throws Exception the exception */ - void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String sourceID, String path, RestObject restObject); + void Put(T t, RequestDetailsWrapper r, String path, RestObject restObject); + + RestObject GetForObject(String path, Class clazz); } diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/SubscriberInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/SubscriberInfo.java new file mode 100644 index 000000000..0c8d7c2a1 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/SubscriberInfo.java @@ -0,0 +1,144 @@ + +package org.onap.vid.mso.rest; + +import com.fasterxml.jackson.annotation.*; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.util.HashMap; +import java.util.Map; + + +/** + * fields providing information about the subscriber associated with the request + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "globalSubscriberId", + "subscriberCommonSiteId", + "subscriberName" +}) +public class SubscriberInfo { + + /** + * global Customer Id understood by A&AI + * + */ + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + /** + * id representing the location of the subscriber + * + */ + @JsonProperty("subscriberCommonSiteId") + private String subscriberCommonSiteId; + /** + * name of the customer or subscriber + * + */ + @JsonProperty("subscriberName") + private String subscriberName; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + /** + * global Customer Id understood by A&AI + * + * @return + * The globalSubscriberId + */ + @JsonProperty("globalSubscriberId") + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + /** + * global Customer Id understood by A&AI + * + * @param globalSubscriberId + * The globalSubscriberId + */ + @JsonProperty("globalSubscriberId") + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + /** + * id representing the location of the subscriber + * + * @return + * The subscriberCommonSiteId + */ + @JsonProperty("subscriberCommonSiteId") + public String getSubscriberCommonSiteId() { + return subscriberCommonSiteId; + } + + /** + * id representing the location of the subscriber + * + * @param subscriberCommonSiteId + * The subscriberCommonSiteId + */ + @JsonProperty("subscriberCommonSiteId") + public void setSubscriberCommonSiteId(String subscriberCommonSiteId) { + this.subscriberCommonSiteId = subscriberCommonSiteId; + } + + /** + * name of the customer or subscriber + * + * @return + * The subscriberName + */ + @JsonProperty("subscriberName") + public String getSubscriberName() { + return subscriberName; + } + + /** + * name of the customer or subscriber + * + * @param subscriberName + * The subscriberName + */ + @JsonProperty("subscriberName") + public void setSubscriberName(String subscriberName) { + this.subscriberName = subscriberName; + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(globalSubscriberId).append(subscriberCommonSiteId).append(subscriberName).append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof SubscriberInfo)) { + return false; + } + SubscriberInfo rhs = ((SubscriberInfo) other); + return new EqualsBuilder().append(globalSubscriberId, rhs.globalSubscriberId).append(subscriberCommonSiteId, rhs.subscriberCommonSiteId).append(subscriberName, rhs.subscriberName).append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} -- cgit 1.2.3-korg