From 76e46d726af8c3221f1e72b65c12be6ca8f59571 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Wed, 28 Mar 2018 23:27:50 -0400 Subject: removed unused api-handler code Change-Id: I4fc23794cc96092ca4144bd847de91cff4bdb02b Issue-ID: SO-548 Signed-off-by: Benjamin, Max (mb388a) --- .../openecomp/mso/apihandlerinfra/Constants.java | 104 ++- .../mso/apihandlerinfra/NetworkInfoHandler.java | 340 --------- .../apihandlerinfra/NetworkMsoInfraRequest.java | 622 ---------------- .../mso/apihandlerinfra/NetworkRequestHandler.java | 670 ----------------- .../mso/apihandlerinfra/NetworkTypesHandler.java | 107 --- .../apihandlerinfra/VfModuleModelNamesHandler.java | 107 --- .../mso/apihandlerinfra/VnfInfoHandler.java | 377 ---------- .../mso/apihandlerinfra/VnfMsoInfraRequest.java | 717 ------------------ .../mso/apihandlerinfra/VnfRequestHandler.java | 807 --------------------- .../mso/apihandlerinfra/VnfRequestType.java | 30 - .../mso/apihandlerinfra/VnfTypesHandler.java | 113 --- .../mso/apihandlerinfra/VolumeInfoHandler.java | 371 ---------- .../mso/apihandlerinfra/VolumeMsoInfraRequest.java | 647 ----------------- .../mso/apihandlerinfra/VolumeRequestHandler.java | 750 ------------------- .../apihandlerinfra/networkbeans/ActionType.java | 74 -- .../networkbeans/NetworkInputs.java | 378 ---------- .../networkbeans/NetworkOutputs.java | 120 --- .../networkbeans/NetworkRequest.java | 179 ----- .../networkbeans/NetworkRequests.java | 99 --- .../apihandlerinfra/networkbeans/NetworkType.java | 148 ---- .../apihandlerinfra/networkbeans/NetworkTypes.java | 99 --- .../networkbeans/ObjectFactory.java | 129 ---- .../apihandlerinfra/networkbeans/RequestInfo.java | 285 -------- .../networkbeans/RequestStatusType.java | 70 -- .../apihandlerinfra/networkbeans/package-info.java | 30 - .../apihandlerinfra/volumebeans/ActionType.java | 76 -- .../apihandlerinfra/volumebeans/ObjectFactory.java | 115 --- .../apihandlerinfra/volumebeans/RequestInfo.java | 286 -------- .../volumebeans/RequestStatusType.java | 70 -- .../apihandlerinfra/volumebeans/VolumeInputs.java | 435 ----------- .../apihandlerinfra/volumebeans/VolumeOutputs.java | 233 ------ .../apihandlerinfra/volumebeans/VolumeRequest.java | 179 ----- .../volumebeans/VolumeRequests.java | 99 --- .../apihandlerinfra/volumebeans/package-info.java | 30 - .../apihandlerinfra/NetworkInfoHandlerTest.java | 65 -- .../apihandlerinfra/NetworkRequestHandlerTest.java | 333 --------- .../apihandlerinfra/NetworkTypesHandlerTest.java | 73 -- .../VfModuleModelNamesHandlerTest.java | 74 -- .../mso/apihandlerinfra/VnfInfoHandlerTest.java | 54 -- .../apihandlerinfra/VnfMsoInfraRequestTest.java | 59 -- .../mso/apihandlerinfra/VnfRequestHandlerTest.java | 364 ---------- .../mso/apihandlerinfra/VnfTypesHandlerTest.java | 75 -- .../mso/apihandlerinfra/VolumeInfoHandlerTest.java | 135 ---- .../apihandlerinfra/VolumeRequestHandlerTest.java | 212 ------ .../networkbeans/NetworkOutputsTest.java | 50 -- .../volumebeans/ObjectFactoryTest.java | 38 - .../volumebeans/RequestInfoTest.java | 50 -- .../volumebeans/VolumeInputsTest.java | 58 -- .../volumebeans/VolumeOutputsTest.java | 44 -- .../volumebeans/VolumeRequestTest.java | 44 -- .../volumebeans/VolumeRequestsTest.java | 32 - .../mso/requestsdb/adapter/package-info.java | 26 - 52 files changed, 48 insertions(+), 10634 deletions(-) delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputsTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactoryTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfoTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputsTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputsTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestTest.java delete mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestsTest.java delete mode 100644 mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java (limited to 'mso-api-handlers') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java index 50716d83ae..477a7e46b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java @@ -1,56 +1,48 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -public class Constants { - - private Constants() { - } - - public static final String REQUEST_ID_PATH = "/{request-id}"; - - public static final String STATUS_SUCCESS = "SUCCESS"; - - public static final String MODIFIED_BY_APIHANDLER = "APIH"; - - public static final long PROGRESS_REQUEST_COMPLETED = 100L; - public static final long PROGRESS_REQUEST_RECEIVED = 0L; - public static final long PROGRESS_REQUEST_IN_PROGRESS = 20L; - - public static final String VNF_TYPE_WILDCARD = "*"; - - public static final String VOLUME_GROUP_COMPONENT_TYPE = "VOLUME_GROUP"; - - public static final String VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$"; - - public static final String A_LA_CARTE = "aLaCarte"; - - public static final String VNF_TYPES_PATH = "/{version: v1|v2|v3}/vnf-types"; - public static final String NETWORK_TYPES_PATH = "/{version: v1|v2|v3}/network-types"; - public static final String VF_MODULE_MODEL_NAMES_PATH = "/{version: v2|v3}/vf-module-model-names"; - - public static final String SCHEMA_VERSION_V1 = "v1"; - public static final String SCHEMA_VERSION_V2 = "v2"; - public static final String SCHEMA_VERSION_V3 = "v3"; - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; -} +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.openecomp.mso.apihandlerinfra; + + +public class Constants { + + private Constants() { + } + + public static final String REQUEST_ID_PATH = "/{request-id}"; + + public static final String STATUS_SUCCESS = "SUCCESS"; + + public static final String MODIFIED_BY_APIHANDLER = "APIH"; + + public static final long PROGRESS_REQUEST_COMPLETED = 100L; + public static final long PROGRESS_REQUEST_RECEIVED = 0L; + public static final long PROGRESS_REQUEST_IN_PROGRESS = 20L; + + public static final String VNF_TYPE_WILDCARD = "*"; + + public static final String VOLUME_GROUP_COMPONENT_TYPE = "VOLUME_GROUP"; + + public static final String VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$"; + + public static final String A_LA_CARTE = "aLaCarte"; + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java deleted file mode 100644 index d9528930e5..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java +++ /dev/null @@ -1,340 +0,0 @@ - -package org.openecomp.mso.apihandlerinfra; - -/*- - * #%L - * MSO - * %% - * Copyright (C) 2016 ONAP - SO - * %% - * 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. - * #L% - */ - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.apache.http.HttpStatus; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.networkbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkOutputs; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequests; -import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; -import org.xml.sax.InputSource; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path("/{version: v1|v2|v3}/network-request") -@Api(value="/{version: v1|v2|v3}/network-request",description="API Requests for network requests") -public class NetworkInfoHandler { - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - @GET - @ApiOperation(value="Finds Network Requests",response=Response.class) - public Response queryFilters (@QueryParam("network-type") String networkType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenant-id") String tenantId, - @PathParam("version") String version) { - MsoLogger.setServiceName ("QueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - long startTime = System.currentTimeMillis (); - - msoLogger.debug ("Incoming request received for query filters with Network type " + networkType - + " - service type " - + serviceType - + " - aicNodeClli " - + aicNodeClli - + " - tenant id " - + tenantId); - Response response; - if (networkType != null) { - response = this.getRequestList ("vnfType", networkType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - @ApiOperation(value="Add a Network Outputs from requestId and version",response=Response.class) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - MsoLogger.setServiceName ("GetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with requestId=" + requestId + ", version = " + version); - long startTime = System.currentTimeMillis (); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - protected void fillNetworkRequest (NetworkRequest qr, InfraRequests ar, String version) { - NetworkInputs vi = beansObjectFactory.createNetworkInputs (); - - if (ar.getVnfId () != null) { - vi.setNetworkId (ar.getVnfId ()); - } - if (ar.getVnfName () != null) { - vi.setNetworkName (ar.getVnfName ()); - } - if (ar.getVnfType () != null) { - vi.setNetworkType (ar.getVnfType ()); - } - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - - break; - } - - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - if (ar.getProvStatus () != null) { - vi.setProvStatus (ar.getProvStatus ()); - } - qr.setNetworkInputs (vi); - - qr.setNetworkParams (ar.getVnfParams ()); - - try { - String networkoutputs = ar.getVnfOutputs (); - if (networkoutputs != null && networkoutputs.length () > 0) { - msoLogger.debug ("Read NETWORK outputs: " + networkoutputs); - NetworkOutputs networkOutput = null; - - // Now unmarshal it into network outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (networkoutputs)); - SAXSource source = new SAXSource (inputSource); - - networkOutput = jaxbUnmarshaller.unmarshal (source, NetworkOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for network outputs"); - } - - qr.setNetworkOutputs (networkOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading networkOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - MsoLogger.setLogContext (requestId, null); - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString; - - InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId, "NETWORK"); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute, - queryValue, - "NETWORK"); - - List queryResponseList = new LinkedList <> (); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateNetworkRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private NetworkRequest fillGeneric (InfraRequests ar) { - NetworkRequest qr = beansObjectFactory.createNetworkRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList <> (); - - for (InfraRequests ar : arList) { - NetworkRequest qr = fillGeneric (ar); - fillNetworkRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateNetworkRequests (List queryResponseList) { - NetworkRequests queryResponses = new NetworkRequests (); - for (NetworkRequest aQueryResponseList : queryResponseList) { - queryResponses.getNetworkRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - NetworkRequest qr = fillGeneric (ar); - fillNetworkRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java deleted file mode 100644 index 3d419926f1..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java +++ /dev/null @@ -1,622 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamResult; - -import org.hibernate.Session; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.networkbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; -import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; - -public class NetworkMsoInfraRequest { - - private String requestId; - private String requestXML; - private String requestUri; - private RequestInfo rinfo; - private NetworkInputs networkInputs; - private String networkParams; - private ActionType action; - private String errorMessage; - private String httpResponse; - private String responseBody; - private RequestStatusType status; - private long startTime; - private long progress = Constants.PROGRESS_REQUEST_RECEIVED; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static final String NOT_PROVIDED = "not provided"; - - protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); - - NetworkMsoInfraRequest (String requestId) { - this.requestId = requestId; - this.startTime = System.currentTimeMillis(); - MsoLogger.setLogContext (requestId, null); - - } - - // Parse request XML - void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { - - msoLogger.debug ("Validating the request"); - - this.requestXML = reqXML; - - NetworkRequest networkReq = null; - boolean isWrongRootElement = false; - - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (reqXML)); - SAXSource source = new SAXSource (inputSource); - - if (reqXML.contains ("network-request") && !reqXML.contains ("vnf-request")) { - networkReq = jaxbUnmarshaller.unmarshal (source, NetworkRequest.class).getValue (); - } else { - isWrongRootElement = true; - } - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - throw new ValidationException ("format for network request"); - } - - if (isWrongRootElement) { - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.DataError, "root element expected"); - throw new ValidationException ("root element expected"); - } - - if (networkReq == null) { - throw new ValidationException ("network-request"); - } - - this.rinfo = networkReq.getRequestInfo (); - - if (this.rinfo == null) { - throw new ValidationException ("request-info"); - } - - action = this.rinfo.getAction (); - if (action == null) { - throw new ValidationException ("action"); - } - - if (!InfraUtils.isActionAllowed (props, "network", version, action.value ())) { - throw new ValidationException ("action allowable for version " + version + " of network request"); - } - - this.networkInputs = networkReq.getNetworkInputs (); - if (this.networkInputs == null) { - throw new ValidationException ("network-inputs"); - } - - // Verify that the elements correspond to the version - - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null - || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException("format for v1 version of network request"); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || - this.networkInputs.getServiceInstanceId() != null) { - throw new ValidationException("format for v2 version of network request"); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { - throw new ValidationException("format for v3 version of network request"); - } - break; - } - - switch (action) { - case UPDATE: - case DELETE: - if (this.networkInputs.getNetworkId () == null) { - throw new ValidationException ("network-id"); - } - break; - default: - break; - } - - if (ActionType.CREATE.equals (action) && this.networkInputs.getNetworkName () == null) { - throw new ValidationException ("network-name"); - } - - if (this.networkInputs.getNetworkType () == null) { - throw new ValidationException ("network-type"); - } - - if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.networkInputs.getServiceId () == null) { - throw new ValidationException ("service-id "); - } - - if (this.networkInputs.getServiceType () != null && this.networkInputs.getServiceId () != null) { - throw new ValidationException ("service-type or service-id "); - } - - if (version.equals(Constants.SCHEMA_VERSION_V1) && this.networkInputs.getAicNodeClli () == null) { - throw new ValidationException ("aic-node-clli"); - } - - if ((version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) && (this.networkInputs.getAicCloudRegion () == null || this.networkInputs.getAicCloudRegion ().isEmpty())) { - throw new ValidationException ("aic-cloud-region"); - } - - if (version.equals(Constants.SCHEMA_VERSION_V3) && this.networkInputs.getServiceInstanceId () == null) { - throw new ValidationException ("service-instance-id"); - } - - if (ActionType.CREATE.equals (action)) { - if (this.networkInputs.getTenantId () == null) { - throw new ValidationException ("tenant-id"); - } - } - - - Object vpN = networkReq.getNetworkParams (); - - if (vpN != null) { - Node node = (Node) vpN; - Document doc = node.getOwnerDocument (); - this.networkParams = domToStr (doc); - } - - msoLogger.debug ("NetworkParams: " + this.networkParams); - - msoLogger.debug ("Request valid"); - - // Rebuild the request string for BPEL to include request-id - rinfo.setRequestId (this.requestId); - networkReq.setRequestInfo (rinfo); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (networkReq, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - this.requestXML = stringWriter.toString ().replace ("http://org.openecomp/mso/infra/network-request", - "http://org.openecomp/mso/infra/vnf-request"); - msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); - - } - - public void createRequestRecord (Status status) { - - long startTime = System.currentTimeMillis (); - - Session session = null; - try { - - session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - session.beginTransaction (); - - InfraActiveRequests aq = new InfraActiveRequests (); - aq.setRequestId (requestId); - - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - if (rinfo != null) { - if (rinfo.getAction () != null) { - aq.setAction (rinfo.getAction ().value ()); - aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); - } - aq.setSource (rinfo.getSource ()); - } else { - // Set up mandatory parameters - aq.setAction (NOT_PROVIDED); - aq.setRequestAction (NOT_PROVIDED); - } - - aq.setRequestBody (this.requestXML); - aq.setRequestScope (ModelType.network.name ()); - - if (networkInputs != null) { - if (networkInputs.getNetworkId () != null) { - aq.setVnfId (networkInputs.getNetworkId ()); - } - if (networkInputs.getNetworkName () != null) { - aq.setVnfName (networkInputs.getNetworkName ()); - } - if (networkInputs.getNetworkType () != null) { - aq.setVnfType (networkInputs.getNetworkType ()); - } - if (networkInputs.getServiceInstanceId () != null) { - aq.setServiceInstanceId (networkInputs.getServiceInstanceId ()); - } - if (networkInputs.getServiceType () != null) { - aq.setServiceType (networkInputs.getServiceType ()); - } - if (networkInputs.getServiceId () != null) { - aq.setServiceType (networkInputs.getServiceId ()); - } - if (networkInputs.getAicNodeClli () != null) { - aq.setAicNodeClli (networkInputs.getAicNodeClli ()); - } - if (networkInputs.getTenantId () != null) { - aq.setTenantId (networkInputs.getTenantId ()); - } - if (networkInputs.getProvStatus () != null) { - aq.setProvStatus (networkInputs.getProvStatus ()); - } - - } - aq.setStartTime (startTimeStamp); - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - aq.setRequestType ("NETWORK"); - - if (networkParams != null) { - msoLogger.debug ("Storing networkParams: " + networkParams); - aq.setVnfParams (this.networkParams); - } - - if ((status == Status.FAILED) || (status == Status.COMPLETE)) { - aq.setStatusMessage (this.errorMessage); - aq.setResponseBody (this.responseBody); - - Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - } - aq.setProgress (this.progress); - - - msoLogger.debug ("About to insert a record"); - - session.save (aq); - session.getTransaction ().commit (); - session.close (); - msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "saveRequest", null); - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in createRequestRecord", e); - msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "RequestDB", "saveRequest", null); - if (session != null) { - session.close (); - } - if (!status.equals (Status.FAILED)) { - throw e; - } - } - } - - public void updateFinalStatus (Status status) { - try { - (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId, - status.toString (), - this.errorMessage, - this.progress, - this.responseBody, - Constants.MODIFIED_BY_APIHANDLER); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage (), "", "", MsoLogger.ErrorCode.SchemaError, "Exception in updateFinalStatus"); - msoLogger.debug ("Exception: ", e); - } - } - - public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { - return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); - } - - public Response buildResponseWithError (int httpResponseCode, - String errorCode, - InfraActiveRequests inProgress, - String errorString) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - - NetworkRequest vr = beansObjectFactory.createNetworkRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - - ri.setRequestId (requestId); - ri.setRequestStatus (this.status); - ri.setAction (this.rinfo.getAction ()); - ri.setSource (this.rinfo.getSource ()); - - String errorMsg = null; - if (errorCode != null) { - // If error code is actually an XML error response from BPEL, treat it specially: - if (!Messages.errors.containsKey (errorCode)) { - if (errorCode.length () > 300) { - errorMsg = errorCode.substring (0, 299); - } else { - errorMsg = errorCode; - } - - } else { - - if (inProgress == null) { - if (errorCode.equals (ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { - errorMsg = String.format (Messages.errors.get (errorCode), "network", errorString); - } else { - errorMsg = String.format (Messages.errors.get (errorCode), errorString); - } - } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "network", - inProgress.getVnfName (), - inProgress.getRequestStatus (), - "network"); - } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "network", - inProgress.getVnfId (), - inProgress.getRequestStatus (), - inProgress.getAction (), - "network"); - } - } - - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - } - ri.setProgress ((int) this.progress); - - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - - vr.setRequestInfo (ri); - vr.setNetworkInputs (this.networkInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - // Log the failed request into the MSO Requests database - - return Response.status (httpResponseCode).entity (response).build (); - - } - - public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - NetworkRequest vr = beansObjectFactory.createNetworkRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (requestId); - - if (this.rinfo != null) { - if (this.rinfo.getAction () != null) { - ri.setAction (this.rinfo.getAction ()); - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - if (this.rinfo.getSource () != null) { - ri.setSource (this.rinfo.getSource ()); - } - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - - // Nothing more is expected for this request - - String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION - + "_service"), - exceptionMessage); - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - - ri.setProgress ((int) this.progress); - ri.setRequestStatus (RequestStatusType.FAILED); - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - - vr.setRequestInfo (ri); - vr.setNetworkInputs (this.networkInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - return Response.status (httpResponseCode).entity (response).build (); - } - - public String getRequestUri () { - return requestUri; - } - - public void setRequestUri (String requestUri) { - this.requestUri = requestUri; - } - - public NetworkInputs getNetworkInputs () { - return networkInputs; - } - - public RequestInfo getRequestInfo () { - return rinfo; - } - - public String getResponseBody () { - return responseBody; - } - - public void setResponseBody (String responseBody) { - this.responseBody = responseBody; - } - - public String getHttpResponse () { - return httpResponse; - } - - public void setHttpResponse (String httpResponse) { - this.httpResponse = httpResponse; - } - - public String getRequestId () { - return requestId; - } - - public String getRequestXML () { - return requestXML; - } - - public void setRequestXML (String requestXML) { - this.requestXML = requestXML; - } - - public RequestStatusType getStatus () { - return status; - } - - public void setStatus (RequestStatusType status) { - this.status = status; - switch (status) { - case FAILED: - case COMPLETE: - this.progress = Constants.PROGRESS_REQUEST_COMPLETED; - break; - case IN_PROGRESS: - this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; - break; - } - } - - public String getServiceType () { - if (this.networkInputs.getServiceType () != null) - return this.networkInputs.getServiceType (); - if (this.networkInputs.getServiceId () != null) - return this.networkInputs.getServiceId (); - return null; - } - - public static String domToStr (Document doc) { - if (doc == null) { - return null; - } - - try { - StringWriter sw = new StringWriter (); - StreamResult sr = new StreamResult (sw); - TransformerFactory tf = TransformerFactory.newInstance (); - Transformer t = tf.newTransformer (); - t.setOutputProperty (OutputKeys.STANDALONE, "yes"); - NodeList nl = doc.getDocumentElement ().getChildNodes (); - DOMSource source = null; - for (int x = 0; x < nl.getLength (); x++) { - Node e = nl.item (x); - if (e instanceof Element) { - source = new DOMSource (e); - break; - } - } - if (source != null) { - t.transform (source, sr); - - String s = sw.toString (); - return s; - } - - return null; - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); - } - return null; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java deleted file mode 100644 index 6a770202fa..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java +++ /dev/null @@ -1,670 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.networkbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkOutputs; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequests; -import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; - -@Path("/{version: v1|v2|v3}/network-request") -public class NetworkRequestHandler { - - @Context - private UriInfo uriInfo; - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - - private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); - - private static final String NOT_FOUND = "Application Not StartedApplication not started, properties file missing or invalid or Database Connection failed"; - - private static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) - .entity (NOT_FOUND) - .build (); - - private RequestsDatabase requestDB = RequestsDatabase.getInstance(); - - @GET - public Response queryFilters (@QueryParam("network-type") String networkType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenant-id") String tenantId, - @PathParam("version") String version) { - MsoLogger.setServiceName ("QueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - long startTime = System.currentTimeMillis (); - - msoLogger.debug ("Incoming request received for query filters with Network type " + networkType - + " - service type " - + serviceType - + " - aicNodeClli " - + aicNodeClli - + " - tenant id " - + tenantId); - Response response; - if (networkType != null) { - response = this.getRequestList ("vnfType", networkType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - MsoLogger.setServiceName ("GetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with requestId=" + requestId + ", version = " + version); - long startTime = System.currentTimeMillis (); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - protected void fillNetworkRequest (NetworkRequest qr, InfraRequests ar, String version) { - NetworkInputs vi = beansObjectFactory.createNetworkInputs (); - - if (ar.getVnfId () != null) { - vi.setNetworkId (ar.getVnfId ()); - } - if (ar.getVnfName () != null) { - vi.setNetworkName (ar.getVnfName ()); - } - if (ar.getVnfType () != null) { - vi.setNetworkType (ar.getVnfType ()); - } - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - - break; - } - - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - if (ar.getProvStatus () != null) { - vi.setProvStatus (ar.getProvStatus ()); - } - qr.setNetworkInputs (vi); - - qr.setNetworkParams (ar.getVnfParams ()); - - try { - String networkoutputs = ar.getVnfOutputs (); - if (networkoutputs != null && networkoutputs.length () > 0) { - msoLogger.debug ("Read NETWORK outputs: " + networkoutputs); - NetworkOutputs networkOutput = null; - - // Now unmarshal it into network outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (networkoutputs)); - SAXSource source = new SAXSource (inputSource); - - networkOutput = jaxbUnmarshaller.unmarshal (source, NetworkOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for network outputs"); - } - - qr.setNetworkOutputs (networkOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading networkOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - MsoLogger.setLogContext (requestId, null); - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString; - - InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId, "NETWORK"); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute, - queryValue, - "NETWORK"); - - List queryResponseList = new LinkedList <> (); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateNetworkRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private NetworkRequest fillGeneric (InfraRequests ar) { - NetworkRequest qr = beansObjectFactory.createNetworkRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList <> (); - - for (InfraRequests ar : arList) { - NetworkRequest qr = fillGeneric (ar); - fillNetworkRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateNetworkRequests (List queryResponseList) { - NetworkRequests queryResponses = new NetworkRequests (); - for (NetworkRequest aQueryResponseList : queryResponseList) { - queryResponses.getNetworkRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - NetworkRequest qr = fillGeneric (ar); - fillNetworkRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } - - @POST - @Path("/") - @Produces(MediaType.APPLICATION_XML) - public Response manageNetworkRequest (String reqXML, @PathParam("version") String version) { - MsoLogger.setServiceName ("NetworkRequest"); - if ("v1".equals(version)) { - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } else if ("v2".equals(version)) { - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } else if ("v3".equals(version)) { - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } else { - long startTime = System.currentTimeMillis (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); - return Response.status(HttpStatus.SC_NOT_FOUND).build(); - } - } - - private Response manageNetworkRequestImpl (String reqXML, String version) { - - props = MsoPropertiesUtils.loadMsoProperties (); - - long startTime = System.currentTimeMillis (); - if (MsoPropertiesUtils.getNoPropertiesState()) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Application not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - uriInfo.getRequestUri (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - NetworkMsoInfraRequest msoRequest = new NetworkMsoInfraRequest (requestUUID.toString ()); - MsoLogger.setLogContext (msoRequest.getRequestId (), null); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The input Request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - - msoLogger.debug ("Incoming Request: " + reqXML); - - msoRequest.setRequestUri (requestUri); - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - if (msoRequest.getRequestInfo () - .getAction () == org.openecomp.mso.apihandlerinfra.networkbeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same network Name - msoLogger.debug ("Checking for a duplicate with the same network-name"); - InfraActiveRequests dup = null; - try { - - dup = requestDB.checkDuplicateByVnfName (msoRequest.getNetworkInputs ().getNetworkName (), - msoRequest.getRequestInfo ().getAction ().value (), - "NETWORK"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "network-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - "CREATE on the same Network Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same Network Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same Network Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same networkId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same network-id"); - try { - dup = requestDB.checkDuplicateByVnfId (msoRequest.getNetworkInputs ().getNetworkId (), - msoRequest.getRequestInfo ().getAction ().value (), - "NETWORK"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "network-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the same network-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the same network-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same Network Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same Network Id already in progress"); - - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same Network Id already in progress."); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - // Query MSO Catalog DB - try (CatalogDatabase db = CatalogDatabase.getInstance()) { - - Recipe recipe = null; - - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getNetworkRecipe (msoRequest.getNetworkInputs ().getNetworkType (), - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - - } - if (recipe == null) { - recipe = db.getNetworkRecipe (msoRequest.getNetworkInputs ().getNetworkType (), - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "VNF Recipe attribute not found"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - db.close (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - - db.close (); - - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.DataError, "Exception while creating record in DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.DataError, "bpelResponse is null"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is null"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.IN_PROGRESS); - requestDB.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is with status Failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java deleted file mode 100644 index 43f2d2afbb..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringWriter; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import org.apache.http.HttpStatus; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkType; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkTypes; -import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path(Constants.NETWORK_TYPES_PATH) -@Api(value="/{version: v1|v2|v3}/network-types",description="API Requests to find Network Types") -public class NetworkTypesHandler { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - @GET - @ApiOperation(value="Finds Network Types",response=Response.class) - public Response getNetworkTypes (@PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("getNetworkTypes"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getNetworkTypes"); - - List networkResources = null; - try (CatalogDatabase db = CatalogDatabase.getInstance()){ - networkResources = db.getAllNetworkResources (); - } catch (Exception e) { - msoLogger.debug ("No connection to catalog DB", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "no connection to catalog DB"); - msoLogger.debug ("End of the transaction, the final response is: " + e.toString ()); - return Response.status (HttpStatus.SC_NOT_FOUND).entity (e.toString ()).build (); - } - - if (networkResources == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "NetworkType not found"); - msoLogger.debug ("End of the transaction. NetworkType not found the final response status: " + HttpStatus.SC_NOT_FOUND); - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - - ObjectFactory beansObjectFactory = new ObjectFactory (); - NetworkTypes networkTypes = beansObjectFactory.createNetworkTypes (); - for (NetworkResource networkResource : networkResources) { - NetworkType networkType = beansObjectFactory.createNetworkType(); - NetworkResource vr = networkResource; - networkType.setType(vr.getModelName()); - networkType.setDescription(vr.getDescription()); - networkType.setId(String.valueOf(vr.getModelUUID())); - networkTypes.getNetworkType().add(networkType); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (NetworkTypes.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (networkTypes, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + response); - return Response.status (HttpStatus.SC_OK).entity (response).build (); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java deleted file mode 100644 index df51a8f96a..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringWriter; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import org.apache.http.HttpStatus; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelName; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelNames; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.logger.MsoLogger; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path(Constants.VF_MODULE_MODEL_NAMES_PATH) -@Api(value="/{version: v2|v3}/vf-module-model-names",description="API Requests to find Vf Module model names") -public class VfModuleModelNamesHandler { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static final String LOG_SERVICE_NAME = "InfrastructurePortal:MSO-APIH."; - - @GET - @ApiOperation(value="Finds Vf Module Model Names",response=Response.class) - public Response getVfModuleModelNames (@PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - String methodName = "getVfModuleModelNames"; - MsoLogger.setServiceName (LOG_SERVICE_NAME + methodName); - msoLogger.debug ("Incoming request received for vfModuleModelNames"); - List vfModules = null; - try (CatalogDatabase db = CatalogDatabase.getInstance()){ - vfModules = db.getAllVfModules (); - } catch (Exception e) { - msoLogger.debug ("No connection to catalog DB", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "no connection to catalog DB"); - msoLogger.debug ("End of the transaction, the final response is: " + e.toString ()); - return Response.status (HttpStatus.SC_NOT_FOUND).entity (e.toString ()).build (); - } - - if (vfModules == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "VfModule not found"); - msoLogger.debug ("End of the transaction. VfModuleModelName not found the final response status: " + HttpStatus.SC_NOT_FOUND); - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - - ObjectFactory beansObjectFactory = new ObjectFactory (); - VfModuleModelNames vfModuleModelNames = beansObjectFactory.createVfModuleModelNames (); - for (VfModule vfModule : vfModules) { - VfModuleModelName vfModuleModelName = beansObjectFactory.createVfModuleModelName(); - VfModule vm = vfModule; - vfModuleModelName.setModelName(vm.getModelName()); - vfModuleModelName.setModelVersion(vm.getVersion()); - vfModuleModelName.setModelInvariantUuid(vm.getModelInvariantUuid()); - vfModuleModelName.setIsBase(vm.isBase()); - vfModuleModelName.setDescription(vm.getDescription()); - vfModuleModelName.setId(String.valueOf(vm.getModelUUID())); - vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion()); - vfModuleModelNames.getVfModuleModelName().add(vfModuleModelName); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VfModuleModelNames.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (vfModuleModelNames, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + response); - return Response.status (HttpStatus.SC_OK).entity (response).build (); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java deleted file mode 100644 index 2fe0103098..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java +++ /dev/null @@ -1,377 +0,0 @@ -package org.openecomp.mso.apihandlerinfra; - -/*- - * #%L - * MSO - * %% - * Copyright (C) 2016 ONAP - SO - * %% - * 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. - * #L% - */ - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.apache.http.HttpStatus; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfOutputs; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequests; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; -import org.xml.sax.InputSource; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path("/{version: v1|v2|v3}/vnf-request") -@Api(value="/{version: v1|v2|v3}/vnf-request",description="API Requests of vnfRequest") -public class VnfInfoHandler { - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - - @GET - @ApiOperation(value="Finds Volume Requests",response=Response.class) - public Response queryFilters (@QueryParam("vnf-type") String vnfType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenant-id") String tenantId, - @QueryParam("volume-group-id") String volumeGroupId, - @QueryParam("volume-group-name") String volumeGroupName, - @QueryParam("vnf-name") String vnfName, - @PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VNFQueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType - + " service-type:" + serviceType - + " aic-node-clli:" + aicNodeClli - + " tenant-id:" + tenantId - + " volume-group-id:" + volumeGroupId - + " volume-group-name:" + volumeGroupName - + " vnf-name: " + vnfName); - Response response; - if (vnfType != null) { - response = this.getRequestList ("vnfType", vnfType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, vnfName, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - @ApiOperation(value="Add a Vnf Outputs from requestId and version",response=Response.class) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VNFGetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId + ", version = " + version); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - protected String getRequestType () { - return VnfRequestType.VNF.toString (); - } - - protected void fillVnfRequest (VnfRequest qr, InfraRequests ar, String version) { - VnfInputs vi = beansObjectFactory.createVnfInputs (); - - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - if (ar.getVnfName () != null) { - vi.setVnfName (ar.getVnfName ()); - } - if (ar.getVnfType () != null) { - vi.setVnfType (ar.getVnfType ()); - } - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - if (ar.getProvStatus () != null) { - vi.setProvStatus (ar.getProvStatus ()); - } - if (ar.getVolumeGroupName () != null) { - vi.setVolumeGroupName (ar.getVolumeGroupName ()); - } - if (ar.getVolumeGroupId () != null) { - vi.setVolumeGroupId (ar.getVolumeGroupId ()); - } - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleName() != null) { - vi.setVfModuleName(ar.getVfModuleName()); - } - if (ar.getVfModuleId() != null) { - vi.setVfModuleId(ar.getVfModuleId()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleName() != null) { - vi.setVfModuleName(ar.getVfModuleName()); - } - if (ar.getVfModuleId() != null) { - vi.setVfModuleId(ar.getVfModuleId()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - break; - } - qr.setVnfInputs (vi); - - qr.setVnfParams (ar.getVnfParams ()); - - try { - String vnfoutputs = ar.getVnfOutputs (); - if (vnfoutputs != null && vnfoutputs.length () > 0) { - msoLogger.debug ("Read VNF outputs: " + vnfoutputs); - VnfOutputs vnfOutput = null; - - // Now unmarshal it into vnf outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (vnfoutputs)); - SAXSource source = new SAXSource (inputSource); - - vnfOutput = jaxbUnmarshaller.unmarshal (source, VnfOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for vnf outputs"); - } - - qr.setVnfOutputs (vnfOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading vnfOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String vnfName, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - if (volumeGroupId != null) { - return this.getRequestList ("volumeGroupId", volumeGroupId, version); - } - if (volumeGroupName != null) { - return this.getRequestList ("volumeGroupName", volumeGroupName, version); - } - if (vnfName != null) { - return this.getRequestList ("vnfName", vnfName, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString; - - InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId, getRequestType ()); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute, - queryValue, - getRequestType ()); - - List queryResponseList = new LinkedList <> (); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateVnfRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private VnfRequest fillGeneric (InfraRequests ar) { - VnfRequest qr = beansObjectFactory.createVnfRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList <> (); - - for (InfraRequests ar : arList) { - VnfRequest qr = fillGeneric (ar); - fillVnfRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateVnfRequests (List queryResponseList) { - VnfRequests queryResponses = new VnfRequests (); - for (VnfRequest aQueryResponseList : queryResponseList) { - queryResponses.getVnfRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - VnfRequest qr = fillGeneric (ar); - fillVnfRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java deleted file mode 100644 index 1f3008aa1a..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java +++ /dev/null @@ -1,717 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamResult; - -import org.hibernate.Session; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; - -public class VnfMsoInfraRequest { - - private String requestId; - private String requestXML; - private String requestUri; - private VnfRequest vnfReq; - private RequestInfo rinfo; - private VnfInputs vnfInputs; - private String vnfParams; - private ActionType action; - private String errorMessage; - private String httpResponse; - private String responseBody; - private RequestStatusType status; - private long startTime; - private long progress = Constants.PROGRESS_REQUEST_RECEIVED; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static final String NOT_PROVIDED = "not provided"; - - protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); - - VnfMsoInfraRequest (String requestId) { - this.requestId = requestId; - this.startTime = System.currentTimeMillis(); - MsoLogger.setLogContext (requestId, null); - - } - - // Parse request XML - void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { - - msoLogger.debug ("Validating the request"); - - this.requestXML = reqXML; - - VnfRequest vnfReq = null; - boolean isWrongRootElement = false; - - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (reqXML)); - SAXSource source = new SAXSource (inputSource); - - if (reqXML.contains ("vnf-request") && !reqXML.contains ("network-request")) { - vnfReq = jaxbUnmarshaller.unmarshal (source, VnfRequest.class).getValue (); - } else { - isWrongRootElement = true; - } - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in format for vnf request ", e); - throw new ValidationException ("format for vnf request"); - } - - if (isWrongRootElement) { - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.DataError, "root element is not correct"); - throw new ValidationException ("root element expected"); - } - - if (vnfReq == null) { - throw new ValidationException ("vnf-request"); - } - this.vnfReq = vnfReq; - - this.rinfo = vnfReq.getRequestInfo (); - - if (this.rinfo == null) { - throw new ValidationException ("request-info"); - } - if (this.rinfo.getRequestId () != null) { - msoLogger.info (MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, this.rinfo.getRequestId ()); - } - - action = this.rinfo.getAction (); - if (action == null) { - throw new ValidationException ("action"); - } - - this.vnfInputs = vnfReq.getVnfInputs (); - if (this.vnfInputs == null) { - throw new ValidationException ("vnf-inputs"); - } - - // Verify that BPMN-specific elements are not in the APIH incoming request - if (this.vnfInputs.getPersonaModelId () != null || this.vnfInputs.getPersonaModelVersion () != null || - this.vnfInputs.getIsBaseVfModule () != null || this.vnfInputs.getVnfPersonaModelId () != null || - this.vnfInputs.getVnfPersonaModelVersion () != null) { - throw new ValidationException ("format for vnf request"); - } - // Verify that the elements correspond to the version - - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (this.vnfInputs.getVfModuleName() != null || this.vnfInputs.getVfModuleId() != null || - this.vnfInputs.getVfModuleModelName() != null || this.vnfInputs.getAsdcServiceModelVersion() != null - || - this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || - this.vnfInputs.getServiceInstanceId() != null) { - throw new ValidationException("format for v1 version of vnf request"); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null - || this.vnfInputs.getServiceInstanceId() != null) { - throw new ValidationException("format for v2 version of vnf request"); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { - throw new ValidationException("format for v3 version of vnf request"); - } - break; - } - - - if (!InfraUtils.isActionAllowed (props, "vnf", version, action.value ())) { - throw new ValidationException ("action allowable for version " + version + " of vnf request"); - } - - if ((ActionType.UPDATE.equals(action) || ActionType.DELETE.equals(action)) && this.vnfInputs.getVnfId () == null) { - throw new ValidationException("vnf-id"); - } - - if ((ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleId () == null) { - throw new ValidationException ("vf-module-id"); - } - - if (ActionType.CREATE.equals (action) && this.vnfInputs.getVnfName () == null) { - throw new ValidationException ("vnf-name"); - } - - if (ActionType.CREATE_VF_MODULE.equals (action)) { - if (this.vnfInputs.getVfModuleName () == null) { - throw new ValidationException ("vf-module-name"); - } - if (!InfraUtils.isValidHeatName(this.vnfInputs.getVfModuleName ())) { - throw new ValidationException ("vf-module-name: no value meeting heat stack name syntax requirements"); - } - } - - if (this.vnfInputs.getVnfType () == null) { - throw new ValidationException ("vnf-type"); - } - - if ((ActionType.CREATE_VF_MODULE.equals (action) || ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleModelName () == null) { - throw new ValidationException ("vf-module-model-name"); - } - - if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getServiceId () == null) { - throw new ValidationException ("service-id "); - } - - if (this.vnfInputs.getServiceType () != null && this.vnfInputs.getServiceId () != null) { - throw new ValidationException ("service-type or service-id "); - } - - if (version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getAicNodeClli () == null) { - throw new ValidationException ("aic-node-clli"); - } - - if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.vnfInputs.getAicCloudRegion () == null || this.vnfInputs.getAicCloudRegion ().isEmpty())) { - throw new ValidationException ("aic-cloud-region"); - } - - if (version.equals(Constants.SCHEMA_VERSION_V3) && this.vnfInputs.getServiceInstanceId () == null) { - throw new ValidationException ("service-instance-id"); - } - - - if (this.vnfInputs.getTenantId () == null) { - throw new ValidationException ("tenant-id"); - } - - Object vp = vnfReq.getVnfParams (); - - if (vp != null) { - msoLogger.debug ("This object is not null"); - - Node node = (Node) vp; - Document doc = node.getOwnerDocument (); - this.vnfParams = domToStr (doc); - } - - msoLogger.debug ("VNFParams: " + this.vnfParams); - - msoLogger.debug ("Request valid"); - - // Rebuild the request string for BPEL to include request-id - rinfo.setRequestId (this.requestId); - this.vnfReq.setRequestInfo (rinfo); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (this.vnfReq, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - this.requestXML = stringWriter.toString (); - msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); - - } - - public void createRequestRecord (Status status) { - - Session session = null; - try { - - session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - session.beginTransaction (); - - InfraActiveRequests aq = new InfraActiveRequests (); - aq.setRequestId (requestId); - aq.setClientRequestId(rinfo.getRequestId()); - - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - if (rinfo != null) { - if (rinfo.getAction () != null) { - aq.setAction (rinfo.getAction ().value ()); - aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); - } - aq.setSource (rinfo.getSource ()); - } else { - // Set up mandatory parameters - aq.setAction (NOT_PROVIDED); - aq.setRequestAction (NOT_PROVIDED); - } - - aq.setRequestBody (this.requestXML); - aq.setRequestScope (""); - - if (vnfInputs != null) { - if (vnfInputs.getVnfId () != null) { - aq.setVnfId (vnfInputs.getVnfId ()); - } - if (vnfInputs.getVnfName () != null) { - aq.setVnfName (vnfInputs.getVnfName ()); - } - if (vnfInputs.getVnfType () != null) { - aq.setVnfType (vnfInputs.getVnfType ()); - } - if (vnfInputs.getServiceInstanceId () != null) { - aq.setServiceInstanceId (vnfInputs.getServiceInstanceId ()); - } - if (vnfInputs.getServiceType () != null) { - aq.setServiceType (vnfInputs.getServiceType ()); - } - if (vnfInputs.getServiceId () != null) { - aq.setAaiServiceId (vnfInputs.getServiceId ()); - } - if (vnfInputs.getAicNodeClli () != null) { - aq.setAicNodeClli (vnfInputs.getAicNodeClli ()); - } - if (vnfInputs.getAicCloudRegion () != null) { - aq.setAicCloudRegion (vnfInputs.getAicCloudRegion ()); - } - if (vnfInputs.getTenantId () != null) { - aq.setTenantId (vnfInputs.getTenantId ()); - } - if (vnfInputs.getProvStatus () != null) { - aq.setProvStatus (vnfInputs.getProvStatus ()); - } - if (vnfInputs.getVolumeGroupName () != null) { - aq.setVolumeGroupName (vnfInputs.getVolumeGroupName ()); - } - if (vnfInputs.getVolumeGroupId () != null) { - aq.setVolumeGroupId (vnfInputs.getVolumeGroupId ()); - } - if (vnfInputs.getVfModuleId () != null) { - aq.setVfModuleId (vnfInputs.getVfModuleId ()); - } - if (vnfInputs.getVfModuleName () != null) { - aq.setVfModuleName (vnfInputs.getVfModuleName ()); - } - if (vnfInputs.getVfModuleModelName () != null) { - aq.setVfModuleModelName (vnfInputs.getVfModuleModelName ()); - } - - if (vnfInputs.getVfModuleName () != null || vnfInputs.getVfModuleId () != null) { - aq.setRequestScope (ModelType.vfModule.name ()); - } - else { - aq.setRequestScope (ModelType.vnf.name ()); - } - - - } - - aq.setStartTime (startTimeStamp); - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - aq.setRequestType ("VNF"); - - if (vnfParams != null) { - msoLogger.debug ("Storing vnfParams: " + vnfParams); - aq.setVnfParams (this.vnfParams); - } - - if ((status == Status.FAILED) || (status == Status.COMPLETE)) { - aq.setStatusMessage (this.errorMessage); - aq.setResponseBody (this.responseBody); - - Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - } - - aq.setProgress (this.progress); - - - msoLogger.debug ("About to insert a record"); - - session.save (aq); - session.getTransaction ().commit (); - session.close (); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in createRequestRecord", e); - if (session != null) { - session.close (); - } - if (!status.equals (Status.FAILED)) { - throw e; - } - } - } - - public void updateFinalStatus (Status status) { - int result = 0; - try { - result = (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId, - status.toString (), - this.errorMessage, - this.progress, - this.responseBody, - Constants.MODIFIED_BY_APIHANDLER); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in updateFinalStatus"); - msoLogger.debug ("Exception: ", e); - } - } - - public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { - return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); - } - - public Response buildResponseWithError (int httpResponseCode, - String errorCode, - InfraActiveRequests inProgress, - String errorString) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - - VnfRequest vr = beansObjectFactory.createVnfRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - - ri.setRequestId (requestId); - ri.setRequestStatus (this.status); - ri.setAction (this.rinfo.getAction ()); - ri.setSource (this.rinfo.getSource ()); - - String errorMsg = null; - if (errorCode != null) { - // If error code is actually an XML error response from BPEL, treat it specially: - if (!Messages.errors.containsKey (errorCode)) { - if (errorCode.length () > 300) { - errorMsg = errorCode.substring (0, 299); - } else { - errorMsg = errorCode; - } - - } else { - - if (inProgress == null) { - if (errorCode.equals (ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { - errorMsg = String.format (Messages.errors.get (errorCode), "vnf", errorString); - } else { - errorMsg = String.format (Messages.errors.get (errorCode), errorString); - } - } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "vnf", - inProgress.getVnfName (), - inProgress.getRequestStatus (), - "vnf"); - } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "vnf", - inProgress.getVnfId (), - inProgress.getRequestStatus (), - inProgress.getAction (), - "vnf"); - } - } - - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - } - ri.setProgress ((int) this.progress); - - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - - if (this.progress == Constants.PROGRESS_REQUEST_COMPLETED) { - ri.setEndTime(startTimeString); - } - - vr.setRequestInfo (ri); - - this.vnfInputs.setIsBaseVfModule(null); - this.vnfInputs.setPersonaModelId(null); - this.vnfInputs.setPersonaModelVersion(null); - this.vnfInputs.setVnfPersonaModelId(null); - this.vnfInputs.setVnfPersonaModelVersion(null); - - vr.setVnfInputs (this.vnfInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - - // Log the failed request into the MSO Requests database - - return Response.status (httpResponseCode).entity (response).build (); - - } - - public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - VnfRequest vr = beansObjectFactory.createVnfRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (requestId); - - if (this.rinfo != null) { - if (this.rinfo.getAction () != null) { - ri.setAction (this.rinfo.getAction ()); - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - if (this.rinfo.getSource () != null) { - ri.setSource (this.rinfo.getSource ()); - } - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - - // Nothing more is expected for this request - - String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION - + "_service"), - exceptionMessage); - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - - ri.setProgress ((int) this.progress); - ri.setRequestStatus (RequestStatusType.FAILED); - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - ri.setEndTime(startTimeString); - - vr.setRequestInfo (ri); - - vr.setVnfInputs (this.vnfInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - return Response.status (httpResponseCode).entity (response).build (); - } - - public String getRequestUri () { - return requestUri; - } - - public void setRequestUri (String requestUri) { - this.requestUri = requestUri; - } - - public VnfInputs getVnfInputs () { - return vnfInputs; - } - - public RequestInfo getRequestInfo () { - return rinfo; - } - - public String getResponseBody () { - return responseBody; - } - - public void setResponseBody (String responseBody) { - this.responseBody = responseBody; - } - - public String getHttpResponse () { - return httpResponse; - } - - public void setHttpResponse (String httpResponse) { - this.httpResponse = httpResponse; - } - - public String getRequestId () { - return requestId; - } - - public String getRequestXML () { - return requestXML; - } - - public void setRequestXML (String requestXML) { - this.requestXML = requestXML; - } - - public RequestStatusType getStatus () { - return status; - } - - public String getServiceType () { - if (this.vnfInputs.getServiceType () != null) - return this.vnfInputs.getServiceType (); - if (this.vnfInputs.getServiceId () != null) - return this.vnfInputs.getServiceId (); - return null; - } - - public void setStatus (RequestStatusType status) { - this.status = status; - switch (status) { - case FAILED: - case COMPLETE: - this.progress = Constants.PROGRESS_REQUEST_COMPLETED; - break; - case IN_PROGRESS: - this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; - break; - } - } - - public static String domToStr (Document doc) { - if (doc == null) { - return null; - } - - try { - StringWriter sw = new StringWriter (); - StreamResult sr = new StreamResult (sw); - TransformerFactory tf = TransformerFactory.newInstance (); - Transformer t = tf.newTransformer (); - t.setOutputProperty (OutputKeys.STANDALONE, "yes"); - NodeList nl = doc.getDocumentElement ().getChildNodes (); - DOMSource source = null; - for (int x = 0; x < nl.getLength (); x++) { - Node e = nl.item (x); - if (e instanceof Element) { - source = new DOMSource (e); - break; - } - } - if (source != null) { - t.transform (source, sr); - - String s = sw.toString (); - return s; - } - - return null; - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); - } - return null; - } - - public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule, - String vnfPersonaModelId, String vnfPersonaModelVersion) { - vnfInputs.setPersonaModelId(personaModelId); - vnfInputs.setPersonaModelVersion(personaModelVersion); - vnfInputs.setIsBaseVfModule(isBaseVfModule); - vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); - vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); - - this.vnfReq.setVnfInputs(vnfInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (this.vnfReq, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - this.requestXML = stringWriter.toString (); - msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); - - - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java deleted file mode 100644 index 098ed31b58..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java +++ /dev/null @@ -1,807 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; - -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfOutputs; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequests; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; - -@Path("/{version: v1|v2|v3}/vnf-request") -public class VnfRequestHandler { - - @Context - private UriInfo uriInfo; - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - - private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); - - private static final String NOT_FOUND = "Application Not StartedApplication not started, properties file missing or invalid or Database Connection failed"; - - private static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) - .entity (NOT_FOUND) - .build (); - private RequestsDatabase requestDB = RequestsDatabase.getInstance(); - - @GET - public Response queryFilters (@QueryParam("vnf-type") String vnfType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenant-id") String tenantId, - @QueryParam("volume-group-id") String volumeGroupId, - @QueryParam("volume-group-name") String volumeGroupName, - @QueryParam("vnf-name") String vnfName, - @PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VNFQueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType - + " service-type:" + serviceType - + " aic-node-clli:" + aicNodeClli - + " tenant-id:" + tenantId - + " volume-group-id:" + volumeGroupId - + " volume-group-name:" + volumeGroupName - + " vnf-name: " + vnfName); - Response response = null; - if (vnfType != null) { - response = this.getRequestList ("vnfType", vnfType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, vnfName, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VNFGetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId + ", version = " + version); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - protected String getRequestType () { - return VnfRequestType.VNF.toString (); - } - - protected void fillVnfRequest (VnfRequest qr, InfraRequests ar, String version) { - VnfInputs vi = beansObjectFactory.createVnfInputs (); - - if (ar.getVnfId () != null) { - vi.setVnfId (ar.getVnfId ()); - } - if (ar.getVnfName () != null) { - vi.setVnfName (ar.getVnfName ()); - } - if (ar.getVnfType () != null) { - vi.setVnfType (ar.getVnfType ()); - } - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - if (ar.getProvStatus () != null) { - vi.setProvStatus (ar.getProvStatus ()); - } - if (ar.getVolumeGroupName () != null) { - vi.setVolumeGroupName (ar.getVolumeGroupName ()); - } - if (ar.getVolumeGroupId () != null) { - vi.setVolumeGroupId (ar.getVolumeGroupId ()); - } - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleName() != null) { - vi.setVfModuleName(ar.getVfModuleName()); - } - if (ar.getVfModuleId() != null) { - vi.setVfModuleId(ar.getVfModuleId()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleName() != null) { - vi.setVfModuleName(ar.getVfModuleName()); - } - if (ar.getVfModuleId() != null) { - vi.setVfModuleId(ar.getVfModuleId()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - break; - } - qr.setVnfInputs (vi); - - qr.setVnfParams (ar.getVnfParams ()); - - try { - String vnfoutputs = ar.getVnfOutputs (); - if (vnfoutputs != null && vnfoutputs.length () > 0) { - msoLogger.debug ("Read VNF outputs: " + vnfoutputs); - VnfOutputs vnfOutput = null; - - // Now unmarshal it into vnf outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (vnfoutputs)); - SAXSource source = new SAXSource (inputSource); - - vnfOutput = jaxbUnmarshaller.unmarshal (source, VnfOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for vnf outputs"); - } - - qr.setVnfOutputs (vnfOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading vnfOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String vnfName, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - if (volumeGroupId != null) { - return this.getRequestList ("volumeGroupId", volumeGroupId, version); - } - if (volumeGroupName != null) { - return this.getRequestList ("volumeGroupName", volumeGroupName, version); - } - if (vnfName != null) { - return this.getRequestList ("vnfName", vnfName, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString = null; - - InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId, getRequestType ()); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute, - queryValue, - getRequestType ()); - - List queryResponseList = new LinkedList<>(); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateVnfRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private VnfRequest fillGeneric (InfraRequests ar) { - VnfRequest qr = beansObjectFactory.createVnfRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList<>(); - - for (InfraRequests ar : arList) { - VnfRequest qr = fillGeneric (ar); - fillVnfRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateVnfRequests (List queryResponseList) { - VnfRequests queryResponses = new VnfRequests (); - for (VnfRequest aQueryResponseList : queryResponseList) { - queryResponses.getVnfRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - VnfRequest qr = fillGeneric (ar); - fillVnfRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } - - @POST - @Path("/") - @Produces(MediaType.APPLICATION_XML) - public Response manageVnfRequest (String reqXML, @PathParam("version") String version) { - MsoLogger.setServiceName ("VnfRequest"); - if ("v1".equals(version)) { - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } else if ("v2".equals(version)) { - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } else if ("v3".equals(version)) { - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } else { - long startTime = System.currentTimeMillis (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); - return Response.status(HttpStatus.SC_NOT_FOUND).build(); - } - } - - private Response manageVnfRequestImpl (String reqXML, String version) { - String methodName = "VnfRequest"; - props = MsoPropertiesUtils.loadMsoProperties (); - long startTime = System.currentTimeMillis (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - VnfMsoInfraRequest msoRequest = new VnfMsoInfraRequest (requestUUID.toString ()); - MsoLogger.setLogContext (msoRequest.getRequestId (), null); - - if (MsoPropertiesUtils.getNoPropertiesState()) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Exiting the transaction: Infra API Handler not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - - uriInfo.getRequestUri (); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The content of the request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - msoLogger.debug ("Incoming request received for pose VNFRequest:" + reqXML); - - msoRequest.setRequestUri (requestUri); - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.SchemaError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - if (msoRequest.getRequestInfo ().getAction () == org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same vnfName - msoLogger.debug ("Checking for a duplicate with the same vnf-name"); - InfraActiveRequests dup = null; - try { - dup = requestDB.checkDuplicateByVnfName (msoRequest.getVnfInputs ().getVnfName (), - msoRequest.getRequestInfo ().getAction ().value (), - "VNF"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "vnf-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, "CREATE on the same VNF Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same VNF Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same VNF Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same vnfId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same vnf-id"); - try { - dup = requestDB.checkDuplicateByVnfId (msoRequest.getVnfInputs ().getVnfId (), - msoRequest.getRequestInfo ().getAction ().value (), - "VNF"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "vnf-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the same vnf-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the same vnf-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same VNF Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same VNF Id already in progress"); - - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same VNF Id already in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - // Query MSO Catalog DB - try (CatalogDatabase db = CatalogDatabase.getInstance()){ - - Recipe recipe = null; - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - // First get recipe for the service type given - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - } - // If no recipe for the service type or no service type was given, look for recipe without service type - if (recipe == null) { - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - } - if (version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) { - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE: - case UPDATE: - case DELETE: - // First get recipe for the vnf type given - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfRecipe (Constants.VNF_TYPE_WILDCARD, - msoRequest.getRequestInfo ().getAction ().value ()); - } - break; - case CREATE_VF_MODULE: - case UPDATE_VF_MODULE: - case DELETE_VF_MODULE: - // First get recipe for the vnf type/vf module model name through vf module id query - recipe = db.getVfModuleRecipe (msoRequest.getVnfInputs ().getVnfType (), msoRequest.getVnfInputs ().getVfModuleModelName (), - msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfRecipeByVfModuleId (msoRequest.getVnfInputs ().getVfModuleId (), - Constants.VNF_TYPE_WILDCARD, msoRequest.getRequestInfo ().getAction ().value ()); - } - // First get recipe for the vnf type given - //recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - // msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - //if (recipe == null) { - // recipe = db.getVnfRecipe (Constants.VNF_TYPE_WILDCARD, - // msoRequest.getRequestInfo ().getAction ().value ()); - // - //} - break; - default: - break; - } - - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - db.close (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - - // Retrieve additional info for Vf Modules from Catalog DB to send it to BPMN - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE_VF_MODULE: - case UPDATE_VF_MODULE: - String personaModelId = ""; - String personaModelVersion = ""; - String vnfPersonaModelId = ""; - String vnfPersonaModelVersion = ""; - Boolean isBase = false; - String asdcServiceModelVersion = msoRequest.getVnfInputs ().getAsdcServiceModelVersion (); - - // Get VF Module-specific persona info and base module indicator - VfModule vfm = null; - String vfModuleType = msoRequest.getVnfInputs ().getVnfType () + "::" + msoRequest.getVnfInputs ().getVfModuleModelName (); - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - vfm = db.getVfModuleType (vfModuleType, asdcServiceModelVersion); - } - else { - vfm = db.getVfModuleType (vfModuleType); - } - if (vfm != null) { - if (vfm.getIsBase() == 1) { - isBase = true; - } - personaModelId = vfm.getModelInvariantUuid(); - personaModelVersion = vfm.getModelVersion(); - msoLogger.debug("Setting personaModelId to " + personaModelId + - ", personaModelVersion to " + personaModelVersion); - } - // Get VNF-specific persona info - VnfResource vnfr = null; - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - vnfr = db.getVnfResource (msoRequest.getVnfInputs ().getVnfType (), asdcServiceModelVersion); - } - else { - vnfr = db.getVnfResource (msoRequest.getVnfInputs ().getVnfType ()); - } - if (vnfr != null) { - vnfPersonaModelId = vnfr.getModelInvariantUuid (); - vnfPersonaModelVersion = vnfr.getModelVersion(); - msoLogger.debug("Setting vnfPersonaModelId to " + vnfPersonaModelId + - ", vnfPersonaModelVersion to " + vnfPersonaModelVersion); - } - - msoRequest.addBPMNSpecificInputs(personaModelId, personaModelVersion, isBase, - vnfPersonaModelId, vnfPersonaModelVersion); - - break; - default: - break; - } - - db.close (); - - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - msoLogger.debug("Request going to BPEL: " + msoRequest.getRequestXML ()); - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post(msoRequest.getRequestXML(), - requestId, - Integer.toString(recipe.getRecipeTimeout()), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Null response from BPEL"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS); - requestDB.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java deleted file mode 100644 index 7f1f6b531c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -/* - * Enum for VNF Request Type values -*/ -public enum VnfRequestType { - VNF, - NETWORK -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java deleted file mode 100644 index 3d87d131b3..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfTypes; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; -import org.apache.http.HttpStatus; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import java.io.StringWriter; -import java.util.List; - -@Path(Constants.VNF_TYPES_PATH) -@Api(value="/{version: v1|v2|v3}/vnf-types",description="API Requests of vnfTypes") -public class VnfTypesHandler { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - - @GET - @ApiOperation(value="Finds Vnf Types",response=Response.class) - public Response getVnfTypes (@QueryParam("vnf-role") String vnfRole, @PathParam("version") String version) { - - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("GetVnfTypes"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getVnfTypes with vnf-role:" + vnfRole); - - List vnfResources = null; - try(CatalogDatabase db = CatalogDatabase.getInstance()) { - if (vnfRole != null) { - vnfResources = db.getVnfResourcesByRole (vnfRole); - } else { - vnfResources = db.getAllVnfResources (); - } - } catch (Exception e) { - msoLogger.debug ("No connection to catalog DB", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "No connection to catalog DB"); - msoLogger.debug ("End of the transaction, the final response is: " + e.toString ()); - return Response.status (HttpStatus.SC_NOT_FOUND).entity (e.toString ()).build (); - } - - if (vnfResources == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Error:no vnf types found"); - msoLogger.debug ("End of the transaction. No VNF Types found. The final response status is: " + HttpStatus.SC_NOT_FOUND); - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - - ObjectFactory beansObjectFactory = new ObjectFactory (); - VnfTypes vnfTypes = beansObjectFactory.createVnfTypes (); - for (VnfResource vnfResource : vnfResources) { - VnfType vnfType = beansObjectFactory.createVnfType(); - VnfResource vr = vnfResource; - vnfType.setDescription(vr.getDescription()); - vnfType.setId(String.valueOf(vr.getModelUuid())); - vnfTypes.getVnfType().add(vnfType); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VnfTypes.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (vnfTypes, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + response); - return Response.status (HttpStatus.SC_OK).entity (response).build (); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java deleted file mode 100644 index adc5189670..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java +++ /dev/null @@ -1,371 +0,0 @@ -package org.openecomp.mso.apihandlerinfra; - -/*- - * #%L - * MSO - * %% - * Copyright (C) 2016 ONAP - SO - * %% - * 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. - * #L% - */ - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.apache.http.HttpStatus; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; -import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeInputs; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeOutputs; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequests; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; -import org.xml.sax.InputSource; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path("/{version: v1|v2|v3}/volume-request") -@Api(value="/{version: v1|v2|v3}/volume-request",description="API Requests for volumeRequest") -public class VolumeInfoHandler { - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - - @GET - @ApiOperation(value="Finds Volume Requests",response=Response.class) - public Response queryFilters (@QueryParam("vnf-type") String vnfType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenantId") String tenantId, - @QueryParam("volume-group-id") String volumeGroupId, - @QueryParam("volume-group-name") String volumeGroupName, - @PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VolumeQueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType - + " service-type:" + serviceType - + " aic-node-clli:" + aicNodeClli - + " tenant-id:" + tenantId - + " volume-group-id:" + volumeGroupId - + " volume-group-name:" + volumeGroupName); - Response response; - if (vnfType != null) { - response = this.getRequestList ("vnfType", vnfType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - @ApiOperation(value="Find Volume Outputs by requestId and verison",response=Response.class) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VolumeGetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - - } - - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - - protected void fillVolumeRequest (VolumeRequest qr, InfraRequests ar, String version) { - VolumeInputs vi = beansObjectFactory.createVolumeInputs (); - - if (ar.getVolumeGroupId () != null) { - vi.setVolumeGroupId (ar.getVolumeGroupId ()); - } - if (ar.getVolumeGroupName () != null) { - vi.setVolumeGroupName (ar.getVolumeGroupName ()); - } - if (ar.getVnfType () != null) { - vi.setVnfType (ar.getVnfType ()); - } - - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - if (ar.getVnfId() != null) { - vi.setVnfId(ar.getVnfId()); - } - break; - } - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - - qr.setVolumeInputs (vi); - - qr.setVolumeParams(ar.getVnfParams ()); - - try { - String volumeoutputs = ar.getVnfOutputs (); - if (volumeoutputs != null && volumeoutputs.length () > 0) { - msoLogger.debug ("Read VOLUME outputs: " + volumeoutputs); - VolumeOutputs volumeOutput = null; - - // Now unmarshal it into network outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (volumeoutputs)); - SAXSource source = new SAXSource (inputSource); - - volumeOutput = (VolumeOutputs) jaxbUnmarshaller.unmarshal (source, VolumeOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for volume outputs"); - } - - qr.setVolumeOutputs (volumeOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading networkOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - if (volumeGroupName != null) { - return this.getRequestList ("volumeGroupName", volumeGroupName, version); - } - if (volumeGroupId != null) { - return this.getRequestList ("volumeGroupId", volumeGroupId, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString; - - InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId, - "VOLUME"); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute, - queryValue, - "VOLUME"); - - List queryResponseList = new LinkedList <> (); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateVolumeRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private VolumeRequest fillGeneric (InfraRequests ar) { - VolumeRequest qr = beansObjectFactory.createVolumeRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList <> (); - - for (InfraRequests ar : arList) { - VolumeRequest qr = fillGeneric (ar); - fillVolumeRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateVolumeRequests (List queryResponseList) { - VolumeRequests queryResponses = new VolumeRequests (); - for (VolumeRequest aQueryResponseList : queryResponseList) { - queryResponses.getVolumeRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - VolumeRequest qr = fillGeneric (ar); - fillVolumeRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } - - private String getAuditLogReturnMsg (Response response) { - String returnMsg = ""; - if (response.getStatus() == HttpStatus.SC_OK) { - returnMsg = "Successful. StatusCode=" + HttpStatus.SC_OK; - } else if (response.getStatus() == HttpStatus.SC_NOT_FOUND) { - returnMsg = "Record not found . StatusCode=" + HttpStatus.SC_NOT_FOUND; - } else if (response.getStatus() == HttpStatus.SC_BAD_REQUEST) { - returnMsg = "Bad request: one of the following attribute serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName should be defined. StatusCode=" + HttpStatus.SC_BAD_REQUEST; - } - return returnMsg; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java deleted file mode 100644 index f908a3f0d6..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java +++ /dev/null @@ -1,647 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import java.io.StringReader; -import java.io.StringWriter; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamResult; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeInputs; -import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; - -public class VolumeMsoInfraRequest { - - private String requestId; - private String requestXML; - private String requestUri; - private RequestInfo rinfo; - private VolumeInputs volumeInputs; - private String volumeParams; - private ActionType action; - private String errorMessage; - private String httpResponse; - private String responseBody; - private RequestStatusType status; - private long startTime; - private long progress = Constants.PROGRESS_REQUEST_RECEIVED; - - protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static final String NOT_PROVIDED = "not provided"; - - VolumeMsoInfraRequest (String requestId) { - this.requestId = requestId; - this.startTime = System.currentTimeMillis(); - MsoLogger.setLogContext (requestId, null); - - } - - // Parse request XML - void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { - - msoLogger.debug ("Validating the request"); - - this.requestXML = reqXML; - - VolumeRequest volumeReq = null; - boolean isWrongRootElement = false; - - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (reqXML)); - SAXSource source = new SAXSource (inputSource); - - if (reqXML.contains ("volume-request") && !reqXML.contains("vnf-request")) { - volumeReq = jaxbUnmarshaller.unmarshal (source, VolumeRequest.class).getValue (); - } else { - isWrongRootElement = true; - } - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - throw new ValidationException ("format for volume request"); - } - - if (isWrongRootElement) { - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.SchemaError, "root element expected"); - throw new ValidationException ("root element expected"); - } - - if (volumeReq == null) { - throw new ValidationException ("volume-request"); - } - - this.rinfo = volumeReq.getRequestInfo (); - - if (this.rinfo == null) { - throw new ValidationException ("request-info"); - } - - action = this.rinfo.getAction (); - if (action == null) { - throw new ValidationException ("action"); - } - this.volumeInputs = volumeReq.getVolumeInputs (); - if (this.volumeInputs == null) { - throw new ValidationException ("volume-inputs"); - } - - // Verify that the elements correspond to the version - - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || - this.volumeInputs.getVfModuleModelName() != null - || this.volumeInputs.getAsdcServiceModelVersion() != null || - this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { - throw new ValidationException("format for v1 version of volume request"); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || - this.volumeInputs.getServiceInstanceId() != null || this.volumeInputs.getVnfId() != null) { - throw new ValidationException("format for v2 version of volume request"); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { - throw new ValidationException("format for v3 version of volume request"); - } - break; - } - - - if (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) { - throw new ValidationException ("action allowable for version " + version + " of volume request"); - } - - switch (action) { - case UPDATE: - case DELETE: - case UPDATE_VF_MODULE_VOL: - case DELETE_VF_MODULE_VOL: - if (this.volumeInputs.getVolumeGroupId () == null) { - throw new ValidationException ("volume-group-id"); - } - break; - default: - break; - } - - if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) { - if (this.volumeInputs.getVolumeGroupName () == null) { - throw new ValidationException ("volume-group-name"); - } - if (!InfraUtils.isValidHeatName(this.volumeInputs.getVolumeGroupName ())) { - throw new ValidationException ("volume-group-name: no value meeting heat stack name syntax requirements"); - } - } - - - if (this.volumeInputs.getVnfType () == null) { - throw new ValidationException ("vnf-type"); - } - - - switch (action) { - case CREATE_VF_MODULE_VOL: - case UPDATE_VF_MODULE_VOL: - case DELETE_VF_MODULE_VOL: - if (this.volumeInputs.getVfModuleModelName () == null) { - throw new ValidationException ("vf-module-model-name"); - } - break; - default: - break; - } - - if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceId () == null) { - throw new ValidationException ("service-id "); - } - - if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceType () != null && this.volumeInputs.getServiceId () != null) { - throw new ValidationException ("service-type or service-id "); - } - - if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getAicNodeClli () == null) { - throw new ValidationException ("aic-node-clli"); - } - - if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.volumeInputs.getAicCloudRegion () == null || this.volumeInputs.getAicCloudRegion ().isEmpty())) { - throw new ValidationException ("aic-cloud-region"); - } - - if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getServiceInstanceId () == null) { - throw new ValidationException ("service-instance-id"); - } - - if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getVnfId () == null && ActionType.CREATE_VF_MODULE_VOL.equals(action)) { - throw new ValidationException ("vnf-id"); - } - - if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) { - if (this.volumeInputs.getTenantId () == null) { - throw new ValidationException ("tenant-id"); - } - } - - - Object vpN = volumeReq.getVolumeParams (); - - if (vpN != null) { - Node node = (Node) vpN; - Document doc = node.getOwnerDocument (); - this.volumeParams = domToStr (doc); - } - - msoLogger.debug ("VolumeParams: " + this.volumeParams); - - - msoLogger.debug ("Request valid"); - - // Rebuild the request string for BPEL to include request-id - rinfo.setRequestId (this.requestId); - volumeReq.setRequestInfo (rinfo); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (volumeReq, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - this.requestXML = stringWriter.toString ().replace("http://org.openecomp/mso/infra/volume-request", - "http://org.openecomp/mso/infra/vnf-request"); - - msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); - - } - - public void createRequestRecord (Status status) { - - Session session = null; - try { - - session = requestsDbSessionFactoryManager.getSessionFactory ().openSession (); - session.beginTransaction (); - - InfraActiveRequests aq = new InfraActiveRequests (); - aq.setRequestId (requestId); - - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - if (rinfo != null) { - if (rinfo.getAction () != null) { - aq.setAction (rinfo.getAction ().value ()); - aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); - } - aq.setSource (rinfo.getSource ()); - } else { - // Set up mandatory parameters - aq.setAction (NOT_PROVIDED); - aq.setRequestAction (NOT_PROVIDED); - } - - aq.setRequestBody (this.requestXML); - aq.setRequestScope (ModelType.volumeGroup.name ()); - - if (volumeInputs != null) { - if (volumeInputs.getVolumeGroupId () != null) { - aq.setVolumeGroupId (volumeInputs.getVolumeGroupId ()); - } - if (volumeInputs.getVolumeGroupName () != null) { - aq.setVolumeGroupName (volumeInputs.getVolumeGroupName ()); - } - if (volumeInputs.getVnfType () != null) { - aq.setVnfType (volumeInputs.getVnfType ()); - } - if (volumeInputs.getVnfId () != null) { - aq.setVnfId (volumeInputs.getVnfId ()); - } - if (volumeInputs.getServiceInstanceId () != null) { - aq.setServiceInstanceId (volumeInputs.getServiceInstanceId ()); - } - if (volumeInputs.getServiceType () != null) { - aq.setServiceType (volumeInputs.getServiceType ()); - } - if (volumeInputs.getServiceId () != null) { - aq.setAaiServiceId (volumeInputs.getServiceId ()); - } - if (volumeInputs.getAicNodeClli () != null) { - aq.setAicNodeClli (volumeInputs.getAicNodeClli ()); - } - if (volumeInputs.getAicCloudRegion () != null) { - aq.setAicCloudRegion (volumeInputs.getAicCloudRegion ()); - } - if (volumeInputs.getTenantId () != null) { - aq.setTenantId (volumeInputs.getTenantId ()); - } - - } - aq.setStartTime (startTimeStamp); - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - aq.setRequestType ("VOLUME"); - - if (volumeParams != null) { - msoLogger.debug ("Storing volumeParams: " + volumeParams); - aq.setVnfParams (this.volumeParams); - } - - if ((status == Status.FAILED) || (status == Status.COMPLETE)) { - aq.setStatusMessage (this.errorMessage); - aq.setResponseBody (this.responseBody); - - Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - } - aq.setProgress (this.progress); - - - msoLogger.debug ("About to insert a record"); - - session.save (aq); - session.getTransaction ().commit (); - session.close (); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in createRequestRecord", e); - if (session != null) { - session.close (); - } - if (!status.equals (Status.FAILED)) { - throw e; - } - } - } - - public void updateFinalStatus (Status status) { - int result = 0; - try { - result = (RequestsDatabase.getInstance()).updateInfraFinalStatus(requestId, status.toString (), - this.errorMessage, this.progress, this.responseBody, Constants.MODIFIED_BY_APIHANDLER); - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception in updateFinalStatus"); - msoLogger.debug("Exception: ", e); - } - } - - public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { - return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); - } - - public Response buildResponseWithError (int httpResponseCode, - String errorCode, - InfraActiveRequests inProgress, - String errorString) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - - VolumeRequest vr = beansObjectFactory.createVolumeRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - - ri.setRequestId (requestId); - ri.setRequestStatus (this.status); - ri.setAction (this.rinfo.getAction ()); - ri.setSource (this.rinfo.getSource ()); - - String errorMsg = null; - if (errorCode != null) { - // If error code is actually an XML error response from BPEL, treat it specially: - if (!Messages.errors.containsKey (errorCode)) { - if (errorCode.length () > 300) { - errorMsg = errorCode.substring (0, 299); - } else { - errorMsg = errorCode; - } - - } else { - - if (inProgress == null) { - if (errorCode.equals(ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { - errorMsg = String.format (Messages.errors.get (errorCode), "volume", errorString); - } - else { - errorMsg = String.format (Messages.errors.get (errorCode), errorString); - } - } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "volume", - inProgress.getVnfName (), - inProgress.getRequestStatus (), - "volume"); - } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { - errorMsg = String.format (Messages.errors.get (errorCode), - "volume", - inProgress.getVnfId (), - inProgress.getRequestStatus (), - inProgress.getAction (), - "volume"); - } - } - - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - } - ri.setProgress ((int) this.progress); - - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - - vr.setRequestInfo (ri); - vr.setVolumeInputs (this.volumeInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Exception: ", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - // Log the failed request into the MSO Requests database - - return Response.status (httpResponseCode).entity (response).build (); - - } - - public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { - - ObjectFactory beansObjectFactory = new ObjectFactory (); - VolumeRequest vr = beansObjectFactory.createVolumeRequest (); - - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (requestId); - - if (this.rinfo != null) { - if (this.rinfo.getAction () != null) { - ri.setAction (this.rinfo.getAction ()); - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - if (this.rinfo.getSource () != null) { - ri.setSource (this.rinfo.getSource ()); - } - } else { - ri.setAction (ActionType.NOT_PROVIDED); - } - - // Nothing more is expected for this request - - String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION - + "_service"), - exceptionMessage); - ri.setStatusMessage (errorMsg); - this.errorMessage = errorMsg; - - ri.setProgress ((int) this.progress); - ri.setRequestStatus (RequestStatusType.FAILED); - Date startDate = new Date (this.startTime); - SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); - String startTimeString = sdf.format (startDate); - - ri.setStartTime (startTimeString); - - vr.setRequestInfo (ri); - vr.setVolumeInputs (this.volumeInputs); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (vr, stringWriter); - - } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); - } - - String response = stringWriter.toString (); - - this.httpResponse = Integer.toString (httpResponseCode); - this.responseBody = response; - - return Response.status (httpResponseCode).entity (response).build (); - } - - public String getRequestUri () { - return requestUri; - } - - public void setRequestUri (String requestUri) { - this.requestUri = requestUri; - } - - public VolumeInputs getVolumeInputs () { - return volumeInputs; - } - - public RequestInfo getRequestInfo () { - return rinfo; - } - - public String getResponseBody () { - return responseBody; - } - - public void setResponseBody (String responseBody) { - this.responseBody = responseBody; - } - - public String getHttpResponse () { - return httpResponse; - } - - public void setHttpResponse (String httpResponse) { - this.httpResponse = httpResponse; - } - - public String getRequestId () { - return requestId; - } - - public String getRequestXML () { - return requestXML; - } - - public void setRequestXML (String requestXML) { - this.requestXML = requestXML; - } - - public RequestStatusType getStatus () { - return status; - } - - public void setStatus (RequestStatusType status) { - this.status = status; - switch (status) { - case FAILED: - case COMPLETE: - this.progress = Constants.PROGRESS_REQUEST_COMPLETED; - break; - case IN_PROGRESS: - this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; - break; - } - } - - public String getServiceType () { - if (this.volumeInputs.getServiceType () != null) - return this.volumeInputs.getServiceType (); - if (this.volumeInputs.getServiceId () != null) - return this.volumeInputs.getServiceId (); - return null; - } - - public static String domToStr (Document doc) { - if (doc == null) { - return null; - } - - try { - StringWriter sw = new StringWriter (); - StreamResult sr = new StreamResult (sw); - TransformerFactory tf = TransformerFactory.newInstance (); - Transformer t = tf.newTransformer (); - t.setOutputProperty (OutputKeys.STANDALONE, "yes"); - NodeList nl = doc.getDocumentElement ().getChildNodes (); - DOMSource source = null; - for (int x = 0; x < nl.getLength (); x++) { - Node e = nl.item (x); - if (e instanceof Element) { - source = new DOMSource (e); - break; - } - } - if (source != null) { - t.transform (source, sr); - - String s = sw.toString (); - return s; - } - - return null; - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in domToStr", e); - } - return null; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java deleted file mode 100644 index e3af83df92..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java +++ /dev/null @@ -1,750 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; - -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.sax.SAXSource; - -import org.xml.sax.InputSource; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; -import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeInputs; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeOutputs; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequests; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; - -@Path("/{version: v1|v2|v3}/volume-request") -public class VolumeRequestHandler { - - @Context - private UriInfo uriInfo; - - protected ObjectFactory beansObjectFactory = new ObjectFactory (); - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - - private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); - - private static final String NOT_FOUND = "Application Not StartedApplication not started, properties file missing or invalid or Database Connection failed"; - - private static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) - .entity (NOT_FOUND) - .build (); - - private RequestsDatabase requestDB = RequestsDatabase.getInstance(); - - @GET - public Response queryFilters (@QueryParam("vnf-type") String vnfType, - @QueryParam("service-type") String serviceType, - @QueryParam("aic-node-clli") String aicNodeClli, - @QueryParam("tenantId") String tenantId, - @QueryParam("volume-group-id") String volumeGroupId, - @QueryParam("volume-group-name") String volumeGroupName, - @PathParam("version") String version) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VolumeQueryFilters"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType - + " service-type:" + serviceType - + " aic-node-clli:" + aicNodeClli - + " tenant-id:" + tenantId - + " volume-group-id:" + volumeGroupId - + " volume-group-name:" + volumeGroupName); - Response response = null; - if (vnfType != null) { - response = this.getRequestList ("vnfType", vnfType, version); - } else { - response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, version); - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - @GET - @Path(Constants.REQUEST_ID_PATH) - public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { - - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("VolumeGetRequest"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); - msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId); - - Response response = getRequestGeneric (requestId, version); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - - } - - - protected MsoLogger getMsoLogger () { - return msoLogger; - } - - - protected void fillVolumeRequest (VolumeRequest qr, InfraRequests ar, String version) { - VolumeInputs vi = beansObjectFactory.createVolumeInputs (); - - if (ar.getVolumeGroupId () != null) { - vi.setVolumeGroupId (ar.getVolumeGroupId ()); - } - if (ar.getVolumeGroupName () != null) { - vi.setVolumeGroupName (ar.getVolumeGroupName ()); - } - if (ar.getVnfType () != null) { - vi.setVnfType (ar.getVnfType ()); - } - - switch (version) { - case Constants.SCHEMA_VERSION_V1: - if (ar.getServiceType() != null) { - vi.setServiceType(ar.getServiceType()); - } - if (ar.getAicNodeClli() != null) { - vi.setAicNodeClli(ar.getAicNodeClli()); - } - break; - case Constants.SCHEMA_VERSION_V2: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - break; - case Constants.SCHEMA_VERSION_V3: - if (ar.getAaiServiceId() != null) { - vi.setServiceId(ar.getAaiServiceId()); - } - if (ar.getAicCloudRegion() != null) { - vi.setAicCloudRegion(ar.getAicCloudRegion()); - } - if (ar.getVfModuleModelName() != null) { - vi.setVfModuleModelName(ar.getVfModuleModelName()); - } - if (ar.getServiceInstanceId() != null) { - vi.setServiceInstanceId(ar.getServiceInstanceId()); - } - if (ar.getVnfId() != null) { - vi.setVnfId(ar.getVnfId()); - } - break; - } - if (ar.getTenantId () != null) { - vi.setTenantId (ar.getTenantId ()); - } - - qr.setVolumeInputs (vi); - - qr.setVolumeParams(ar.getVnfParams ()); - - try { - String volumeoutputs = ar.getVnfOutputs (); - if (volumeoutputs != null && volumeoutputs.length () > 0) { - msoLogger.debug ("Read VOLUME outputs: " + volumeoutputs); - VolumeOutputs volumeOutput = null; - - // Now unmarshal it into network outputs - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeOutputs.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); - - InputSource inputSource = new InputSource (new StringReader (volumeoutputs)); - SAXSource source = new SAXSource (inputSource); - - volumeOutput = (VolumeOutputs) jaxbUnmarshaller.unmarshal (source, VolumeOutputs.class).getValue (); - - } catch (Exception e) { - msoLogger.debug ("Validation failed", e); - throw new ValidationException ("format for volume outputs"); - } - - qr.setVolumeOutputs (volumeOutput); - } - } catch (Exception e) { - msoLogger.debug ("exception reading networkOutputs Clob", e); - } - } - - protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String version) { - if (serviceType != null) { - return this.getRequestList ("serviceType", serviceType, version); - } - if (aicNodeClli != null) { - return this.getRequestList ("aicNodeClli", aicNodeClli, version); - } - if (tenantId != null) { - return this.getRequestList ("tenantId", tenantId, version); - } - if (volumeGroupName != null) { - return this.getRequestList ("volumeGroupName", volumeGroupName, version); - } - if (volumeGroupId != null) { - return this.getRequestList ("volumeGroupId", volumeGroupId, version); - } - return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); - } - - - protected Response getRequestGeneric (String requestId, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest: " + requestId); - - String responseString = null; - - InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId, - "VOLUME"); - if (activeReq != null) { - // build response for active - responseString = infraRequestsResponse (activeReq, version); - return Response.status (HttpStatus.SC_OK).entity (responseString).build (); - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - protected Response getRequestList (String queryAttribute, String queryValue, String version) { - // Check INFRA_ACTIVE_REQUESTS table to find info - // on this request - - getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); - - List activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute, - queryValue, - "VOLUME"); - - List queryResponseList = new LinkedList<>(); - - if (activeReqList != null) { - // build response for active - queryResponseList = infraRequestsResponses (activeReqList, version); - - } - - - if (queryResponseList != null && !queryResponseList.isEmpty ()) { - String result = this.translateVolumeRequests (queryResponseList); - return Response.status (HttpStatus.SC_OK).entity (result).build (); - - } else { - // Report that no request has been found - return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); - } - } - - private VolumeRequest fillGeneric (InfraRequests ar) { - VolumeRequest qr = beansObjectFactory.createVolumeRequest (); - RequestInfo ri = beansObjectFactory.createRequestInfo (); - ri.setRequestId (ar.getRequestId ()); - ri.setAction (ActionType.fromValue (ar.getAction ())); - ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); - if (ar.getProgress () != null) { - ri.setProgress (ar.getProgress ().intValue ()); - } - if (ar.getSource () != null) { - ri.setSource (ar.getSource ()); - } - - ri.setStartTime (ar.getStartTime ().toString ()); - if (ar.getEndTime () != null) { - ri.setEndTime (ar.getEndTime ().toString ()); - } - - if (ar.getStatusMessage () != null) { - ri.setStatusMessage (ar.getStatusMessage ()); - } - qr.setRequestInfo (ri); - return qr; - } - - private List infraRequestsResponses (List arList, String version) { - List queryResponseList = new LinkedList<>(); - - for (InfraRequests ar : arList) { - VolumeRequest qr = fillGeneric (ar); - fillVolumeRequest (qr, ar, version); - queryResponseList.add (qr); - } - return queryResponseList; - } - - private String translateVolumeRequests (List queryResponseList) { - VolumeRequests queryResponses = new VolumeRequests (); - for (VolumeRequest aQueryResponseList : queryResponseList) { - queryResponses.getVolumeRequest().add(aQueryResponseList); - } - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequests.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - // output pretty printed - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - - jaxbMarshaller.marshal (queryResponses, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - return stringWriter.toString (); - } - - private String infraRequestsResponse (InfraRequests ar, String version) { - VolumeRequest qr = fillGeneric (ar); - fillVolumeRequest (qr, ar, version); - - StringWriter stringWriter = new StringWriter (); - try { - JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); - Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); - - jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); - jaxbMarshaller.marshal (qr, stringWriter); - - } catch (JAXBException e) { - getMsoLogger ().debug ("Marshalling issue", e); - } - - String response = stringWriter.toString (); - return response; - } - - private String getAuditLogReturnMsg (Response response) { - String returnMsg = ""; - if (response.getStatus() == HttpStatus.SC_OK) { - returnMsg = "Successful. StatusCode=" + HttpStatus.SC_OK; - } else if (response.getStatus() == HttpStatus.SC_NOT_FOUND) { - returnMsg = "Record not found . StatusCode=" + HttpStatus.SC_NOT_FOUND; - } else if (response.getStatus() == HttpStatus.SC_BAD_REQUEST) { - returnMsg = "Bad request: one of the following attribute serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName should be defined. StatusCode=" + HttpStatus.SC_BAD_REQUEST; - } - return returnMsg; - } - - @POST - @Path("/") - @Produces(MediaType.APPLICATION_XML) - public Response manageVolumeRequest (String reqXML, @PathParam("version") String version) { - MsoLogger.setServiceName ("VolumeRequest"); - if ("v1".equals(version)) { - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } else if ("v2".equals(version)) { - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } else if ("v3".equals(version)) { - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } else { - long startTime = System.currentTimeMillis (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); - return Response.status(HttpStatus.SC_NOT_FOUND).build(); - } - } - - private Response manageVolumeRequestImpl (String reqXML, String version) { - String methodName = "VolumeRequest"; - props = MsoPropertiesUtils.loadMsoProperties (); - - long startTime = System.currentTimeMillis (); - if (MsoPropertiesUtils.getNoPropertiesState()) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Application not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - - uriInfo.getRequestUri (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - VolumeMsoInfraRequest msoRequest = new VolumeMsoInfraRequest (requestUUID.toString ()); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The input request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - - msoLogger.debug ("Incoming Request: " + reqXML); - - msoRequest.setRequestUri (requestUri); - - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo ().getAction ().name ()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo ().getAction ().name ()); - if (msoRequest.getRequestInfo () - .getAction () == org.openecomp.mso.apihandlerinfra.volumebeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same network Name - msoLogger.debug ("Checking for a duplicate with the same volume-name"); - InfraActiveRequests dup = null; - try { - - dup = requestDB.checkDuplicateByVnfName (msoRequest.getVolumeInputs ().getVolumeGroupName (), - msoRequest.getRequestInfo ().getAction ().value (), - "VOLUME"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "volume-group-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - "CREATE on the same Volume Group Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same Volume Group Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same Volume Group Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same volumeGroupId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same volume-group-id"); - try { - dup = requestDB.checkDuplicateByVnfId (msoRequest.getVolumeInputs ().getVolumeGroupId (), - msoRequest.getRequestInfo ().getAction ().value (), - "VOLUME"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "volume-group-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the sam volume-group-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the sam volume-group-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same Volume Group Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same Volume Group Id already in progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same Volume Group Id already in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - // Query MSO Catalog DB - try(CatalogDatabase db = CatalogDatabase.getInstance()) { - Recipe recipe = null; - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - } - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - null); - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - } - } - else if (version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) { - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE: - case UPDATE: - case DELETE: - // First get recipe for the vnf type given - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - } - break; - case CREATE_VF_MODULE_VOL: - case UPDATE_VF_MODULE_VOL: - case DELETE_VF_MODULE_VOL: - // First get recipe for the vnf type given - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - - // If no recipe for the vnf type is found, look for generic recipe with "*" in vf module id - if (recipe == null) { - recipe = db.getVnfComponentsRecipeByVfModuleModelUUId (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value ()); - } - break; - default: - break; - } - - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "VNF Recipe not found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - db.close (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "VNF Recipe not found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in createRequestRecord", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post(msoRequest.getRequestXML(), - requestId, - Integer.toString(recipe.getRecipeTimeout()), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.DataError, "Null response from BPMN engine"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.IN_PROGRESS); - requestDB.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.DataError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is with status Failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.DataError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java deleted file mode 100644 index b3fc70ad91..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for action-type. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="action-type">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="CREATE"/>
- *     <enumeration value="SETSTATUS"/>
- *     <enumeration value="REPLACE"/>
- *     <enumeration value="UPDATE"/>
- *     <enumeration value="DELETE"/>
- *     <enumeration value="NOT_PROVIDED"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "action-type") -@XmlEnum -public enum ActionType { - - CREATE, - SETSTATUS, - REPLACE, - UPDATE, - DELETE, - NOT_PROVIDED; - - public String value() { - return name(); - } - - public static ActionType fromValue(String v) { - return valueOf(v); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java deleted file mode 100644 index d9a3323ee8..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java +++ /dev/null @@ -1,378 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="network-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="network-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="network-type" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="service-instance-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="backout-on-failure" type="{http://www.w3.org/2001/XMLSchema}Boolean"/>
- *         <choice>
- *         	<element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         	<element name="service-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         </choice>
- *         <choice>
- *         	<element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *          <element name="aic-cloud-region" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         </choice>
- *         <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="prov-status" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "networkId", - "networkName", - "networkType", - "serviceInstanceId", - "backoutOnFailure", - "serviceType", - "serviceId", - "aicNodeClli", - "aicCloudRegion", - "tenantId", - "provStatus" -}) -@XmlRootElement(name = "network-inputs") -public class NetworkInputs { - - @XmlElement(name = "network-id") - protected String networkId; - @XmlElement(name = "network-name") - protected String networkName; - @XmlElement(name = "network-type", required = true) - protected String networkType; - @XmlElement(name = "service-instance-id") - protected String serviceInstanceId; - @XmlElement(name = "backout-on-failure") - protected Boolean backoutOnFailure; - @XmlElement(name = "service-type") - protected String serviceType; - @XmlElement(name = "service-id") - protected String serviceId; - @XmlElement(name = "aic-node-clli") - protected String aicNodeClli; - @XmlElement(name = "aic-cloud-region") - protected String aicCloudRegion; - @XmlElement(name = "tenant-id", required = true) - protected String tenantId; - @XmlElement(name = "prov-status") - protected String provStatus; - - /** - * Gets the value of the networkId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNetworkId() { - return networkId; - } - - /** - * Sets the value of the networkId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNetworkId(String value) { - this.networkId = value; - } - - /** - * Gets the value of the networkName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNetworkName() { - return networkName; - } - - /** - * Sets the value of the networkName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNetworkName(String value) { - this.networkName = value; - } - - /** - * Gets the value of the networkType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNetworkType() { - return networkType; - } - - /** - * Sets the value of the networkType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNetworkType(String value) { - this.networkType = value; - } - - /** - * Gets the value of the serviceInstanceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * Sets the value of the serviceInstanceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceInstanceId(String value) { - this.serviceInstanceId = value; - } - - /** - * Gets the value of the serviceType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceType() { - return serviceType; - } - - /** - * Sets the value of the serviceType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceType(String value) { - this.serviceType = value; - } - - /** - * Gets the value of the serviceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceId() { - return serviceId; - } - - /** - * Sets the value of the serviceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceId (String value) { - this.serviceId = value; - } - - - /** - * Gets the value of the aicNodeClli property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicNodeClli() { - return aicNodeClli; - } - - /** - * Sets the value of the aicNodeClli property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicNodeClli(String value) { - this.aicNodeClli = value; - } - - /** - * Gets the value of the aicCloudRegion property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicCloudRegion() { - return aicCloudRegion; - } - - /** - * Sets the value of the aicCloudRegion property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicCloudRegion(String value) { - this.aicCloudRegion = value; - } - - - /** - * Gets the value of the tenantId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTenantId() { - return tenantId; - } - - /** - * Sets the value of the tenantId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTenantId(String value) { - this.tenantId = value; - } - - /** - * Gets the value of the provStatus property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getProvStatus() { - return provStatus; - } - - /** - * Sets the value of the provStatus property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setProvStatus(String value) { - this.provStatus = value; - } - - /** - * Gets the value of the backoutOnFailure property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean getBackoutOnFailure() { - return backoutOnFailure; - } - - /** - * Sets the value of the backoutOnFailure property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setBackoutOnFailure(Boolean value) { - this.backoutOnFailure = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java deleted file mode 100644 index aedac6f00d..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="network-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="network-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "networkId", - "networkName" -}) -@XmlRootElement(name = "network-outputs") -public class NetworkOutputs { - - @XmlElement(name = "network-id", required = true) - protected String networkId; - @XmlElement(name = "network-name", required = true) - protected String networkName; - - /** - * Gets the value of the networkId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNetworkId() { - return networkId; - } - - /** - * Sets the value of the networkId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNetworkId(String value) { - this.networkId = value; - } - - /** - * Gets the value of the networkName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getNetworkName() { - return networkName; - } - - /** - * Sets the value of the networkName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNetworkName(String value) { - this.networkName = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java deleted file mode 100644 index a325e54c08..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}request-info"/>
- *           <sequence>
- *             <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-inputs"/>
- *             <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-params" minOccurs="0"/>
- *             <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-outputs" minOccurs="0"/>
- *           </sequence>
- *        </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestInfo", - "networkInputs", - "networkParams", - "networkOutputs" -}) -@XmlRootElement(name = "network-request") -public class NetworkRequest { - - @XmlElement(name = "request-info", required = true) - protected RequestInfo requestInfo; - @XmlElement(name = "network-inputs") - protected NetworkInputs networkInputs; - @XmlElement(name = "network-params") - protected Object networkParams; - @XmlElement(name = "network-outputs") - protected NetworkOutputs networkOutputs; - - /** - * Gets the value of the requestInfo property. - * - * @return - * possible object is - * {@link RequestInfo } - * - */ - public RequestInfo getRequestInfo() { - return requestInfo; - } - - /** - * Sets the value of the requestInfo property. - * - * @param value - * allowed object is - * {@link RequestInfo } - * - */ - public void setRequestInfo(RequestInfo value) { - this.requestInfo = value; - } - - - /** - * Gets the value of the networkInputs property. - * - * @return - * possible object is - * {@link NetworkInputs } - * - */ - public NetworkInputs getNetworkInputs() { - return networkInputs; - } - - /** - * Sets the value of the networkInputs property. - * - * @param value - * allowed object is - * {@link NetworkInputs } - * - */ - public void setNetworkInputs(NetworkInputs value) { - this.networkInputs = value; - } - - /** - * Gets the value of the networkParams property. - * - * @return - * possible object is - * {@link Object } - * - */ - public Object getNetworkParams() { - return networkParams; - } - - /** - * Sets the value of the networkParams property. - * - * @param value - * allowed object is - * {@link Object } - * - */ - public void setNetworkParams(Object value) { - this.networkParams = value; - } - - /** - * Gets the value of the networkOutputs property. - * - * @return - * possible object is - * {@link NetworkOutputs } - * - */ - public NetworkOutputs getNetworkOutputs() { - return networkOutputs; - } - - /** - * Sets the value of the networkOutputs property. - * - * @param value - * allowed object is - * {@link NetworkOutputs } - * - */ - public void setNetworkOutputs(NetworkOutputs value) { - this.networkOutputs = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java deleted file mode 100644 index a223d6e384..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/mso/infra/network-request/v1}network-request" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "networkRequest" -}) -@XmlRootElement(name = "network-requests") -public class NetworkRequests { - - @XmlElement(name = "network-request") - protected List networkRequest; - - /** - * Gets the value of the networkRequest property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the vnfRequest property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getNetworkRequest().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link NetworkRequest } - * - * - */ - public List getNetworkRequest() { - if (networkRequest == null) { - networkRequest = new ArrayList<>(); - } - return this.networkRequest; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java deleted file mode 100644 index 7d435862e9..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="type" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "type", - "id", - "description" -}) -@XmlRootElement(name = "network-type") -public class NetworkType { - - @XmlElement(required = true) - protected String type; - @XmlElement(required = true) - protected String id; - @XmlElement(required = true) - protected String description; - - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the description property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDescription(String value) { - this.description = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java deleted file mode 100644 index 9e9a832843..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "networkType" -}) -@XmlRootElement(name = "network-types") -public class NetworkTypes { - - @XmlElement(name = "network-type") - protected List networkType; - - /** - * Gets the value of the networkType property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the vnfType property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getNetworkType().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link NetworkType } - * - * - */ - public List getNetworkType() { - if (networkType == null) { - networkType = new ArrayList<>(); - } - return this.networkType; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java deleted file mode 100644 index 652c6a32ef..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _NetworkParams_QNAME = new QName("http://org.openecomp/mso/infra/network-request/v1", "network-params"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link RequestInfo } - * - */ - public RequestInfo createRequestInfo() { - return new RequestInfo(); - } - - /** - * Create an instance of {@link NetworkRequest } - * - */ - public NetworkRequest createNetworkRequest() { - return new NetworkRequest(); - } - - /** - * Create an instance of {@link NetworkInputs } - * - */ - public NetworkInputs createNetworkInputs() { - return new NetworkInputs(); - } - - /** - * Create an instance of {@link NetworkOutputs } - * - */ - public NetworkOutputs createNetworkOutputs() { - return new NetworkOutputs(); - } - - /** - * Create an instance of {@link NetworkRequests } - * - */ - public NetworkRequests createNetworkRequests() { - return new NetworkRequests(); - } - - /** - * Create an instance of {@link NetworkTypes } - * - */ - public NetworkTypes createNetworkTypes() { - return new NetworkTypes(); - } - - /** - * Create an instance of {@link NetworkType } - * - */ - public NetworkType createNetworkType() { - return new NetworkType(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/network-request/v1", name = "network-params") - public JAXBElement createNetworkParams(Object value) { - return new JAXBElement<>(_NetworkParams_QNAME, Object.class, null, value); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java deleted file mode 100644 index 7f30a8a33c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java +++ /dev/null @@ -1,285 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/>
- *         <element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/>
- *         <element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="end-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "action", - "requestStatus", - "statusMessage", - "progress", - "startTime", - "endTime", - "source" -}) -@XmlRootElement(name = "request-info") -public class RequestInfo { - - @XmlElement(name = "request-id") - protected String requestId; - @XmlElement(required = true) - protected ActionType action; - @XmlElement(name = "request-status") - protected RequestStatusType requestStatus; - @XmlElement(name = "status-message") - protected String statusMessage; - protected Integer progress; - @XmlElement(name = "start-time") - protected String startTime; - @XmlElement(name = "end-time") - protected String endTime; - protected String source; - - /** - * Gets the value of the requestId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRequestId() { - return requestId; - } - - /** - * Sets the value of the requestId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRequestId(String value) { - this.requestId = value; - } - - /** - * Gets the value of the action property. - * - * @return - * possible object is - * {@link ActionType } - * - */ - public ActionType getAction() { - return action; - } - - /** - * Sets the value of the action property. - * - * @param value - * allowed object is - * {@link ActionType } - * - */ - public void setAction(ActionType value) { - this.action = value; - } - - /** - * Gets the value of the requestStatus property. - * - * @return - * possible object is - * {@link RequestStatusType } - * - */ - public RequestStatusType getRequestStatus() { - return requestStatus; - } - - /** - * Sets the value of the requestStatus property. - * - * @param value - * allowed object is - * {@link RequestStatusType } - * - */ - public void setRequestStatus(RequestStatusType value) { - this.requestStatus = value; - } - - /** - * Gets the value of the statusMessage property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStatusMessage() { - return statusMessage; - } - - /** - * Sets the value of the statusMessage property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStatusMessage(String value) { - this.statusMessage = value; - } - - /** - * Gets the value of the progress property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getProgress() { - return progress; - } - - /** - * Sets the value of the progress property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setProgress(Integer value) { - this.progress = value; - } - - /** - * Gets the value of the startTime property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStartTime() { - return startTime; - } - - /** - * Sets the value of the startTime property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStartTime(String value) { - this.startTime = value; - } - - /** - * Gets the value of the endTime property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEndTime() { - return endTime; - } - - /** - * Sets the value of the endTime property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEndTime(String value) { - this.endTime = value; - } - - /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSource() { - return source; - } - - /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSource(String value) { - this.source = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java deleted file mode 100644 index ef18284475..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.networkbeans; - - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for request-status-type. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="request-status-type">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="COMPLETE"/>
- *     <enumeration value="FAILED"/>
- *     <enumeration value="IN_PROGRESS"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "request-status-type") -@XmlEnum -public enum RequestStatusType { - - COMPLETE, - FAILED, - IN_PROGRESS, - PENDING, - TIMEOUT; - - public String value() { - return name(); - } - - public static RequestStatusType fromValue(String v) { - return valueOf(v); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java deleted file mode 100644 index 5ffba93303..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/network-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package org.openecomp.mso.apihandlerinfra.networkbeans; - diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java deleted file mode 100644 index 41f95e650e..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for action-type. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="action-type">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="CREATE"/>
- *     <enumeration value="UPDATE"/>
- *     <enumeration value="DELETE"/>
- *     <enumeration value="CREATE_VF_MODULE_VOL"/>
- *     <enumeration value="UPDATE_VF_MODULE_VOL"/>
- *     <enumeration value="DELETE_VF_MODULE_VOL"/>
- *     <enumeration value="NOT_PROVIDED"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "action-type") -@XmlEnum -public enum ActionType { - - CREATE, - UPDATE, - DELETE, - CREATE_VF_MODULE_VOL, - UPDATE_VF_MODULE_VOL, - DELETE_VF_MODULE_VOL, - NOT_PROVIDED; - - public String value() { - return name(); - } - - public static ActionType fromValue(String v) { - return valueOf(v); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java deleted file mode 100644 index 2d4d588f9a..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _VolumeParams_QNAME = new QName("http://org.openecomp/mso/infra/volume-request/v1", "volume-params"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link RequestInfo } - * - */ - public RequestInfo createRequestInfo() { - return new RequestInfo(); - } - - /** - * Create an instance of {@link VolumeRequest } - * - */ - public VolumeRequest createVolumeRequest() { - return new VolumeRequest(); - } - - /** - * Create an instance of {@link VolumeInputs } - * - */ - public VolumeInputs createVolumeInputs() { - return new VolumeInputs(); - } - - /** - * Create an instance of {@link VolumeOutputs } - * - */ - public VolumeOutputs createVolumeOutputs() { - return new VolumeOutputs(); - } - - /** - * Create an instance of {@link VolumeRequests } - * - */ - public VolumeRequests createVolumeRequests() { - return new VolumeRequests(); - } - - - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/volume-request/v1", name = "volume-params") - public JAXBElement createVolumeParams(Object value) { - return new JAXBElement<>(_VolumeParams_QNAME, Object.class, null, value); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java deleted file mode 100644 index f69692c24f..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java +++ /dev/null @@ -1,286 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/>
- *         <element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/>
- *         <element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="end-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "action", - "requestStatus", - "statusMessage", - "progress", - "startTime", - "endTime", - "source" -}) -@XmlRootElement(name = "request-info") -public class RequestInfo { - - @XmlElement(name = "request-id") - protected String requestId; - @XmlElement(required = true) - protected ActionType action; - @XmlElement(name = "request-status") - protected RequestStatusType requestStatus; - @XmlElement(name = "status-message") - protected String statusMessage; - protected Integer progress; - @XmlElement(name = "start-time") - protected String startTime; - @XmlElement(name = "end-time") - protected String endTime; - protected String source; - - /** - * Gets the value of the requestId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRequestId() { - return requestId; - } - - /** - * Sets the value of the requestId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRequestId(String value) { - this.requestId = value; - } - - /** - * Gets the value of the action property. - * - * @return - * possible object is - * {@link ActionType } - * - */ - public ActionType getAction() { - return action; - } - - /** - * Sets the value of the action property. - * - * @param value - * allowed object is - * {@link ActionType } - * - */ - public void setAction(ActionType value) { - this.action = value; - } - - /** - * Gets the value of the requestStatus property. - * - * @return - * possible object is - * {@link RequestStatusType } - * - */ - public RequestStatusType getRequestStatus() { - return requestStatus; - } - - /** - * Sets the value of the requestStatus property. - * - * @param value - * allowed object is - * {@link RequestStatusType } - * - */ - public void setRequestStatus(RequestStatusType value) { - this.requestStatus = value; - } - - /** - * Gets the value of the statusMessage property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStatusMessage() { - return statusMessage; - } - - /** - * Sets the value of the statusMessage property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStatusMessage(String value) { - this.statusMessage = value; - } - - /** - * Gets the value of the progress property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getProgress() { - return progress; - } - - /** - * Sets the value of the progress property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setProgress(Integer value) { - this.progress = value; - } - - /** - * Gets the value of the startTime property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStartTime() { - return startTime; - } - - /** - * Sets the value of the startTime property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStartTime(String value) { - this.startTime = value; - } - - /** - * Gets the value of the endTime property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEndTime() { - return endTime; - } - - /** - * Sets the value of the endTime property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEndTime(String value) { - this.endTime = value; - } - - /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSource() { - return source; - } - - /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSource(String value) { - this.source = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java deleted file mode 100644 index c14e3e2587..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for request-status-type. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="request-status-type">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="COMPLETE"/>
- *     <enumeration value="FAILED"/>
- *     <enumeration value="IN_PROGRESS"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "request-status-type") -@XmlEnum -public enum RequestStatusType { - - COMPLETE, - FAILED, - IN_PROGRESS, - PENDING, - TIMEOUT; - - public String value() { - return name(); - } - - public static RequestStatusType fromValue(String v) { - return valueOf(v); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java deleted file mode 100644 index bd97060cd4..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java +++ /dev/null @@ -1,435 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="vf-module-model-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="asdc-service-model-version" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="vnf-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="service-instance-id" type="{http://www.w3.org/2001/XMLSchema}Boolean"/>
- *         <choice>
- *         	<element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         	<element name="service-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         </choice>
- *          <choice>
- *         	<element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *          <element name="aic-cloud-region" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         </choice>
- *         <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfType", - "vnfId", - "vfModuleModelName", - "asdcServiceModelVersion", - "serviceInstanceId", - "backoutOnFailure", - "serviceType", - "serviceId", - "aicNodeClli", - "aicCloudRegion", - "tenantId", - "volumeGroupName", - "volumeGroupId" -}) -@XmlRootElement(name = "volume-inputs") -public class VolumeInputs { - @XmlElement(name = "vnf-type", required = true) - protected String vnfType; - @XmlElement(name = "vnf-id") - protected String vnfId; - @XmlElement(name = "vf-module-model-name") - protected String vfModuleModelName; - @XmlElement(name = "asdc-service-model-version") - protected String asdcServiceModelVersion; - @XmlElement(name = "service-instance-id", required = true) - protected String serviceInstanceId; - @XmlElement(name = "backout-on-failure") - protected Boolean backoutOnFailure; - @XmlElement(name = "service-type") - protected String serviceType; - @XmlElement(name = "service-id") - protected String serviceId; - @XmlElement(name = "aic-node-clli", required = true) - protected String aicNodeClli; - @XmlElement(name = "aic-cloud-region") - protected String aicCloudRegion; - @XmlElement(name = "tenant-id", required = true) - protected String tenantId; - @XmlElement(name = "volume-group-name") - protected String volumeGroupName; - @XmlElement(name = "volume-group-id") - protected String volumeGroupId; - - /** - * Gets the value of the volumeGroupId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVolumeGroupId() { - return volumeGroupId; - } - - /** - * Sets the value of the volumeGroupId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVolumeGroupId(String value) { - this.volumeGroupId = value; - } - - /** - * Gets the value of the volumeGroupName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVolumeGroupName() { - return volumeGroupName; - } - - /** - * Sets the value of the volumeGroupName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVolumeGroupName(String value) { - this.volumeGroupName = value; - } - - /** - * Gets the value of the vnfType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVnfType() { - return vnfType; - } - - /** - * Sets the value of the vnfType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVnfType(String value) { - this.vnfType = value; - } - - /** - * Gets the value of the vnfId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVnfId() { - return vnfId; - } - - /** - * Sets the value of the vnfId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVnfId(String value) { - this.vnfId = value; - } - - /** - * Gets the value of the serviceInstanceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * Sets the value of the serviceInstanceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceInstanceId(String value) { - this.serviceInstanceId = value; - } - - /** - * Gets the value of the serviceType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceType() { - return serviceType; - } - - /** - * Sets the value of the serviceType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceType(String value) { - this.serviceType = value; - } - - /** - * Gets the value of the serviceId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceId() { - return serviceId; - } - - /** - * Sets the value of the serviceId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceId (String value) { - this.serviceId = value; - } - - - /** - * Gets the value of the aicNodeClli property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicNodeClli() { - return aicNodeClli; - } - - /** - * Sets the value of the aicNodeClli property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicNodeClli(String value) { - this.aicNodeClli = value; - } - - /** - * Gets the value of the aicCloudRegion property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicCloudRegion() { - return aicCloudRegion; - } - - /** - * Sets the value of the aicCloudRegion property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicCloudRegion(String value) { - this.aicCloudRegion = value; - } - - /** - * Gets the value of the tenantId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTenantId() { - return tenantId; - } - - /** - * Sets the value of the tenantId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTenantId(String value) { - this.tenantId = value; - } - - /** - * Gets the value of the vfModuleModelName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVfModuleModelName() { - return vfModuleModelName; - } - - /** - * Sets the value of the vfModuleModelName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVfModuleModelName(String value) { - this.vfModuleModelName = value; - } - - /** - * Gets the value of the asdcServiceModelVersion property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAsdcServiceModelVersion() { - return asdcServiceModelVersion; - } - - /** - * Sets the value of the asdcServiceModelVersion property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAsdcServiceModelVersion(String value) { - this.asdcServiceModelVersion = value; - } - - /** - * Gets the value of the backoutOnFailure property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean getBackoutOnFailure() { - return backoutOnFailure; - } - - /** - * Sets the value of the backoutOnFailure property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setBackoutOnFailure(Boolean value) { - this.backoutOnFailure = value; - } - - - - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java deleted file mode 100644 index 3b8fab6552..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java +++ /dev/null @@ -1,233 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfType", - "serviceType", - "aicNodeClli", - "tenantId", - "volumeGroupName", - "volumeGroupId" -}) -@XmlRootElement(name = "volume-outputs") -public class VolumeOutputs { - @XmlElement(name = "vnf-type", required = true) - protected String vnfType; - @XmlElement(name = "service-type") - protected String serviceType; - @XmlElement(name = "aic-node-clli", required = true) - protected String aicNodeClli; - @XmlElement(name = "tenant-id", required = true) - protected String tenantId; - @XmlElement(name = "volume-group-name") - protected String volumeGroupName; - @XmlElement(name = "volume-group-id") - protected String volumeGroupId; - - /** - * Gets the value of the volumeId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVolumeGroupId() { - return volumeGroupId; - } - - /** - * Sets the value of the volumeGroupId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVolumeGroupId(String value) { - this.volumeGroupId = value; - } - - /** - * Gets the value of the volumeGroupName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVolumeGroupName() { - return volumeGroupName; - } - - /** - * Sets the value of the volumeGroupName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVolumeGroupName(String value) { - this.volumeGroupName = value; - } - - /** - * Gets the value of the vnfType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVnfType() { - return vnfType; - } - - /** - * Sets the value of the vnfType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVnfType(String value) { - this.vnfType = value; - } - - /** - * Gets the value of the serviceType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getServiceType() { - return serviceType; - } - - /** - * Sets the value of the serviceType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setServiceType(String value) { - this.serviceType = value; - } - - /** - * Gets the value of the aicNodeClli property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicNodeClli() { - return aicNodeClli; - } - - /** - * Sets the value of the aicNodeClli property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicNodeClli(String value) { - this.aicNodeClli = value; - } - - /** - * Gets the value of the tenantId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTenantId() { - return tenantId; - } - - /** - * Sets the value of the tenantId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTenantId(String value) { - this.tenantId = value; - } - - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java deleted file mode 100644 index 69e0ca232c..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/mso/infra/volume-request/v1}request-info"/>
- *           <sequence>
- *             <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-inputs"/>
- *             <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-params" minOccurs="0"/>
- *             <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-outputs" minOccurs="0"/>
- *           </sequence>
- *        </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestInfo", - "volumeInputs", - "volumeParams", - "volumeOutputs" -}) -@XmlRootElement(name = "volume-request") -public class VolumeRequest { - - @XmlElement(name = "request-info", required = true) - protected RequestInfo requestInfo; - @XmlElement(name = "volume-inputs") - protected VolumeInputs volumeInputs; - @XmlElement(name = "volume-params") - protected Object volumeParams; - @XmlElement(name = "volume-outputs") - protected VolumeOutputs volumeOutputs; - - /** - * Gets the value of the requestInfo property. - * - * @return - * possible object is - * {@link RequestInfo } - * - */ - public RequestInfo getRequestInfo() { - return requestInfo; - } - - /** - * Sets the value of the requestInfo property. - * - * @param value - * allowed object is - * {@link RequestInfo } - * - */ - public void setRequestInfo(RequestInfo value) { - this.requestInfo = value; - } - - - /** - * Gets the value of the volumeInputs property. - * - * @return - * possible object is - * {@link VolumeInputs } - * - */ - public VolumeInputs getVolumeInputs() { - return volumeInputs; - } - - /** - * Sets the value of the volumeInputs property. - * - * @param value - * allowed object is - * {@link VolumeInputs } - * - */ - public void setVolumeInputs(VolumeInputs value) { - this.volumeInputs = value; - } - - /** - * Gets the value of the volumeParams property. - * - * @return - * possible object is - * {@link Object } - * - */ - public Object getVolumeParams() { - return volumeParams; - } - - /** - * Sets the value of the volumeParams property. - * - * @param value - * allowed object is - * {@link Object } - * - */ - public void setVolumeParams(Object value) { - this.volumeParams = value; - } - - /** - * Gets the value of the volumeOutputs property. - * - * @return - * possible object is - * {@link VolumeOutputs } - * - */ - public VolumeOutputs getVolumeOutputs() { - return volumeOutputs; - } - - /** - * Sets the value of the volumeOutputs property. - * - * @param value - * allowed object is - * {@link VolumeOutputs } - * - */ - public void setVolumeOutputs(VolumeOutputs value) { - this.volumeOutputs = value; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java deleted file mode 100644 index 318ff90136..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - - -package org.openecomp.mso.apihandlerinfra.volumebeans; - - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-request" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "volumeRequest" -}) -@XmlRootElement(name = "volume-requests") -public class VolumeRequests { - - @XmlElement(name = "volume-request") - protected List volumeRequest; - - /** - * Gets the value of the volumeRequest property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the vnfRequest property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getVolumeRequest().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link VolumeRequest } - * - * - */ - public List getVolumeRequest() { - if (volumeRequest == null) { - volumeRequest = new ArrayList<>(); - } - return this.volumeRequest; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java deleted file mode 100644 index 4224f657d6..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT -// - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/volume-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package org.openecomp.mso.apihandlerinfra.volumebeans; - diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandlerTest.java deleted file mode 100644 index 445fab329f..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandlerTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; -import org.openecomp.mso.requestsdb.InfraRequests; - -public class NetworkInfoHandlerTest { - - NetworkInfoHandler handler = new NetworkInfoHandler(); - - @Test - public void fillVnfRequestTest(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v3"); - String vnfid = (String)qr.getNetworkParams(); - assertTrue(vnfid.equals("test")); - } - - @Test - public void fillVnfRequestTestV2(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v2"); - String vnfid = (String)qr.getNetworkParams(); - assertTrue(vnfid.equals("test")); - } - - @Test - public void fillVnfRequestTestV1(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v1"); - String vnfid = (String)qr.getNetworkParams(); - assertTrue(vnfid.equals("test")); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java deleted file mode 100644 index 2089cf1d32..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java +++ /dev/null @@ -1,333 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.net.URI; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import mockit.Expectations; -import mockit.Mock; -import mockit.MockUp; - -import mockit.Mocked; -import org.apache.http.HttpResponse; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.message.BasicHttpResponse; -import org.hibernate.Session; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -import org.openecomp.mso.apihandler.common.CamundaClient; -import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.NetworkRecipe; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; - -public class NetworkRequestHandlerTest { - private static final String REQ_XML = " e1fc3ed3-31e5-48a8-913b-23184c1e9443CREATE VID e1fc3ed3-31e5-48a8-913b-23184c1e9443 e1fc3ed3-31e5-48a8-913b-23184c1e9443 nwInstanceName nwModelNamee1fc3ed3-31e5-48a8-913b-23184c1e9443 e1fc3ed3-31e5-48a8-913b-23184c1e9443 e1fc3ed3-31e5-48a8-913b-23184c1e9443e1fc3ed3-31e5-48a8-913b-23184c1e9443 false1802e1fc3ed3-31e5-48a8-913b-23184c1e9443 "; - - private static MockUp mockRDB; - private static MockUp mockCDB; - private static MockUp mockCamundaClient; - - NetworkRequestHandler handler = null; - UriInfo uriInfo = null; - - @Before - public void setup() throws Exception{ - - uriInfo = Mockito.mock(UriInfo.class); - - Class clazz = NetworkRequestHandler.class; - handler = (NetworkRequestHandler)clazz.newInstance(); - - Field f1 = handler.getClass().getDeclaredField("uriInfo"); - - f1.setAccessible(true); - f1.set(handler, uriInfo); - - } - - @BeforeClass - public static void setUp() throws Exception { - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); - - mockRDB = new MockUp() { - @Mock - public InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) { - return null; - } - @Mock - public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) { - return 1; - } - - @Mock - public int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) { - return 1; - } - }; - - mockCDB = new MockUp() { - @Mock - public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { - final NetworkRecipe networkRecipe = new NetworkRecipe(); - networkRecipe.setOrchestrationUri("test/vnf"); - networkRecipe.setRecipeTimeout(180); - return networkRecipe; - } - - @Mock - public VfModule getVfModuleType(String type, String version) { - final VfModule vfModule = new VfModule(); - return vfModule; - } - - @Mock - public VnfResource getVnfResource (String vnfType, String serviceVersion) { - final VnfResource vnfResource = new VnfResource(); - return vnfResource; - } - }; - - mockCamundaClient = new MockUp() { - @Mock - public HttpResponse post(String camundaReqXML, String requestId, - String requestTimeout, String schemaVersion, String serviceInstanceId, String action) - throws ClientProtocolException, IOException { - ProtocolVersion pv = new ProtocolVersion("HTTP",1,1); - HttpResponse resp = new BasicHttpResponse(pv,200, "test response"); - BasicHttpEntity entity = new BasicHttpEntity(); - String body = "{\"response\":\"success\",\"message\":\"success\"}"; - InputStream instream = new ByteArrayInputStream(body.getBytes()); - entity.setContent(instream); - resp.setEntity(entity); - return resp; - } - }; - - } - - @AfterClass - public static void tearDown() { - mockRDB.tearDown(); - mockCDB.tearDown(); - mockCamundaClient.tearDown(); - } - - @Test - public void manageVnfRequestTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session){ - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - }}; - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequestTestV1(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session){ - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - }}; - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest(REQ_XML, "v1"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequestTestV3(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session){ - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - }}; - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequestTestInvalidVersion(){ - Response resp = handler.manageNetworkRequest(REQ_XML, "v249"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequest2Test(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); - assertTrue(null != resp); - } - - @Test - public void fillNetworkRequestTestV1(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v1"); - String param = (String)qr.getNetworkParams(); - assertTrue(param.equals("test")); - } - @Test - public void fillNetworkRequestTestV2(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v2"); - String param = (String)qr.getNetworkParams(); - assertTrue(param.equals("test")); - } - @Test - public void fillNetworkRequestTestV3(){ - NetworkRequest qr = new NetworkRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - handler.fillNetworkRequest(qr, ar, "v3"); - String param = (String)qr.getNetworkParams(); - assertTrue(param.equals("test")); - } - - @Test - public void queryFiltersTest(){ - new MockUp() { - @Mock - public List getRequestListFromInfraActive (String queryAttributeName, - String queryValue, - String requestType) { - List list = new ArrayList<>(); - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - list.add(req); - return list; - } - }; - Response resp = handler.queryFilters("networkType", "serviceType", "aicNodeClli", "tenantId", "v1"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getRequestTest(){ - new MockUp() { - @Mock - public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - return req; - } - }; - Response resp = handler.getRequest("388293", "v1"); - assertTrue(resp.getEntity().toString() != null); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandlerTest.java deleted file mode 100644 index 3738e2f94a..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandlerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.Response; - -import mockit.Mock; -import mockit.MockUp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.NetworkResource; - -public class NetworkTypesHandlerTest { - - NetworkTypesHandler handler = new NetworkTypesHandler(); - - @Test - public void getNetworkTypesTest(){ - Response resp = handler.getNetworkTypes("v2"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getNetworkTypesTest2(){ - new MockUp() { - @Mock - public List getAllNetworkResources(){ - return null; - } - }; - Response resp = handler.getNetworkTypes("v2"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getNetworkTypesTest3(){ - List netList = new ArrayList<>(); - new MockUp() { - @Mock - public List getAllNetworkResources(){ - NetworkResource ns = new NetworkResource(); - netList.add(ns); - return netList; - } - }; - Response resp = handler.getNetworkTypes("v2"); - assertTrue(resp.getEntity().toString() != null); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java deleted file mode 100644 index 1c3c85653b..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandlerTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import mockit.Mock; -import mockit.MockUp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfResource; - -import javax.ws.rs.core.Response; -public class VfModuleModelNamesHandlerTest { - - VfModuleModelNamesHandler handler = new VfModuleModelNamesHandler(); - - @Test - public void getVfModuleModelNamesTest(){ - Response resp = handler.getVfModuleModelNames("v2"); - assertTrue(resp.getEntity().toString()!= null); - } - - @Test - public void getVfModuleModelNamesTest2(){ - new MockUp() { - @Mock - public List getAllVfModules(){ - List list = new ArrayList<>(); - VfModule resource = new VfModule(); - list.add(resource); - return list; - } - }; - Response resp = handler.getVfModuleModelNames("v2"); - assertTrue(resp.getEntity().toString()!= null); - } - - - @Test - public void getVfModuleModelNamesTest3(){ - new MockUp() { - @Mock - public List getAllVfModules(){ - return null; - } - }; - Response resp = handler.getVfModuleModelNames("v2"); - assertTrue(resp.getEntity().toString()!= null); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandlerTest.java deleted file mode 100644 index fd22af012f..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandlerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.requestsdb.InfraRequests; - -public class VnfInfoHandlerTest { - - VnfInfoHandler handler = new VnfInfoHandler(); - - @Test - public void fillVnfRequestTest(){ - VnfRequest qr = new VnfRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillVnfRequest(qr, ar, "v3"); - String vnfid = (String)qr.getVnfParams(); - assertTrue(vnfid.equals("test")); - } - - @Test - public void fillVnfRequestTestV2(){ - VnfRequest qr = new VnfRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillVnfRequest(qr, ar, "v2"); - String vnfid = (String)qr.getVnfParams(); - assertTrue(vnfid.equals("test")); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java deleted file mode 100644 index 9a9dec3c27..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import mockit.Expectations; -import mockit.Mocked; -import mockit.Tested; -import mockit.integration.junit4.JMockit; -import org.hibernate.Session; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.properties.MsoJavaProperties; - -@RunWith(JMockit.class) -public class VnfMsoInfraRequestTest { - - VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020"); - private String reqXML = "43b34d6d-1ab2-4c7a-a3a0-5471306550c5CREATE_VF_MODULEVID43b34d6d-1ab2-4c7a-a3a0-5471306550c5vnfNamevnfType43b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c5vfModuleName43b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c5false43b34d6d-1ab2-4c7a-a3a0-5471306550c5pNamepValue"; - - @Test - public void parseTest() throws ValidationException { - request.parse(reqXML, "v3", new MsoJavaProperties()); - } - - @Test - public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager, - @Mocked Session session) throws ValidationException { - - new Expectations() {{ - sessionFactoryManager.getSessionFactory().openSession(); result = session; - }}; - - request.parse(reqXML, "v3", new MsoJavaProperties()); - request.createRequestRecord(Status.COMPLETE); - - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java deleted file mode 100644 index 11c385ced9..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java +++ /dev/null @@ -1,364 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.net.URI; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -import mockit.Mock; -import mockit.MockUp; - -import org.apache.http.HttpResponse; -import org.apache.http.ProtocolVersion; -import org.apache.http.StatusLine; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.mso.apihandler.common.CamundaClient; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfRecipe; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -public class VnfRequestHandlerTest { - private static MockUp mockRDB; - private static MockUp mockMsoRequest; - private static MockUp mockCDB; - private static MockUp mockCamudaClient; -// private static MockUp mockCamudaClient; - VnfRequestHandler handler = null; - UriInfo uriInfo = null; - - private static final String manageVnfRequest = "43b34d6d-1ab2-4c7a-a3a0-5471306550c5CREATE_VF_MODULEVID43b34d6d-1ab2-4c7a-a3a0-5471306550c5vnfNamevnfType43b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c5vfModuleName43b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c543b34d6d-1ab2-4c7a-a3a0-5471306550c5false43b34d6d-1ab2-4c7a-a3a0-5471306550c5\t\t\t\t"; - - @Before - public void setup() throws Exception{ - - uriInfo = Mockito.mock(UriInfo.class); - Class clazz = VnfRequestHandler.class; - handler = (VnfRequestHandler)clazz.newInstance(); - - Field f1 = handler.getClass().getDeclaredField("uriInfo"); - - f1.setAccessible(true); - f1.set(handler, uriInfo); - } - - @BeforeClass - public static void setUp() throws Exception { - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); - - mockRDB = new MockUp() { - @Mock - public InfraActiveRequests checkDuplicateByVnfId(String vnfId, String action, String requestType) { - return null; - } - @Mock - public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) { - return 1; - } - - @Mock - public int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) { - return 1; - } - }; - - mockMsoRequest = new MockUp() { - @Mock - public void createRequestRecord (Status status) { - return; - } - }; - - mockCDB = new MockUp() { - @Mock - public VnfRecipe getVfModuleRecipe(String vnfType, String vfModuleModelName, String action) { - final VnfRecipe vnfRecipe = new VnfRecipe(); - vnfRecipe.setOrchestrationUri("test/vnf"); - vnfRecipe.setRecipeTimeout(180); - return vnfRecipe; - } - - @Mock - public VfModule getVfModuleType(String type, String version) { - final VfModule vfModule = new VfModule(); - return vfModule; - } - - @Mock - public VnfResource getVnfResource (String vnfType, String serviceVersion) { - final VnfResource vnfResource = new VnfResource(); - return vnfResource; - } - }; - - mockCamudaClient = new MockUp() { - @Mock - public HttpResponse post(String camundaReqXML, String requestId, - String requestTimeout, String schemaVersion, String serviceInstanceId, String action) - throws ClientProtocolException, IOException { - ProtocolVersion pv = new ProtocolVersion("HTTP",1,1); - HttpResponse resp = new BasicHttpResponse(pv,200, "test response"); - BasicHttpEntity entity = new BasicHttpEntity(); - String body = "{\"response\":\"success\",\"message\":\"success\"}"; - InputStream instream = new ByteArrayInputStream(body.getBytes()); - entity.setContent(instream); - resp.setEntity(entity); - return resp; - } - }; - - /*mockCamudaClient = new MockUp() { - @Mock - public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{ - RequestClient client = new CamundaClient(); - client.setUrl("/test/url"); - return client; - } - };*/ - - } - - @AfterClass - public static void tearDown() { - mockRDB.tearDown(); - mockMsoRequest.tearDown(); - mockCDB.tearDown(); - mockCamudaClient.tearDown(); - } - - @Test - public void manageVnfRequestTestV2(){ - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageVnfRequest(manageVnfRequest, "v2"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequestTestv1(){ - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageVnfRequest(manageVnfRequest, "v1"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequestTestv3(){ - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageVnfRequest(manageVnfRequest, "v3"); - assertTrue(null != resp); - } - @Test - public void manageVnfRequestTestInvalidVersion(){ - Response resp = handler.manageVnfRequest(manageVnfRequest, "v30"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequest2Test(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - Response resp = handler.manageVnfRequest(manageVnfRequest, "v2"); - assertTrue(null != resp); - } - - @Test - public void fillVnfRequestTest(){ - VnfRequest qr = new VnfRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - handler.fillVnfRequest(qr, ar, "v1"); - String param = (String)qr.getVnfParams(); - assertTrue(param.equals("test")); - } - - @Test - public void fillVnfRequestTestV2(){ - VnfRequest qr = new VnfRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - handler.fillVnfRequest(qr, ar, "v2"); - String param = (String)qr.getVnfParams(); - assertTrue(param.equals("test")); - } - @Test - public void fillVnfRequestTestV3(){ - VnfRequest qr = new VnfRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("1003"); - ar.setVnfName("vnf"); - ar.setVnfType("vnt"); - ar.setTenantId("48889690"); - ar.setProvStatus("uuu"); - ar.setVolumeGroupName("volume"); - ar.setVolumeGroupId("38838"); - ar.setServiceType("vnf"); - ar.setAicNodeClli("djerfe"); - ar.setAaiServiceId("599499"); - ar.setAicCloudRegion("south"); - ar.setVfModuleName("m1"); - ar.setVfModuleId("39949"); - ar.setVfModuleModelName("test"); - ar.setAaiServiceId("37728"); - ar.setVnfParams("test"); - ar.setServiceInstanceId("38829"); - handler.fillVnfRequest(qr, ar, "v3"); - String param = (String)qr.getVnfParams(); - assertTrue(param.equals("test")); - } - - @Test - public void queryFiltersTest(){ - new MockUp() { - @Mock - public List getRequestListFromInfraActive (String queryAttributeName, - String queryValue, - String requestType) { - List list = new ArrayList<>(); - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - list.add(req); - return list; - } - }; - Response resp = handler.queryFilters("vnfType", "serviceType", "aicNodeClli", "tenantId", "volumeGroupId", "volumeGroupName", "vnfName", "v1"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void queryFiltersTestNullVnfType(){ - new MockUp() { - @Mock - public List getRequestListFromInfraActive (String queryAttributeName, - String queryValue, - String requestType) { - List list = new ArrayList<>(); - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - list.add(req); - return list; - } - }; - Response resp = handler.queryFilters(null, null, null, null, null, null, null, "v1"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getRequestTest(){ - new MockUp() { - @Mock - public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - return req; - } - }; - Response resp = handler.getRequest("388293", "v1"); - assertTrue(resp.getEntity().toString() != null); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java deleted file mode 100644 index 1800bb4695..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandlerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import mockit.Mock; -import mockit.MockUp; - -import org.junit.Test; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.db.catalog.beans.VnfResource; - -import javax.ws.rs.core.Response; - -public class VnfTypesHandlerTest { - - VnfTypesHandler handler = new VnfTypesHandler(); - - @Test - public void getVnfTypesTest(){ - Response resp = handler.getVnfTypes(null, "v2"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getVnfTypesTest2(){ - new MockUp() { - @Mock - public List getAllVnfResources(){ - return null; - } - }; - Response resp = handler.getVnfTypes(null, "v2"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getVnfTypesTest3(){ - new MockUp() { - @Mock - public List getAllVnfResources(){ - List list = new ArrayList<>(); - VnfResource resource = new VnfResource(); - list.add(resource); - return list; - } - }; - Response resp = handler.getVnfTypes(null, "v2"); - assertTrue(resp.getEntity().toString() != null); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java deleted file mode 100644 index ffdf5d40b4..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import mockit.Mock; -import mockit.MockUp; -import org.apache.http.HttpResponse; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.message.BasicHttpResponse; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.mso.apihandler.common.CamundaClient; -import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; -import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; -import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.NetworkRecipe; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.InfraRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; - -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.sql.Timestamp; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; - -public class VolumeInfoHandlerTest { - - VolumeInfoHandler handler = new VolumeInfoHandler(); - - private static MockUp mockRDB; - - @BeforeClass - public static void setUp() throws Exception { - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); - - mockRDB = new MockUp() { - @Mock - public List getRequestListFromInfraActive (String queryAttributeName, - String queryValue, - String requestType) { - final InfraActiveRequests requests = new InfraActiveRequests(); - requests.setAction(ActionType.CREATE.name()); - requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); - requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); - return Collections.singletonList(requests); - } - @Mock - public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { - final InfraActiveRequests requests = new InfraActiveRequests(); - requests.setAction(ActionType.CREATE.name()); - requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); - requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); - return requests; - } - }; - - } - - @AfterClass - public static void tearDown() { - mockRDB.tearDown(); - } - - @Test - public void fillVnfRequestTestV3(){ - VolumeRequest qr = new VolumeRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillVolumeRequest(qr, ar, "v3"); - String vnfid = (String)qr.getVolumeParams(); - assertTrue(vnfid.equals("test")); - } - - @Test - public void fillVnfRequestTestV2(){ - VolumeRequest qr = new VolumeRequest(); - InfraRequests ar = new InfraRequests(); - ar.setVnfId("2990102"); - ar.setVnfParams("test"); - handler.fillVolumeRequest(qr, ar, "v2"); - String vnfid = (String)qr.getVolumeParams(); - assertTrue(vnfid.equals("test")); - } - - @Test - public void queryFilters() { - final Response response = handler.queryFilters("vnf-type", "svc-type", "aicNode", "tenant-id", - "vg-id", "vg-name", "v3"); - } - - @Test - public void queryFilters2() { - final Response response = handler.queryFilters(null, "svc-type", "aicNode", "tenant-id", - "vg-id", "vg-name", "v3"); - } - - @Test - public void getRequest() { - final Response response = handler.getRequest("request-id", "v3"); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java deleted file mode 100644 index e2fcca5011..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.Field; -import java.net.URI; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import mockit.Mock; -import mockit.MockUp; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; - -public class VolumeRequestHandlerTest { - VolumeRequestHandler handler = null; - - UriInfo uriInfo = null; - - @Before - public void setup() throws Exception{ - - uriInfo = Mockito.mock(UriInfo.class); - Class clazz = VolumeRequestHandler.class; - handler = (VolumeRequestHandler)clazz.newInstance(); - - Field f1 = handler.getClass().getDeclaredField("uriInfo"); - - f1.setAccessible(true); - f1.set(handler, uriInfo); - } - - @Test - public void manageVnfRequestTest(){ - Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageVolumeRequest("Test", "v2"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequest2TestV1InvalidRequestData(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - String request = "{\"result\":\"success\"}"; - Response resp = handler.manageVolumeRequest(request, "v1"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequest2TestV1(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - String request = "CREATECOMPLETEmessage100011970-01-01 02:47:00.11970-01-01 05:33:40.1test299392"; - Response resp = handler.manageVolumeRequest(request, "v1"); - assertTrue(null != resp); - } - - @Test - public void manageVnfRequest2TestV2(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - String request = "CREATECOMPLETEmessage100011970-01-01 02:47:00.11970-01-01 05:33:40.1test299392"; - Response resp = handler.manageVolumeRequest(request, "v2"); - assertTrue(null != resp); - } - @Test - public void manageVnfRequest2TestV3(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - String request = "CREATECOMPLETEmessage100011970-01-01 02:47:00.11970-01-01 05:33:40.1test299392"; - Response resp = handler.manageVolumeRequest(request, "v3"); - assertTrue(null != resp); - } - @Test - public void manageVnfRequest2TestInvalidVersion(){ - Mockito.when(uriInfo.getRequestUri()) - .thenReturn(URI.create("http://localhost:8080/test")); - - new MockUp() { - @Mock - public synchronized final boolean getNoPropertiesState() { - return false; - } - }; - String request = "CREATECOMPLETEmessage100011970-01-01 02:47:00.11970-01-01 05:33:40.1test299392"; - Response resp = handler.manageVolumeRequest(request, "v33"); - assertTrue(null != resp); - } - - @Test - public void queryFiltersTest(){ - new MockUp() { - @Mock - public List getRequestListFromInfraActive (String queryAttributeName, - String queryValue, - String requestType) { - List list = new ArrayList<>(); - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - list.add(req); - return list; - } - }; - Response resp = handler.queryFilters("vnfType", "serviceType", "aic", "19929293", "288393923", "test", "v1"); - assertTrue(resp.getEntity().toString() != null); - } - @Test - public void getRequestTestV3(){ - new MockUp() { - @Mock - public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - return req; - } - }; - Response resp = handler.getRequest("399293", "v3"); - assertTrue(resp.getEntity().toString() != null); - } - @Test - public void getRequestTestV2(){ - new MockUp() { - @Mock - public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { - InfraActiveRequests req = new InfraActiveRequests(); - req.setAaiServiceId("299392"); - req.setAction("CREATE"); - req.setRequestStatus("COMPLETE"); - req.setProgress(10001L); - req.setSource("test"); - req.setStartTime(new Timestamp(10020100)); - req.setEndTime(new Timestamp(20020100)); - req.setStatusMessage("message"); - return req; - } - }; - Response resp = handler.getRequest("399293", "v2"); - assertTrue(resp.getEntity().toString() != null); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputsTest.java deleted file mode 100644 index 3920094dc6..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.openecomp.mso.apihandlerinfra.networkbeans; - -import org.junit.Test; - -public class NetworkOutputsTest { - // TODO: currently test case is done for coverage - // later, it should be modified properly. - - NetworkOutputs test = new NetworkOutputs(); - - @Test - public void getNetworkIdTest() throws Exception { - test.getNetworkId(); - } - - @Test - public void setNetworkIdTest() throws Exception { - test.setNetworkId("id"); - } - - @Test - public void getNetworkNameTest() throws Exception { - test.getNetworkName(); - } - - @Test - public void setNetworkNameTest() throws Exception { - test.setNetworkName("name"); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactoryTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactoryTest.java deleted file mode 100644 index 228fc2fa87..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactoryTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ObjectFactoryTest { - ObjectFactory of = new ObjectFactory(); - Object o = new Object(); - @Test - public void testObjectFactory() { - of.createRequestInfo(); - of.createVolumeRequest(); - of.createVolumeInputs(); - of.createVolumeOutputs(); - of.createVolumeRequests(); - of.createVolumeParams(o); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfoTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfoTest.java deleted file mode 100644 index b452c91034..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class RequestInfoTest { - RequestInfo ri = new RequestInfo(); - ActionType actiontype = ActionType.CREATE; - RequestStatusType requestStatustype = RequestStatusType.COMPLETE; - int abc; - @Test - public void testRequestInfo() { - ri.setRequestId("requestId"); - ri.setAction(actiontype); - ri.setRequestStatus(requestStatustype); - ri.setStatusMessage("statusMessage"); - ri.setProgress(abc); - ri.setStartTime("startTime"); - ri.setEndTime("endTime"); - ri.setSource("source"); - assertEquals(ri.getRequestId(), "requestId"); - assertEquals(ri.getAction(), actiontype); - assertEquals(ri.getRequestStatus(), requestStatustype); - assertEquals(ri.getStatusMessage(), "statusMessage"); - assert(ri.getProgress().equals(abc)); - assertEquals(ri.getStartTime(), "startTime"); - assertEquals(ri.getEndTime(), "endTime"); - assertEquals(ri.getSource(), "source"); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputsTest.java deleted file mode 100644 index 8fd3ea0505..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class VolumeInputsTest { - - VolumeInputs vi = new VolumeInputs(); - @Test - public void testVolumeInputs() { - vi.setVolumeGroupId("volumeGroupId"); - vi.setVolumeGroupName("volumeGroupName"); - vi.setVnfType("vnfType"); - vi.setVnfId("vnfId"); - vi.setServiceInstanceId("serviceInstanceId"); - vi.setServiceType("serviceType"); - vi.setServiceId("serviceId"); - vi.setAicNodeClli("aicNodeClli"); - vi.setAicCloudRegion("aicCloudRegion"); - vi.setTenantId("tenantId"); - vi.setVfModuleModelName("vfModuleModelName"); - vi.setAsdcServiceModelVersion("asdcServiceModelVersion"); - vi.setBackoutOnFailure(true); - assertEquals(vi.getVolumeGroupId(), "volumeGroupId"); - assertEquals(vi.getVolumeGroupName(), "volumeGroupName"); - assertEquals(vi.getVnfType(), "vnfType"); - assertEquals(vi.getVnfId(), "vnfId"); - assertEquals(vi.getServiceInstanceId(), "serviceInstanceId"); - assertEquals(vi.getServiceType(), "serviceType"); - assertEquals(vi.getServiceId(), "serviceId"); - assertEquals(vi.getAicNodeClli(), "aicNodeClli"); - assertEquals(vi.getAicCloudRegion(), "aicCloudRegion"); - assertEquals(vi.getTenantId(), "tenantId"); - assertEquals(vi.getVfModuleModelName(), "vfModuleModelName"); - assertEquals(vi.getAsdcServiceModelVersion(), "asdcServiceModelVersion"); - assertEquals(vi.getBackoutOnFailure(), true); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputsTest.java deleted file mode 100644 index f8a65bfa42..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputsTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class VolumeOutputsTest { - - VolumeOutputs vo = new VolumeOutputs(); - @Test - public void testVolumeOutputs() { - vo.setVolumeGroupId("volumeGroupId"); - vo.setVolumeGroupName("volumeGroupName"); - vo.setVnfType("vnfType"); - vo.setServiceType("serviceType"); - vo.setAicNodeClli("aicNodeClli"); - vo.setTenantId("tenantId"); - assertEquals(vo.getVolumeGroupId(), "volumeGroupId"); - assertEquals(vo.getVolumeGroupName(), "volumeGroupName"); - assertEquals(vo.getVnfType(), "vnfType"); - assertEquals(vo.getServiceType(), "serviceType"); - assertEquals(vo.getAicNodeClli(), "aicNodeClli"); - assertEquals(vo.getTenantId(), "tenantId"); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestTest.java deleted file mode 100644 index 1e0152ef61..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class VolumeRequestTest { - - VolumeRequest vr = new VolumeRequest(); - RequestInfo ri = new RequestInfo(); - VolumeInputs vi = new VolumeInputs(); - VolumeOutputs vo = new VolumeOutputs(); - Object o = new Object(); - @Test - public void testVolumeRequest() { - vr.setRequestInfo(ri); - vr.setVolumeInputs(vi); - vr.setVolumeOutputs(vo); - vr.setVolumeParams(o); - assertEquals(vr.getRequestInfo(), ri); - assertEquals(vr.getVolumeInputs(), vi); - assertEquals(vr.getVolumeOutputs(), vo); - assertEquals(vr.getVolumeParams(), o); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestsTest.java deleted file mode 100644 index 0d2c6037a6..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequestsTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.apihandlerinfra.volumebeans; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class VolumeRequestsTest { - VolumeRequests vrs = new VolumeRequests(); - @Test - public void testVolumeRequests() { - vrs.getVolumeRequest(); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java deleted file mode 100644 index bc9c11a486..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -/** - * XML adapters. - */ - -package org.openecomp.mso.requestsdb.adapter; - -- cgit 1.2.3-korg