diff options
Diffstat (limited to 'mso-api-handlers')
21 files changed, 1244 insertions, 720 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java index 00e52ab..71fddd8 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java @@ -7,9 +7,9 @@ * 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. @@ -44,53 +44,53 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) private CamundaInput serviceInput; - + @JsonProperty(CommonConstants.CAMUNDA_HOST) private CamundaInput host; - + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) private CamundaInput requestId; - + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) private CamundaInput msoRequestId; - - + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) private CamundaBooleanInput isBaseVfModule; - + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) private CamundaIntegerInput recipeTimeout; - + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) private CamundaInput requestAction; - + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) private CamundaInput serviceInstanceId; - + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) private CamundaInput vnfId; - + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) private CamundaInput vfModuleId; - + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) private CamundaInput volumeGroupId; - + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) private CamundaInput networkId; - + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) private CamundaInput serviceType; - + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) private CamundaInput vnfType; - + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) private CamundaInput vfModuleType; - + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) private CamundaInput networkType; - + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) public CamundaInput getServiceInput() { return serviceInput; @@ -100,7 +100,7 @@ public class CamundaVIDRequest { public void setServiceInput(CamundaInput serviceInput) { this.serviceInput = serviceInput; } - + @JsonProperty(CommonConstants.CAMUNDA_HOST) public CamundaInput getHost() { return host; @@ -120,7 +120,7 @@ public class CamundaVIDRequest { public void setRequestId(CamundaInput requestId) { this.requestId = requestId; } - + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) public CamundaInput getMsoRequestId() { return msoRequestId; @@ -130,7 +130,7 @@ public class CamundaVIDRequest { public void setMsoRequestId(CamundaInput msoRequestIdp) { this.msoRequestId = msoRequestIdp; } - + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) public CamundaBooleanInput getIsBaseVfModule() { return isBaseVfModule; @@ -140,7 +140,7 @@ public class CamundaVIDRequest { public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { this.isBaseVfModule = isBaseVfModule; } - + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) public CamundaIntegerInput getRecipeTimeout() { return recipeTimeout; @@ -150,7 +150,7 @@ public class CamundaVIDRequest { public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { this.recipeTimeout = recipeTimeout; } - + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) public CamundaInput getRequestAction() { return requestAction; @@ -169,7 +169,7 @@ public class CamundaVIDRequest { public void setServiceInstanceId(CamundaInput serviceInstanceId) { this.serviceInstanceId = serviceInstanceId; } - + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) public CamundaInput getVnfId() { return vnfId; @@ -179,7 +179,7 @@ public class CamundaVIDRequest { public void setVnfId(CamundaInput vnfId) { this.vnfId = vnfId; } - + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) public CamundaInput getVfModuleId() { return vfModuleId; @@ -189,7 +189,7 @@ public class CamundaVIDRequest { public void setVfModuleId(CamundaInput vfModuleId) { this.vfModuleId = vfModuleId; } - + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) public CamundaInput getVolumeGroupId() { return volumeGroupId; @@ -199,7 +199,7 @@ public class CamundaVIDRequest { public void setVolumeGroupId(CamundaInput volumeGroupId) { this.volumeGroupId = volumeGroupId; } - + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) public CamundaInput getNetworkId() { return networkId; @@ -209,7 +209,7 @@ public class CamundaVIDRequest { public void setNetworkId(CamundaInput networkId) { this.networkId = networkId; } - + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) public CamundaInput getServiceType() { return serviceType; @@ -219,7 +219,7 @@ public class CamundaVIDRequest { public void setServiceType(CamundaInput serviceType) { this.serviceType = serviceType; } - + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) public CamundaInput getVnfType() { return vnfType; @@ -229,7 +229,7 @@ public class CamundaVIDRequest { public void setVnfType(CamundaInput vnfType) { this.vnfType = vnfType; } - + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) public CamundaInput getVfModuleType() { return vfModuleType; @@ -239,7 +239,7 @@ public class CamundaVIDRequest { public void setVfModuleType(CamundaInput vfModuleType) { this.vfModuleType = vfModuleType; } - + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) public CamundaInput getNetworkType() { return networkType; @@ -249,14 +249,14 @@ public class CamundaVIDRequest { public void setNetworkType(CamundaInput networkType) { this.networkType = networkType; } - - + + @Override public String toString() { //return "CamundaRequest [requestId=" + + ", host=" // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" // + svcid + ", timeout=" + timeout + "]"; return "CamundaRequest"; - } - + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml index e34740d..fa80b9e 100644 --- a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml @@ -2,20 +2,20 @@ <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>MSO API Handler Infra</display-name>
-
-
+
+
<context-param>
<param-name>resteasy.jndi.resources</param-name>
<param-value>java:module/MsoPropertiesFactory</param-value>
</context-param>
-
+
<!-- enable the Asynchronous Job Service -->
<context-param>
<param-name>resteasy.async.job.service.enabled</param-name>
<param-value>true</param-value>
</context-param>
- <!-- The next context parameters are all optional.
+ <!-- The next context parameters are all optional.
Their default values are shown as example param-values -->
<!-- How many jobs results can be held in memory at once? -->
@@ -45,8 +45,8 @@ <param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
-
- <!--
+
+ <!--
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/v1</param-value>
@@ -56,17 +56,17 @@ <param-name>log.configuration</param-name>
<param-value>logback.apihandler-infra.xml</param-value>
</context-param>
-
+
<context-param>
<param-name>mso.configuration</param-name>
<param-value>MSO_PROP_APIHANDLER_INFRA=mso.apihandler-infra.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value>
</context-param>
-
+
<context-param>
<param-name>resteasy.resources</param-name>
<param-value>org.openecomp.mso.logger.MsoLoggingServlet</param-value>
</context-param>
-
+
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
@@ -105,6 +105,19 @@ <role-name>SiteControl-Client</role-name>
</auth-constraint>
</security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>MSO internal Requests</web-resource-name>
+ <description>Internal Requests</description>
+ <url-pattern>/logging/*</url-pattern>
+ <url-pattern>/properties/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>MSO-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPBasicAuth</web-resource-name>
@@ -117,7 +130,7 @@ <role-name>InfraPortal-Client</role-name>
</auth-constraint>
</security-constraint>
-
+
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ApplicationRealm</realm-name>
@@ -128,14 +141,17 @@ <security-role>
<role-name>SiteControl-Client</role-name>
</security-role>
+ <security-role>
+ <role-name>MSO-Client</role-name>
+ </security-role>
<filter>
<filter-name>LogFilter</filter-name>
- <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
+ <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LogFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
+
</web-app>
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 12cfdb0..b3c8a95 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,50 +1,50 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 { - - 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 REQUEST_ID_PATH = "/{request-id}"; - - public static final String STATUS_SUCCESS = "SUCCESS"; - - public static final String MODIFIED_BY_APIHANDLER = "APIH"; - - 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 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"; +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 {
+
+ 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 REQUEST_ID_PATH = "/{request-id}";
+
+ public static final String STATUS_SUCCESS = "SUCCESS";
+
+ public static final String MODIFIED_BY_APIHANDLER = "APIH";
+
+ 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 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";
}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index 3410cf4..317859d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -85,7 +85,7 @@ public class ServiceInstances { @Path("/{serviceInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteServiceInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { + public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); @@ -96,8 +96,8 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { - + public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) { + msoLogger.debug ("version is: " + version); instanceIdMap.put("serviceInstanceId", serviceInstanceId); Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); @@ -108,9 +108,8 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("version") String version) { + public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); @@ -123,10 +122,9 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("version") String version) { - + public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId) { + msoLogger.debug ("version is: " + version); instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); @@ -138,10 +136,9 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response updateVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, - @PathParam("version") String version) { + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); @@ -155,10 +152,9 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, - @PathParam("version") String version) { + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); @@ -174,9 +170,8 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("version") String version) { + public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); @@ -189,10 +184,9 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response updateVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, - @PathParam("version") String version) { + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); @@ -207,10 +201,9 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, - @PathParam("version") String version) { + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); @@ -225,7 +218,7 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/networks") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { + public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); @@ -237,9 +230,8 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/networks/{networkInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response updateNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId, - @PathParam("version") String version) { + public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("networkInstanceId") String networkInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("networkInstanceId", networkInstanceId); @@ -252,9 +244,8 @@ public class ServiceInstances { @Path("/{serviceInstanceId}/networks/{networkInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId, - @PathParam("version") String version) { + public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("networkInstanceId") String networkInstanceId) { instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("networkInstanceId", networkInstanceId); @@ -367,11 +358,44 @@ public class ServiceInstances { serviceResponse.setRequestReferences(referencesResponse); - try (CatalogDatabase db = new CatalogDatabase()){ + CatalogDatabase db = null; + try { + db = new CatalogDatabase (); + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); + Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + "No communication to catalog DB " + e.getMessage (), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, + null); + alarmLogger.sendAlarm ("MsoDatabaseAccessError", + MsoAlarmLogger.CRITICAL, + Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); + msoRequest.createRequestRecord (Status.FAILED,action); + 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; + } + + RecipeLookupResult recipeLookupResult = null; try { recipeLookupResult = getServiceInstanceOrchestrationURI (db, msoRequest, action); + } catch (ValidationException e) { + msoLogger.debug ("Validation failed: ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error validating request. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null); + if (msoRequest.getRequestId () != null) { + msoLogger.debug ("Logging failed message to the database"); + msoRequest.createRequestRecord (Status.FAILED, action); + } + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, 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; } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e); msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); @@ -594,22 +618,6 @@ public class ServiceInstances { //return Response.status (HttpStatus.SC_ACCEPTED).entity (serviceResponse).build (); // return serviceResponse; - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - "No communication to catalog DB " + e.getMessage (), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, - null); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED,action); - 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; - } } private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java index 777c945..c877751 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java @@ -1,96 +1,96 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.serviceinstancebeans; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class CloudConfiguration { - - protected String aicNodeClli; - protected String tenantId; - protected String lcpCloudRegionId; - - /** - * 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; - } - - - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - public void setLcpCloudRegionId(String lcpCloudRegionId) { - this.lcpCloudRegionId = lcpCloudRegionId; - } - - @Override - public String toString() { - return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" - + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; - } - - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.serviceinstancebeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class CloudConfiguration {
+
+ protected String aicNodeClli;
+ protected String tenantId;
+ protected String lcpCloudRegionId;
+
+ /**
+ * 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;
+ }
+
+
+ public String getLcpCloudRegionId() {
+ return lcpCloudRegionId;
+ }
+
+ public void setLcpCloudRegionId(String lcpCloudRegionId) {
+ this.lcpCloudRegionId = lcpCloudRegionId;
+ }
+
+ @Override
+ public String toString() {
+ return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId="
+ + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]";
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java index f542d63..5f1ea28 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java @@ -1,117 +1,117 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.7 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.03.30 at 02:48:23 PM CDT -// - - -package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import org.openecomp.mso.apihandlerinfra.ModelType; - -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class ModelInfo { - - protected String modelCustomizationName; - protected String modelInvariantId; - protected ModelType modelType; - //v2 - protected String modelNameVersionId; - protected String modelName; - protected String modelVersion; - protected String modelCustomizationUuid; - //v3 - protected String modelVersionId; - protected String modelCustomizationId; - - - public String getModelCustomizationName() { - return modelCustomizationName; - } - public void setModelCustomizationName(String modelCustomizationName) { - this.modelCustomizationName = modelCustomizationName; - } - public String getModelNameVersionId() { - return modelNameVersionId; - } - public void setModelNameVersionId(String modelNameVersionId) { - this.modelNameVersionId = modelNameVersionId; - } - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - public String getModelVersion() { - return modelVersion; - } - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - public ModelType getModelType() { - return modelType; - } - public void setModelType(ModelType modelType) { - this.modelType = modelType; - } - public String getModelInvariantId() { - return modelInvariantId; - } - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - public String getModelCustomizationUuid() { - return modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - public String getModelVersionId() { - return modelVersionId; - } - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - public String getModelCustomizationId() { - return modelCustomizationId; - } - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - @Override - public String toString() { - return "ModelInfo [modelCustomizationName=" + modelCustomizationName - + ", modelInvariantId=" + modelInvariantId + ", modelType=" - + modelType + ", modelNameVersionId=" + modelNameVersionId - + ", modelName=" + modelName + ", modelVersion=" + modelVersion - + ", modelCustomizationUuid=" + modelCustomizationUuid - + ", modelVersionId=" + modelVersionId - + ", modelCustomizationId=" + modelCustomizationId + "]"; - } - - +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.7
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2016.03.30 at 02:48:23 PM CDT
+//
+
+
+package org.openecomp.mso.apihandlerinfra.serviceinstancebeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import org.openecomp.mso.apihandlerinfra.ModelType;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class ModelInfo {
+
+ protected String modelCustomizationName;
+ protected String modelInvariantId;
+ protected ModelType modelType;
+ //v2
+ protected String modelNameVersionId;
+ protected String modelName;
+ protected String modelVersion;
+ protected String modelCustomizationUuid;
+ //v3
+ protected String modelVersionId;
+ protected String modelCustomizationId;
+
+
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+ public String getModelNameVersionId() {
+ return modelNameVersionId;
+ }
+ public void setModelNameVersionId(String modelNameVersionId) {
+ this.modelNameVersionId = modelNameVersionId;
+ }
+ public String getModelName() {
+ return modelName;
+ }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+ public String getModelVersion() {
+ return modelVersion;
+ }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+ public ModelType getModelType() {
+ return modelType;
+ }
+ public void setModelType(ModelType modelType) {
+ this.modelType = modelType;
+ }
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+ public String getModelCustomizationUuid() {
+ return modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+ @Override
+ public String toString() {
+ return "ModelInfo [modelCustomizationName=" + modelCustomizationName
+ + ", modelInvariantId=" + modelInvariantId + ", modelType="
+ + modelType + ", modelNameVersionId=" + modelNameVersionId
+ + ", modelName=" + modelName + ", modelVersion=" + modelVersion
+ + ", modelCustomizationUuid=" + modelCustomizationUuid
+ + ", modelVersionId=" + modelVersionId
+ + ", modelCustomizationId=" + modelCustomizationId + "]";
+ }
+
+
}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java index b60d4b6..2ae5dc8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java @@ -1,42 +1,42 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.serviceinstancebeans; - -public class RelatedInstanceList { - - protected RelatedInstance relatedInstance; - - public RelatedInstance getRelatedInstance() { - return relatedInstance; - } - - public void setRelatedInstance(RelatedInstance relatedInstance) { - this.relatedInstance = relatedInstance; - } - - @Override - public String toString() { - return "RelatedInstanceList [relatedInstance=" + relatedInstance + "]"; - } - - - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.serviceinstancebeans;
+
+public class RelatedInstanceList {
+
+ protected RelatedInstance relatedInstance;
+
+ public RelatedInstance getRelatedInstance() {
+ return relatedInstance;
+ }
+
+ public void setRelatedInstance(RelatedInstance relatedInstance) {
+ this.relatedInstance = relatedInstance;
+ }
+
+ @Override
+ public String toString() {
+ return "RelatedInstanceList [relatedInstance=" + relatedInstance + "]";
+ }
+
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java index bb1fa3b..512b061 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java @@ -1,176 +1,176 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.serviceinstancebeans; - -import java.util.Arrays; - -import org.codehaus.jackson.map.annotate.JsonRootName; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonRootName(value = "requestDetails") -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class RequestDetails { - - protected ModelInfo modelInfo; - protected RequestInfo requestInfo; - protected RelatedInstanceList[] relatedInstanceList; - protected SubscriberInfo subscriberInfo; - protected CloudConfiguration cloudConfiguration; - protected RequestParameters requestParameters; - - /** - * Gets the value of the serviceInfo property. - * - * @return - * possible object is - * {@link ModelInfo } - * - */ - public ModelInfo getModelInfo() { - return modelInfo; - } - - /** - * Sets the value of the serviceInfo property. - * - * @param value - * allowed object is - * {@link ModelInfo } - * - */ - public void setModelInfo(ModelInfo value) { - this.modelInfo = value; - } - - /** - * 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 subscriberInfo property. - * - * @return - * possible object is - * {@link SubscriberInfo } - * - */ - public SubscriberInfo getSubscriberInfo() { - return subscriberInfo; - } - - /** - * Sets the value of the subscriberInfo property. - * - * @param value - * allowed object is - * {@link SubscriberInfo } - * - */ - public void setSubscriberInfo(SubscriberInfo value) { - this.subscriberInfo = value; - } - - /** - * Gets the value of the cloudConfiguration property. - * - * @return - * possible object is - * {@link CloudConfiguration } - * - */ - public CloudConfiguration getCloudConfiguration() { - return cloudConfiguration; - } - - /** - * Sets the value of the cloudConfiguration property. - * - * @param value - * allowed object is - * {@link CloudConfiguration } - * - */ - public void setCloudConfiguration(CloudConfiguration value) { - this.cloudConfiguration = value; - } - - /** - * Gets the value of the requestParameters property. - * - * @return - * possible object is - * {@link RequestParameters } - * - */ - public RequestParameters getRequestParameters() { - return requestParameters; - } - - /** - * Sets the value of the requestParameters property. - * - * @param value - * allowed object is - * {@link RequestParameters } - * - */ - public void setRequestParameters(RequestParameters value) { - this.requestParameters = value; - } - - public RelatedInstanceList[] getRelatedInstanceList() { - return relatedInstanceList; - } - - public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { - this.relatedInstanceList = relatedInstanceList; - } - - @Override - public String toString() { - return "RequestDetails [modelInfo=" + modelInfo + ", requestInfo=" - + requestInfo + ", relatedInstanceList=" - + Arrays.toString(relatedInstanceList) + ", subscriberInfo=" - + subscriberInfo + ", cloudConfiguration=" + cloudConfiguration - + ", requestParameters=" + requestParameters + "]"; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.serviceinstancebeans;
+
+import java.util.Arrays;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonRootName(value = "requestDetails")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestDetails {
+
+ protected ModelInfo modelInfo;
+ protected RequestInfo requestInfo;
+ protected RelatedInstanceList[] relatedInstanceList;
+ protected SubscriberInfo subscriberInfo;
+ protected CloudConfiguration cloudConfiguration;
+ protected RequestParameters requestParameters;
+
+ /**
+ * Gets the value of the serviceInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link ModelInfo }
+ *
+ */
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * Sets the value of the serviceInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ModelInfo }
+ *
+ */
+ public void setModelInfo(ModelInfo value) {
+ this.modelInfo = value;
+ }
+
+ /**
+ * 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 subscriberInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link SubscriberInfo }
+ *
+ */
+ public SubscriberInfo getSubscriberInfo() {
+ return subscriberInfo;
+ }
+
+ /**
+ * Sets the value of the subscriberInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SubscriberInfo }
+ *
+ */
+ public void setSubscriberInfo(SubscriberInfo value) {
+ this.subscriberInfo = value;
+ }
+
+ /**
+ * Gets the value of the cloudConfiguration property.
+ *
+ * @return
+ * possible object is
+ * {@link CloudConfiguration }
+ *
+ */
+ public CloudConfiguration getCloudConfiguration() {
+ return cloudConfiguration;
+ }
+
+ /**
+ * Sets the value of the cloudConfiguration property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CloudConfiguration }
+ *
+ */
+ public void setCloudConfiguration(CloudConfiguration value) {
+ this.cloudConfiguration = value;
+ }
+
+ /**
+ * Gets the value of the requestParameters property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestParameters }
+ *
+ */
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ /**
+ * Sets the value of the requestParameters property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestParameters }
+ *
+ */
+ public void setRequestParameters(RequestParameters value) {
+ this.requestParameters = value;
+ }
+
+ public RelatedInstanceList[] getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) {
+ this.relatedInstanceList = relatedInstanceList;
+ }
+
+ @Override
+ public String toString() {
+ return "RequestDetails [modelInfo=" + modelInfo + ", requestInfo="
+ + requestInfo + ", relatedInstanceList="
+ + Arrays.toString(relatedInstanceList) + ", subscriberInfo="
+ + subscriberInfo + ", cloudConfiguration=" + cloudConfiguration
+ + ", requestParameters=" + requestParameters + "]";
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java index 89e8075..02ad6e2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java @@ -1,60 +1,60 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.serviceinstancebeans; - -import java.util.Date; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class RequestStatus { - - protected String requestState; - protected String statusMessage; - protected Integer percentProgress; - protected String finishTime; - - - public String getRequestState() { - return requestState; - } - public void setRequestState(String requestState) { - this.requestState = requestState; - } - public String getStatusMessage() { - return statusMessage; - } - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - public Integer getPercentProgress() { - return percentProgress; - } - public void setPercentProgress(Integer percentProgress) { - this.percentProgress = percentProgress; - } - public String getFinishTime() { - return finishTime; - } - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; - } +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.serviceinstancebeans;
+
+import java.util.Date;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestStatus {
+
+ protected String requestState;
+ protected String statusMessage;
+ protected Integer percentProgress;
+ protected String finishTime;
+
+
+ public String getRequestState() {
+ return requestState;
+ }
+ public void setRequestState(String requestState) {
+ this.requestState = requestState;
+ }
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+ public Integer getPercentProgress() {
+ return percentProgress;
+ }
+ public void setPercentProgress(Integer percentProgress) {
+ this.percentProgress = percentProgress;
+ }
+ public String getFinishTime() {
+ return finishTime;
+ }
+ public void setFinishTime(String finishTime) {
+ this.finishTime = finishTime;
+ }
}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java index 97fc496..e81f102 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java @@ -1,85 +1,85 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.serviceinstancebeans; - -import org.codehaus.jackson.map.annotate.JsonSerialize; - -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class SubscriberInfo { - - protected String globalSubscriberId; - protected String subscriberName; - - /** - * Gets the value of the globalSubscriberId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - /** - * Sets the value of the globalSubscriberId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGlobalSubscriberId(String value) { - this.globalSubscriberId = value; - } - - /** - * Gets the value of the subscriberName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSubscriberName() { - return subscriberName; - } - - /** - * Sets the value of the subscriberName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSubscriberName(String value) { - this.subscriberName = value; - } - - @Override - public String toString() { - return "SubscriberInfo [globalSubscriberId=" + globalSubscriberId - + ", subscriberName=" + subscriberName + "]"; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.serviceinstancebeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class SubscriberInfo {
+
+ protected String globalSubscriberId;
+ protected String subscriberName;
+
+ /**
+ * Gets the value of the globalSubscriberId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+
+ /**
+ * Sets the value of the globalSubscriberId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setGlobalSubscriberId(String value) {
+ this.globalSubscriberId = value;
+ }
+
+ /**
+ * Gets the value of the subscriberName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ /**
+ * Sets the value of the subscriberName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSubscriberName(String value) {
+ this.subscriberName = value;
+ }
+
+ @Override
+ public String toString() {
+ return "SubscriberInfo [globalSubscriberId=" + globalSubscriberId
+ + ", subscriberName=" + subscriberName + "]";
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java new file mode 100644 index 0000000..dde7ecf --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.apihandler.common.ValidationException; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; +import org.apache.commons.io.IOUtils; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; + +import java.io.IOException; +import java.util.HashMap; + +import static org.junit.Assert.*; + +public class MsoRequestTest { + + + + @Test + public void testParseOrchestration() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + ObjectMapper mapper = new ObjectMapper(); + String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}"; + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parseOrchestration(sir); + assertEquals(msoRequest.getRequestInfo().getSource(),"VID"); + assertEquals(msoRequest.getRequestInfo().getRequestorId(),"zz9999"); + + } + + @Test(expected = ValidationException.class) + public void testParseOrchestrationFailure() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + ObjectMapper mapper = new ObjectMapper(); + String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\"}}}"; + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parseOrchestration(sir); + + } + + @Test + public void testParseV3VnfCreate() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3VnfCreate.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v3"); + assertEquals(msoRequest.getRequestInfo().getSource(),"VID"); + assertFalse(msoRequest.getALaCarteFlag()); + assertEquals(msoRequest.getReqVersion(),3); + boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertFalse(testIsALaCarteSet); + + } + + @Test(expected = ValidationException.class) + public void testParseV3VolumeGroupFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3VolumeGroupBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test + public void testParseV3UpdateNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3UpdateNetwork.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test(expected = ValidationException.class) + public void testParseV3UpdateNetworkFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3UpdateNetworkBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.updateInstance, "v3"); + + } + + @Test + public void testParseV3DeleteNetwork() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteNetwork.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + } + + @Test + public void testParseV3ServiceInstanceDelete() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON1, requestJSON2; + try { + requestJSON1 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstance.json")); + requestJSON2 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceALaCarte.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON1, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + boolean testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertTrue(testIsALaCarteSet); + assertFalse(msoRequest.getALaCarteFlag()); + sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class); + msoRequest = new MsoRequest ("12345"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + testIsALaCarteSet = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters().isALaCarteSet(); + assertTrue(testIsALaCarteSet); + assertTrue(msoRequest.getALaCarteFlag()); + + } + + @Test(expected = ValidationException.class) + public void testParseV3ServiceInstanceCreateFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON2; + try { + requestJSON2 = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceALaCarte.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON2, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.createInstance, "v3"); + + } + + @Test(expected = ValidationException.class) + public void testParseV3ServiceInstanceDeleteMacroFail() throws JsonParseException, JsonMappingException, IOException, ValidationException{ + String requestJSON; + try { + requestJSON = IOUtils.toString (ClassLoader.class.getResourceAsStream ("/v3DeleteServiceInstanceBad.json")); + + } catch (IOException e) { + fail ("Exception caught"); + e.printStackTrace (); + return; + } + ObjectMapper mapper = new ObjectMapper(); + HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + instanceIdMap.put("serviceInstanceId", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + MsoRequest msoRequest = new MsoRequest ("1234"); + msoRequest.parse(sir, instanceIdMap, Action.deleteInstance, "v3"); + + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml new file mode 100644 index 0000000..4609de0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml @@ -0,0 +1,28 @@ +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="debug" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="debug" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="debug"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties new file mode 100644 index 0000000..4941c55 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logging.properties @@ -0,0 +1,2 @@ +#register SLF4JBridgeHandler as handler for the j.u.l. root logger +handlers = org.slf4j.bridge.SLF4JBridgeHandler diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json new file mode 100644 index 0000000..98610af --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteNetwork.json @@ -0,0 +1,15 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json new file mode 100644 index 0000000..4d1719f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstance.json @@ -0,0 +1,27 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json new file mode 100644 index 0000000..5a93206 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceALaCarte.json @@ -0,0 +1,22 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelName": "Test", + "modelVersion": "1.0" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": true, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json new file mode 100644 index 0000000..dcf47d0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3DeleteServiceInstanceBad.json @@ -0,0 +1,26 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "requestParameters": { + "aLaCarte": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json new file mode 100644 index 0000000..2aef2e7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetwork.json @@ -0,0 +1,39 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelName": "CONTRAIL30_BASIC", + "modelCustomizationName": "CONTRAIL30_BASIC 1", + "modelCustomizationId": "b0ed83ec-b7b4-4c70-91c2-63feeaf8609b" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + + ], + "requestParameters": { + "userParams": [] + + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json new file mode 100644 index 0000000..956d771 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3UpdateNetworkBad.json @@ -0,0 +1,38 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelName": "CONTRAIL30_BASIC", + "modelCustomizationName": "CONTRAIL30_BASIC 1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + + ], + "requestParameters": { + "userParams": [] + + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json new file mode 100644 index 0000000..90fc841 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VnfCreate.json @@ -0,0 +1,41 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelCustomizationName": "vSAMP12 1", + "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTEST103a", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc", + "modelInfo": { + "modelType": "service", + "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "aparent", + "modelVersion": "1.0" + } + } + } + ], + "requestParameters": { + "autoBuildVfModules": true + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json new file mode 100644 index 0000000..526be72 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/v3VolumeGroupBad.json @@ -0,0 +1,27 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelCustomizationName": "vSAMP12 1", + "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTEST103a", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false, + "requestorId": "az2016" + }, + "requestParameters": { + "autoBuildVfModules": true + } + } +} |