summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/externalapi')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java1497
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java642
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java1028
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServlet.java214
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java167
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadata.java198
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/AssetMetadata.java190
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/IAssetMetadata.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadata.java70
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadata.java66
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadata.java72
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadata.java70
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadata.java126
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadata.java42
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadata.java72
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionReqInfo.java23
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfo.java24
17 files changed, 2450 insertions, 2071 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
index 1408459470..70225c0dd2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
@@ -20,26 +20,15 @@
package org.openecomp.sdc.be.externalapi.servlet;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.inject.Singleton;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -56,16 +45,24 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcabi.aspects.Loggable;
-
-import fj.data.Either;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
+import javax.inject.Singleton;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Map;
/**
* This Servlet serves external users operations on artifacts.
*
@@ -78,740 +75,740 @@ import io.swagger.annotations.ApiResponses;
@Singleton
public class ArtifactExternalServlet extends AbstractValidationsServlet {
- @Context
- private HttpServletRequest request;
+ @Context
+ private HttpServletRequest request;
+
+ private static final Logger log = LoggerFactory.getLogger(ArtifactExternalServlet.class);
+
+ private static String startLog = "Start handle request of ";
+
+ /**
+ * Uploads an artifact to resource or service
+ *
+ * @param contenType
+ * @param checksum
+ * @param userId
+ * @param requestId
+ * @param instanceIdHeader
+ * @param accept
+ * @param authorization
+ * @param assetType
+ * @param uuid
+ * @param data
+ * @return
+ */
+ @POST
+ @Path("/{assetType}/{uuid}/artifacts")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "uploads of artifact to a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Artifact name given in input already exists in the context of the asset - SVC4125"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 400, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 400, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")})
+ public Response uploadArtifact(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ String data) {
+
+ init(log);
- private static Logger log = LoggerFactory.getLogger(ArtifactExternalServlet.class.getName());
-
- private static String startLog = "Start handle request of ";
+ Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- /**
- * Uploads an artifact to resource or service
- *
- * @param contenType
- * @param checksum
- * @param userId
- * @param requestId
- * @param instanceIdHeader
- * @param accept
- * @param authorization
- * @param assetType
- * @param uuid
- * @param data
- * @return
- */
- @POST
- @Path("/{assetType}/{uuid}/artifacts")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "uploads of artifact to a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Artifact name given in input already exists in the context of the asset - SVC4125"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 400, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 400, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")
- public Response uploadArtifact(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- String data) {
-
- init(log);
-
- Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
-
- if (componentType == null) {
- log.debug("uploadArtifact: assetType parameter {} is not valid", assetType);
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
- }
- if (responseWrapper.isEmpty()) {
- validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
- }
- if (responseWrapper.isEmpty() ) {
- validateHttpCspUserIdHeader(userId, responseWrapper);
- }
- Response response = null;
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.uploadArtifactToComponentByUUID(data, request, componentType, uuid,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Create));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to upload artifact");
- responseWrapper.setInnerElement(uploadArtifactEither.right().value());
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.OK));
- response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers);
- }
- }
- if( response == null ){
- response = buildErrorResponse(responseWrapper.getInnerElement());
- }
- return response;
- } catch (Exception e) {
- final String message = "failed to upload artifact to a resource or service";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- } finally {
- getComponentsUtils().auditExternalUploadArtifact(responseWrapper.getInnerElement(), componentTypeValue, request, additionalParams);
- }
- }
+ if (componentType == null) {
+ log.debug("uploadArtifact: assetType parameter {} is not valid", assetType);
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
+ }
+ if (responseWrapper.isEmpty()) {
+ validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
+ }
+ if (responseWrapper.isEmpty() ) {
+ validateHttpCspUserIdHeader(userId, responseWrapper);
+ }
+ Response response = null;
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.uploadArtifactToComponentByUUID(data, request, componentType, uuid,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to upload artifact");
+ responseWrapper.setInnerElement(uploadArtifactEither.right().value());
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.OK));
+ response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers);
+ }
+ }
+ if( response == null ){
+ response = buildErrorResponse(responseWrapper.getInnerElement());
+ }
+ return response;
+ } catch (Exception e) {
+ final String message = "failed to upload artifact to a resource or service";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ } finally {
+ getComponentsUtils().auditExternalUploadArtifact(responseWrapper.getInnerElement(), componentTypeValue, request, additionalParams);
+ }
+ }
- /**
- * Uploads an artifact to resource instance
- *
- * @param assetType
- * @param uuid
- * @param resourceInstanceName
- * @return
- */
- @POST
- @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "uploads an artifact to a resource instance", httpMethod = "POST", notes = "uploads an artifact to a resource instance")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Artifact name given in input already exists in the context of the asset - SVC4125"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 400, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 400, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")
- public Response uploadArtifactToInstance(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName,
- String data) {
+ /**
+ * Uploads an artifact to resource instance
+ *
+ * @param assetType
+ * @param uuid
+ * @param resourceInstanceName
+ * @return
+ */
+ @POST
+ @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "uploads an artifact to a resource instance", httpMethod = "POST", notes = "uploads an artifact to a resource instance")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact uploaded", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Artifact name given in input already exists in the context of the asset - SVC4125"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 400, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 400, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")})
+ public Response uploadArtifactToInstance(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName,
+ String data) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
- if (componentType == null) {
- log.debug("uploadArtifact: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("uploadArtifact: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
- log.debug("uploadArtifact: Missing USER_ID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.uploadArtifactToRiByUUID(data, request, componentType, uuid, resourceInstanceName,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Create));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to upload artifact");
- responseFormat = uploadArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
- }
- }
- }catch (Exception e) {
- final String message = "failed to upload artifact to a resource instance";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalUploadArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
+ if (componentType == null) {
+ log.debug("uploadArtifact: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("uploadArtifact: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
+ log.debug("uploadArtifact: Missing USER_ID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.uploadArtifactToRiByUUID(data, request, componentType, uuid, resourceInstanceName,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to upload artifact");
+ responseFormat = uploadArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
+ }
+ }
+ }catch (Exception e) {
+ final String message = "failed to upload artifact to a resource instance";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalUploadArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- *
- * @param contenType
- * @param checksum
- * @param userId
- * @param requestId
- * @param instanceIdHeader
- * @param accept
- * @param authorization
- * @param assetType
- * @param uuid
- * @param artifactUUID
- * @param data
- * @return
- */
- @POST
- @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "updates an artifact on a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")
- public Response updateArtifact(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
- String data) {
+ /**
+ *
+ * @param contenType
+ * @param checksum
+ * @param userId
+ * @param requestId
+ * @param instanceIdHeader
+ * @param accept
+ * @param authorization
+ * @param assetType
+ * @param uuid
+ * @param artifactUUID
+ * @param data
+ * @return
+ */
+ @POST
+ @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "updates an artifact on a resource or service", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")})
+ public Response updateArtifact(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
+ String data) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("updateArtifact: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("updateArtifact: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
- log.debug("updateArtifact: Missing USER_ID");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.updateArtifactOnComponentByUUID(data, request, componentType, uuid, artifactUUID,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Update));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to update artifact");
- responseFormat = uploadArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to update artifact on a resource or service";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalUpdateArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("updateArtifact: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("updateArtifact: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
+ log.debug("updateArtifact: Missing USER_ID");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.updateArtifactOnComponentByUUID(data, request, componentType, uuid, artifactUUID,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to update artifact");
+ responseFormat = uploadArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to update artifact on a resource or service";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalUpdateArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- * updates an artifact on a resource instance
- *
- * @param assetType
- * @param uuid
- * @param resourceInstanceName
- * @param artifactUUID
- * @return
- */
- @POST
- @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "updates an artifact on a resource instance", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")
- public Response updateArtifactOnResourceInstance(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
- @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName,
- String data) {
+ /**
+ * updates an artifact on a resource instance
+ *
+ * @param assetType
+ * @param uuid
+ * @param resourceInstanceName
+ * @param artifactUUID
+ * @return
+ */
+ @POST
+ @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "updates an artifact on a resource instance", httpMethod = "POST", notes = "uploads of artifact to a resource or service")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact updated", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.ArtifactDefinition", paramType = "body", value = "json describe the artifact")})
+ public Response updateArtifactOnResourceInstance(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The value for this header must be the MD5 checksum over the whole json body", required = true)@HeaderParam(value = Constants.MD5_HEADER) String checksum,
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
+ @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName,
+ String data) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("updateArtifactOnResourceInstance: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("updateArtifactOnResourceInstance: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
- log.debug("updateArtifactOnResourceInstance: Missing USER_ID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.updateArtifactOnRiByUUID(data, request, componentType, uuid, resourceInstanceName, artifactUUID,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Update));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to update artifact");
- responseFormat = uploadArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to update artifact on resource instance";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalUpdateArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("updateArtifactOnResourceInstance: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("updateArtifactOnResourceInstance: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
+ log.debug("updateArtifactOnResourceInstance: Missing USER_ID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.updateArtifactOnRiByUUID(data, request, componentType, uuid, resourceInstanceName, artifactUUID,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to update artifact");
+ responseFormat = uploadArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to update artifact on resource instance";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalUpdateArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- * deletes an artifact of a resource or service
- *
- * @param assetType
- * @param uuid
- * @param artifactUUID
- * @return
- */
- @DELETE
- @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "deletes an artifact of a resource or service", httpMethod = "DELETE", notes = "deletes an artifact of a resource or service", response = Response.class)
- /*@ApiResponses(value = { @ApiResponse(code = 200, message = "Artifact Deleted"), @ApiResponse(code = 401, message = "Authorization required"), @ApiResponse(code = 403, message = "Restricted operation"),
- @ApiResponse(code = 404, message = "Asset not found") })*/
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- public Response deleteArtifact(
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID) {
+ /**
+ * deletes an artifact of a resource or service
+ *
+ * @param assetType
+ * @param uuid
+ * @param artifactUUID
+ * @return
+ */
+ @DELETE
+ @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "deletes an artifact of a resource or service", httpMethod = "DELETE", notes = "deletes an artifact of a resource or service", response = Response.class)
+ /*@ApiResponses(value = { @ApiResponse(code = 200, message = "Artifact Deleted"), @ApiResponse(code = 401, message = "Authorization required"), @ApiResponse(code = 403, message = "Restricted operation"),
+ @ApiResponse(code = 404, message = "Asset not found") })*/
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ public Response deleteArtifact(
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("deleteArtifact: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("deleteArtifact: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
- log.debug("deleteArtifact: Missing USER_ID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.deleteArtifactOnComponentByUUID(request, componentType, uuid, artifactUUID,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Delete));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to delete artifact");
- responseFormat = uploadArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to delete an artifact of a resource or service";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalDeleteArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("deleteArtifact: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("deleteArtifact: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
+ log.debug("deleteArtifact: Missing USER_ID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.deleteArtifactOnComponentByUUID(request, componentType, uuid, artifactUUID,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to delete artifact");
+ responseFormat = uploadArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to delete an artifact of a resource or service";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalDeleteArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- * deletes an artifact of a resource instance
- *
- * @param assetType
- * @param uuid
- * @param resourceInstanceName
- * @return
- */
- @DELETE
- @Path("{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "deletes an artifact of a resource insatnce", httpMethod = "DELETE", notes = "deletes an artifact of a resource insatnce", response = Response.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
- @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
- @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
- @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
- @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
- @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
- public Response deleteArtifactOnResourceInstance(
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
- @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName) {
+ /**
+ * deletes an artifact of a resource instance
+ *
+ * @param assetType
+ * @param uuid
+ * @param resourceInstanceName
+ * @return
+ */
+ @DELETE
+ @Path("{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "deletes an artifact of a resource insatnce", httpMethod = "DELETE", notes = "deletes an artifact of a resource insatnce", response = Response.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid artifactType was defined as input - SVC4122"),
+ @ApiResponse(code = 400, message = "Artifact type (mandatory field) is missing in request - SVC4124"),
+ @ApiResponse(code = 400, message = "Invalid MD5 header - SVC4127"),
+ @ApiResponse(code = 400, message = "Artifact name is missing in input - SVC4128"),
+ @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4086"),
+ @ApiResponse(code = 409, message = "Restricted Operation – the user provided does not have role of Designer or the asset is being used by another designer - SVC4301")})
+ public Response deleteArtifactOnResourceInstance(
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
+ @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("deleteArtifactOnResourceInsatnce: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("deleteArtifactOnResourceInsatnce: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
- log.debug("deleteArtifactOnResourceInsatnce: Missing USER_ID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.deleteArtifactOnRiByUUID(request, componentType, uuid, resourceInstanceName, artifactUUID,
- additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.Delete));
- if (uploadArtifactEither.isRight()) {
- log.debug("failed to delete artifact");
- responseFormat = uploadArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to delete an artifact of a resource instance";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalDeleteArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("deleteArtifactOnResourceInsatnce: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("deleteArtifactOnResourceInsatnce: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (userId == null || userId.isEmpty())) {
+ log.debug("deleteArtifactOnResourceInsatnce: Missing USER_ID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_USER_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsLogic.deleteArtifactOnRiByUUID(request, componentType, uuid, resourceInstanceName, artifactUUID,
+ additionalParams, artifactsLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
+ if (uploadArtifactEither.isRight()) {
+ log.debug("failed to delete artifact");
+ responseFormat = uploadArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ Object representation = RepresentationUtils.toRepresentation(uploadArtifactEither.left().value());
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), representation, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to delete an artifact of a resource instance";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalDeleteArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- * downloads an artifact of a component (either a service or a resource) by artifactUUID
- *
- * @param assetType
- * @param uuid
- * @param artifactUUID
- * @return
- */
- @GET
- @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_OCTET_STREAM)
- @ApiOperation(value = "Download component artifact", httpMethod = "GET", notes = "Returns downloaded artifact")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 404, message = "Artifact was not found - SVC4505")})
- public Response downloadComponentArtifact(
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID) {
+ /**
+ * downloads an artifact of a component (either a service or a resource) by artifactUUID
+ *
+ * @param assetType
+ * @param uuid
+ * @param artifactUUID
+ * @return
+ */
+ @GET
+ @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ @ApiOperation(value = "Download component artifact", httpMethod = "GET", notes = "Returns downloaded artifact")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 404, message = "Artifact was not found - SVC4505")})
+ public Response downloadComponentArtifact(
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("downloadComponentArtifact: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("downloadComponentArtifact: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<byte[], ResponseFormat> downloadComponentArtifactEither = artifactsLogic.downloadComponentArtifactByUUIDs(componentType, uuid, artifactUUID, additionalParams);
- if (downloadComponentArtifactEither.isRight()) {
- responseFormat = downloadComponentArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- byte[] value = downloadComponentArtifactEither.left().value();
- InputStream is = new ByteArrayInputStream(value);
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to download an artifact of a resource or service";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalDownloadArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("downloadComponentArtifact: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("downloadComponentArtifact: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<byte[], ResponseFormat> downloadComponentArtifactEither = artifactsLogic.downloadComponentArtifactByUUIDs(componentType, uuid, artifactUUID, additionalParams);
+ if (downloadComponentArtifactEither.isRight()) {
+ responseFormat = downloadComponentArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ byte[] value = downloadComponentArtifactEither.left().value();
+ InputStream is = new ByteArrayInputStream(value);
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to download an artifact of a resource or service";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalDownloadArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
- /**
- * downloads an artifact of a resource instance of a component (either a service or a resource) by artifactUUID
- *
- * @param assetType
- * @param uuid
- * @param resourceInstanceName
- * @param artifactUUID
- * @return
- */
- @GET
- @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
- @Produces(MediaType.APPLICATION_OCTET_STREAM)
- @ApiOperation(nickname = "downloadResourceInstanceArtifactByUUID",value = "Download resource instance artifact by artifact UUID", httpMethod = "GET", notes = "Returns downloaded artifact", response = Response.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 404, message = "Artifact was not found - SVC4505")})
- public Response downloadResourceInstanceArtifact(
- @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
- @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
- @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName) {
+ /**
+ * downloads an artifact of a resource instance of a component (either a service or a resource) by artifactUUID
+ *
+ * @param assetType
+ * @param uuid
+ * @param resourceInstanceName
+ * @param artifactUUID
+ * @return
+ */
+ @GET
+ @Path("/{assetType}/{uuid}/resourceInstances/{resourceInstanceName}/artifacts/{artifactUUID}")
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ @ApiOperation(value = "Download resource instance artifact", httpMethod = "GET", notes = "Returns downloaded artifact", response = Response.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Artifact downloaded", response = String.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Specified resource is not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed: Invalid HTTP method type used (PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 404, message = "Artifact was not found - SVC4505")})
+ public Response downloadResourceInstanceArtifact(
+ @ApiParam(value = "The user ID of the DCAE Designer. This user must also have Designer role in SDC", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The uuid of the asset as published in the metadata", required = true)@PathParam("uuid") final String uuid,
+ @ApiParam(value = "The uuid of the artifact as published in the asset detailed metadata or in the response of the upload / update operation", required = true)@PathParam("artifactUUID") final String artifactUUID,
+ @ApiParam(value = "The component instance name (as publishedin the response of the detailed query)", required = true)@PathParam("resourceInstanceName") final String resourceInstanceName) {
- Wrapper<Response> responseWrapper = new Wrapper<>();
- ResponseFormat responseFormat = null;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- String componentTypeValue = componentType == null ? null : componentType.getValue();
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
- if (componentType == null) {
- log.debug("downloadResourceInstanceArtifact: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
- log.debug("downloadResourceInstanceArtifact: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- }
- try {
- if (responseWrapper.isEmpty()) {
- ServletContext context = request.getSession().getServletContext();
- ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
- Either<byte[], ResponseFormat> downloadResourceArtifactEither = artifactsLogic.downloadResourceInstanceArtifactByUUIDs(componentType, uuid, resourceInstanceName, artifactUUID, additionalParams);
- if (downloadResourceArtifactEither.isRight()) {
- responseFormat = downloadResourceArtifactEither.right().value();
- responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
- } else {
- byte[] value = downloadResourceArtifactEither.left().value();
- InputStream is = new ByteArrayInputStream(value);
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
- }
- }
- } catch (Exception e) {
- final String message = "failed to download an artifact of a resource instance";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
- } finally {
- getComponentsUtils().auditExternalDownloadArtifact(responseFormat, componentTypeValue, request, additionalParams);
- }
- return responseWrapper.getInnerElement();
- }
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("{} {}", startLog, url);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ String componentTypeValue = componentType == null ? null : componentType.getValue();
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInstanceName);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_CURR_ARTIFACT_UUID, artifactUUID);
+ if (componentType == null) {
+ log.debug("downloadResourceInstanceArtifact: assetType parameter {} is not valid", assetType);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ if (responseWrapper.isEmpty() && (instanceIdHeader == null || instanceIdHeader.isEmpty())) {
+ log.debug("downloadResourceInstanceArtifact: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ }
+ try {
+ if (responseWrapper.isEmpty()) {
+ ServletContext context = request.getSession().getServletContext();
+ ArtifactsBusinessLogic artifactsLogic = getArtifactBL(context);
+ Either<byte[], ResponseFormat> downloadResourceArtifactEither = artifactsLogic.downloadResourceInstanceArtifactByUUIDs(componentType, uuid, resourceInstanceName, artifactUUID, additionalParams);
+ if (downloadResourceArtifactEither.isRight()) {
+ responseFormat = downloadResourceArtifactEither.right().value();
+ responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
+ } else {
+ byte[] value = downloadResourceArtifactEither.left().value();
+ InputStream is = new ByteArrayInputStream(value);
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
+ }
+ }
+ } catch (Exception e) {
+ final String message = "failed to download an artifact of a resource instance";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ responseWrapper.setInnerElement(buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)));
+ } finally {
+ getComponentsUtils().auditExternalDownloadArtifact(responseFormat, componentTypeValue, request, additionalParams);
+ }
+ return responseWrapper.getInnerElement();
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
index b9956063d6..27f82dfda3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
@@ -20,26 +20,9 @@
package org.openecomp.sdc.be.externalapi.servlet;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Singleton;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-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 com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.annotations.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
@@ -61,14 +44,19 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcabi.aspects.Loggable;
-
-import fj.data.Either;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import javax.inject.Singleton;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* This Servlet serves external users for retrieving component metadata.
@@ -83,311 +71,299 @@ import io.swagger.annotations.ApiResponses;
@Singleton
public class AssetsDataServlet extends AbstractValidationsServlet {
- @Context
- private HttpServletRequest request;
-
- private static Logger log = LoggerFactory.getLogger(AssetsDataServlet.class.getName());
-
- /**
- *
- * @param requestId
- * @param instanceIdHeader
- * @param accept
- * @param authorization
- * @param assetType
- * @param category
- * @param subCategory
- * @param distributionStatus
- * @param resourceType
- * @return
- */
- @GET
- @Path("/{assetType}")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Fetch list of assets", httpMethod = "GET", notes = "Returns list of assets")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
- public Response getAssetListExternal(
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("category") String category,
- @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("subCategory") String subCategory,
- @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("distributionStatus") String distributionStatus,
- @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("resourceType") String resourceType) {
-
- Response response = null;
- ResponseFormat responseFormat = null;
- String query = request.getQueryString();
- String requestURI = request.getRequestURI().endsWith("/")?
- removeDuplicateSlashSeparator(request.getRequestURI()): request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("Start handle request of {}", url);
-
- AuditingActionEnum auditingActionEnum = query == null ? AuditingActionEnum.GET_ASSET_LIST : AuditingActionEnum.GET_FILTERED_ASSET_LIST;
-
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(AuditingFieldsKeysEnum.class);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, query == null ? requestURI : requestURI + "?" + query);
-
- // Mandatory
- if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
- log.debug("getAssetList: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
-
- try {
- ServletContext context = request.getSession().getServletContext();
- ElementBusinessLogic elementLogic = getElementBL(context);
-
- AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
- Map<FilterKeyEnum, String> filters = new EnumMap<>(FilterKeyEnum.class);
-
- if (category != null) {
- filters.put(FilterKeyEnum.CATEGORY, category);
- }
- if (subCategory != null) {
- filters.put(FilterKeyEnum.SUB_CATEGORY, subCategory);
- }
- if (distributionStatus != null) {
- filters.put(FilterKeyEnum.DISTRIBUTION_STATUS, distributionStatus);
- }
- if (resourceType != null) {
- ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.getTypeIgnoreCase(resourceType);
- if (resourceTypeEnum == null) {
- log.debug("getAssetList: Asset Fetching Failed. Invalid resource type was received");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
- filters.put(FilterKeyEnum.RESOURCE_TYPE, resourceTypeEnum.name());
- }
-
- Either<List<? extends Component>, ResponseFormat> assetTypeData = elementLogic.getFilteredCatalogComponents(assetType, filters, query);
-
- if (assetTypeData.isRight()) {
- log.debug("getAssetList: Asset Fetching Failed");
- responseFormat = assetTypeData.right().value();
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- } else {
- log.debug("getAssetList: Asset Fetching Success");
- Either<List<? extends AssetMetadata>, ResponseFormat> resMetadata = assetMetadataUtils.convertToAssetMetadata(assetTypeData.left().value(), requestURI, false);
- if (resMetadata.isRight()) {
- log.debug("getAssetList: Asset conversion Failed");
- responseFormat = resMetadata.right().value();
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
- Object result = RepresentationUtils.toRepresentation(resMetadata.left().value());
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
-
- response = buildOkResponse(responseFormat, result);
- return response;
- }
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Fetch filtered list of assets");
- log.debug("getAssetList: Fetch list of assets failed with exception", e);
- return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
- }
-
- /**
- *
- * @param requestId
- * @param instanceIdHeader
- * @param accept
- * @param authorization
- * @param assetType
- * @param uuid
- * @return
- */
- @GET
- @Path("/{assetType}/{uuid}/metadata")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Detailed metadata of asset by uuid", httpMethod = "GET", notes = "Returns detailed metadata of an asset by uuid")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
- public Response getAssetSpecificMetadataByUuidExternal(
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The requested asset uuid", required = true)@PathParam("uuid") final String uuid) {
-
- Response response = null;
- ResponseFormat responseFormat = null;
- AuditingActionEnum auditingActionEnum = AuditingActionEnum.GET_ASSET_METADATA;
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("Start handle request of {}", url);
-
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<>(AuditingFieldsKeysEnum.class);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, requestURI);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, uuid);
- if (componentType == null) {
- log.debug("getMetaData: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- return buildErrorResponse(responseFormat);
- }
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE, componentType.getValue());
-
- // Mandatory
- if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
- log.debug("getAssetList: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
-
- try {
- ServletContext context = request.getSession().getServletContext();
- ElementBusinessLogic elementLogic = getElementBL(context);
- AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
-
- Either<List<? extends Component>, ResponseFormat> assetTypeData = elementLogic.getCatalogComponentsByUuidAndAssetType(assetType, uuid);
-
- if (assetTypeData.isRight()) {
- log.debug("getAssetList: Asset Fetching Failed");
- responseFormat = assetTypeData.right().value();
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
-
- return buildErrorResponse(responseFormat);
- } else {
- log.debug("getAssetList: Asset Fetching Success");
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, assetTypeData.left().value().iterator().next().getName());
- Either<List<? extends AssetMetadata>, ResponseFormat> resMetadata = assetMetadataUtils.convertToAssetMetadata(assetTypeData.left().value(), requestURI, true);
- if (resMetadata.isRight()) {
- log.debug("getAssetList: Asset conversion Failed");
- responseFormat = resMetadata.right().value();
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
- Object result = RepresentationUtils.toRepresentation(resMetadata.left().value().iterator().next());
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
-
- response = buildOkResponse(responseFormat, result);
- return response;
- }
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Fetch filtered list of assets");
- log.debug("getAssetList: Fetch list of assets failed with exception", e);
- return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
- }
-
- /**
- *
- * @param requestId
- * @param instanceIdHeader
- * @param accept
- * @param authorization
- * @param assetType
- * @param uuid
- * @return
- */
- @GET
- @Path("/{assetType}/{uuid}/toscaModel")
- @Produces(MediaType.APPLICATION_OCTET_STREAM)
- @ApiOperation(value = "Fetch assets CSAR", httpMethod = "GET", notes = "Returns asset csar", response = String.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = String.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
- public Response getToscaModelExternal(
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- @ApiParam(value = "The requested asset uuid", required = true)@PathParam("uuid") final String uuid) {
-
- String url = request.getRequestURI();
- log.debug("Start handle request of {} {}", request.getMethod(), url);
- Response response = null;
- ResponseFormat responseFormat = null;
- ServletContext context = request.getSession().getServletContext();
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- AuditingActionEnum auditingActionEnum = AuditingActionEnum.GET_TOSCA_MODEL;
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(AuditingFieldsKeysEnum.class);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, url);
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, uuid);
-
- if (componentType == null) {
- log.debug("getToscaModel: assetType parameter {} is not valid", assetType);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- return buildErrorResponse(responseFormat);
- }
- additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE, componentType.getValue());
-
-
- if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
- log.debug("getToscaModel: Missing X-ECOMP-InstanceID header");
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return buildErrorResponse(responseFormat);
- }
-
- try {
- ComponentBusinessLogic componentBL = getComponentBL(componentType, context);
-
- Either<ImmutablePair<String, byte[]>, ResponseFormat> csarArtifact = componentBL.getToscaModelByComponentUuid(componentType, uuid, additionalParam);
- if (csarArtifact.isRight()) {
- responseFormat = csarArtifact.right().value();
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- response = buildErrorResponse(responseFormat);
- } else {
- byte[] value = csarArtifact.left().value().getRight();
- InputStream is = new ByteArrayInputStream(value);
- String contenetMD5 = GeneralUtility.calculateMD5Base64EncodedByByteArray(value);
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.CONTENT_DISPOSITION_HEADER, getContentDispositionValue(csarArtifact.left().value().getLeft()));
- headers.put(Constants.MD5_HEADER, contenetMD5);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- response = buildOkResponse(responseFormat, is, headers);
- }
- return response;
-
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get asset tosca model");
- log.debug("falied to get asset tosca model", e);
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
- response = buildErrorResponse(responseFormat);
- getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
- return response;
- }
- }
-
-
- private String removeDuplicateSlashSeparator(String requestUri) {
- return requestUri.substring(0, requestUri.length()-1);
- }
+ @Context
+ private HttpServletRequest request;
+
+ private static final Logger log = LoggerFactory.getLogger(AssetsDataServlet.class);
+
+ /**
+ *
+ * @param requestId
+ * @param instanceIdHeader
+ * @param accept
+ * @param authorization
+ * @param assetType
+ * @param category
+ * @param subCategory
+ * @param distributionStatus
+ * @param resourceType
+ * @return
+ */
+ @GET
+ @Path("/{assetType}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Fetch list of assets", httpMethod = "GET", notes = "Returns list of assets")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
+ public Response getAssetListExternal(
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("category") String category,
+ @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("subCategory") String subCategory,
+ @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("distributionStatus") String distributionStatus,
+ @ApiParam(value = "The filter key (resourceType only for resources)", required = false)@QueryParam("resourceType") String resourceType) {
+
+ Response response = null;
+ ResponseFormat responseFormat = null;
+ String query = request.getQueryString();
+ String requestURI = request.getRequestURI().endsWith("/")?
+ removeDuplicateSlashSeparator(request.getRequestURI()): request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("Start handle request of {}", url);
+
+ AuditingActionEnum auditingActionEnum = query == null ? AuditingActionEnum.GET_ASSET_LIST : AuditingActionEnum.GET_FILTERED_ASSET_LIST;
+
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(AuditingFieldsKeysEnum.class);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, query == null ? requestURI : requestURI + "?" + query);
+
+ // Mandatory
+ if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
+ log.debug("getAssetList: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+
+ try {
+ ServletContext context = request.getSession().getServletContext();
+ ElementBusinessLogic elementLogic = getElementBL(context);
+
+ AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
+ Map<FilterKeyEnum, String> filters = new EnumMap<>(FilterKeyEnum.class);
+
+ if (category != null) {
+ filters.put(FilterKeyEnum.CATEGORY, category);
+ }
+ if (subCategory != null) {
+ filters.put(FilterKeyEnum.SUB_CATEGORY, subCategory);
+ }
+ if (distributionStatus != null) {
+ filters.put(FilterKeyEnum.DISTRIBUTION_STATUS, distributionStatus);
+ }
+ if (resourceType != null) {
+ ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.getTypeIgnoreCase(resourceType);
+ if (resourceTypeEnum == null) {
+ log.debug("getAssetList: Asset Fetching Failed. Invalid resource type was received");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+ filters.put(FilterKeyEnum.RESOURCE_TYPE, resourceTypeEnum.name());
+ }
+
+ Either<List<? extends Component>, ResponseFormat> assetTypeData = elementLogic.getFilteredCatalogComponents(assetType, filters, query);
+
+ if (assetTypeData.isRight()) {
+ log.debug("getAssetList: Asset Fetching Failed");
+ responseFormat = assetTypeData.right().value();
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ } else {
+ log.debug("getAssetList: Asset Fetching Success");
+ Either<List<? extends AssetMetadata>, ResponseFormat> resMetadata = assetMetadataUtils.convertToAssetMetadata(assetTypeData.left().value(), requestURI, false);
+ if (resMetadata.isRight()) {
+ log.debug("getAssetList: Asset conversion Failed");
+ responseFormat = resMetadata.right().value();
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+ Object result = RepresentationUtils.toRepresentation(resMetadata.left().value());
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+
+ response = buildOkResponse(responseFormat, result);
+ return response;
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Fetch filtered list of assets");
+ log.debug("getAssetList: Fetch list of assets failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
+ /**
+ *
+ * @param requestId
+ * @param instanceIdHeader
+ * @param accept
+ * @param authorization
+ * @param assetType
+ * @param uuid
+ * @return
+ */
+ @GET
+ @Path("/{assetType}/{uuid}/metadata")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Detailed metadata of asset by uuid", httpMethod = "GET", notes = "Returns detailed metadata of an asset by uuid")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = AssetMetadata.class, responseContainer="List"),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
+ public Response getAssetSpecificMetadataByUuidExternal(
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The requested asset uuid", required = true)@PathParam("uuid") final String uuid) {
+
+ Response response = null;
+ ResponseFormat responseFormat = null;
+ AuditingActionEnum auditingActionEnum = AuditingActionEnum.GET_ASSET_METADATA;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("Start handle request of {}", url);
+
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, requestURI);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE, componentType.getValue());
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, uuid);
+
+ // Mandatory
+ if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
+ log.debug("getAssetList: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+
+ try {
+ ServletContext context = request.getSession().getServletContext();
+ ElementBusinessLogic elementLogic = getElementBL(context);
+ AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
+
+ Either<List<? extends Component>, ResponseFormat> assetTypeData = elementLogic.getCatalogComponentsByUuidAndAssetType(assetType, uuid);
+
+ if (assetTypeData.isRight()) {
+ log.debug("getAssetList: Asset Fetching Failed");
+ responseFormat = assetTypeData.right().value();
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+
+ return buildErrorResponse(responseFormat);
+ } else {
+ log.debug("getAssetList: Asset Fetching Success");
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, assetTypeData.left().value().iterator().next().getName());
+ Either<List<? extends AssetMetadata>, ResponseFormat> resMetadata = assetMetadataUtils.convertToAssetMetadata(assetTypeData.left().value(), requestURI, true);
+ if (resMetadata.isRight()) {
+ log.debug("getAssetList: Asset conversion Failed");
+ responseFormat = resMetadata.right().value();
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+ Object result = RepresentationUtils.toRepresentation(resMetadata.left().value().iterator().next());
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+
+ response = buildOkResponse(responseFormat, result);
+ return response;
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Fetch filtered list of assets");
+ log.debug("getAssetList: Fetch list of assets failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
+ /**
+ *
+ * @param requestId
+ * @param instanceIdHeader
+ * @param accept
+ * @param authorization
+ * @param assetType
+ * @param uuid
+ * @return
+ */
+ @GET
+ @Path("/{assetType}/{uuid}/toscaModel")
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ @ApiOperation(value = "Fetch assets CSAR", httpMethod = "GET", notes = "Returns asset csar", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Catalog Assets Metadata is returned", response = String.class),
+ @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000")})
+ public Response getToscaModelExternal(
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ @ApiParam(value = "The requested asset uuid", required = true)@PathParam("uuid") final String uuid) {
+
+ String url = request.getRequestURI();
+ log.debug("Start handle request of {} {}", request.getMethod(), url);
+ Response response = null;
+ ResponseFormat responseFormat = null;
+ ServletContext context = request.getSession().getServletContext();
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ AuditingActionEnum auditingActionEnum = AuditingActionEnum.GET_TOSCA_MODEL;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(AuditingFieldsKeysEnum.class);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL, url);
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_TYPE, componentType.getValue());
+ additionalParam.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, uuid);
+
+ if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
+ log.debug("getToscaModel: Missing X-ECOMP-InstanceID header");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return buildErrorResponse(responseFormat);
+ }
+
+ try {
+ ComponentBusinessLogic componentBL = getComponentBL(componentType, context);
+
+ Either<ImmutablePair<String, byte[]>, ResponseFormat> csarArtifact = componentBL.getToscaModelByComponentUuid(componentType, uuid, additionalParam);
+ if (csarArtifact.isRight()) {
+ responseFormat = csarArtifact.right().value();
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ response = buildErrorResponse(responseFormat);
+ } else {
+ byte[] value = csarArtifact.left().value().getRight();
+ InputStream is = new ByteArrayInputStream(value);
+ String contenetMD5 = GeneralUtility.calculateMD5Base64EncodedByByteArray(value);
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.CONTENT_DISPOSITION_HEADER, getContentDispositionValue(csarArtifact.left().value().getLeft()));
+ headers.put(Constants.MD5_HEADER, contenetMD5);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ response = buildOkResponse(responseFormat, is, headers);
+ }
+ return response;
+
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get asset tosca model");
+ log.debug("falied to get asset tosca model", e);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
+ response = buildErrorResponse(responseFormat);
+ getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
+ return response;
+ }
+ }
+
+
+ private String removeDuplicateSlashSeparator(String requestUri) {
+ return requestUri.substring(0, requestUri.length()-1);
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
index 18422f53a1..0651291fc4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
@@ -20,30 +20,11 @@
package org.openecomp.sdc.be.externalapi.servlet;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import javax.inject.Singleton;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.common.Strings;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@@ -62,11 +43,7 @@ import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
import org.openecomp.sdc.be.externalapi.servlet.representation.AssetMetadata;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
@@ -82,508 +59,509 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcabi.aspects.Loggable;
-
-import fj.data.Either;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import javax.inject.Singleton;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
@Api(value = "CRUD External Servlet", description = "This Servlet serves external users for creating assets and changing their lifecycle state")
@Singleton
public class CrudExternalServlet extends AbstractValidationsServlet {
-
- @Context
- private HttpServletRequest request;
-
- private static Logger log = LoggerFactory.getLogger(CrudExternalServlet.class.getName());
-
- /**
- * Creates a new Resource
- *
- * @param assetType
- * @param data
- * @param userId
- * @param instanceIdHeader
- * @return
- */
- @POST
- @Path("/{assetType}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "creates a resource", httpMethod = "POST", notes = "Creates a resource")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "ECOMP component is authenticated and Asset created", response = Resource.class),
- @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 400, message = "The name provided for the newly created resource is already in use for another resource in SDC - SVC4050"),
- @ApiResponse(code = 400, message = "Invalid field format. One of the provided fields does not comply with the field rules - SVC4126"),
- @ApiResponse(code = 400, message = "Missing request body. The post request did not contain the expected body - SVC4500"),
- @ApiResponse(code = 400, message = "The resource name is missing in the request body - SVC4062"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT description has wrong format - SVC4064"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT description has wrong format (exceeds limit) - SVC4065"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT tags exceeds character limit - SVC4066"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor name exceeds character limit - SVC4067"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor release exceeds character limit - SVC4068"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT ATT Contact has wrong format - SVC4069"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT name has wrong format - SVC4070"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor name has wrong format - SVC4071"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor release has wrong format - SVC4072"),
- @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT name exceeds character limit - SVC4073")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.Resource", paramType = "body", value = "json describe the created resource")
- public Response createResourceExternal(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The user id", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
- String data) {
-
- init(log);
-
- Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("Start handle request of {}", url);
- Resource resource = null;
- User modifier = null;
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
- ServletContext context = request.getSession().getServletContext();
- ResourceBusinessLogic resourceBL = getResourceBL(context);
- try {
- // Validate X-ECOMP-InstanceID Header
- if (responseWrapper.isEmpty()) {
- validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
- }
- // Validate USER_ID Header
- if (responseWrapper.isEmpty()) {
- validateHttpCspUserIdHeader(userId, responseWrapper);
- }
- // Validate assetType
- if (responseWrapper.isEmpty()) {
- if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) ){
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
- }
- }
- //Validate resource type
- if(responseWrapper.isEmpty()){
- JSONParser parser = new JSONParser();
- JSONObject jsonObj = (JSONObject) parser.parse(data);
- String resourceType = (String) jsonObj.get(FilterKeyEnum.RESOURCE_TYPE.getName());
- if( StringUtils.isEmpty(resourceType) || !ResourceTypeEnum.containsName(resourceType) ){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, (String) jsonObj.get("name"));
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
- }
- }
- // Convert the user json to a resource
- if (responseWrapper.isEmpty()) {
- modifier = new User();
- modifier.setUserId(userId);
- Either<Resource, ResponseFormat> eitherResource = getComponentsUtils()
- .convertJsonToObjectUsingObjectMapper(data, modifier, Resource.class,
- null, ComponentTypeEnum.RESOURCE);
- if( eitherResource.isRight() ){
- responseWrapper.setInnerElement(eitherResource.right().value());
- }
- else{
- resource = eitherResource.left().value();
- }
-
- }
- //validate name exist
- if(responseWrapper.isEmpty()){
- if( Strings.isEmpty(resource.getName())){
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
- ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue()));
-
- }
- }
-
- if(responseWrapper.isEmpty()){
- resource.setDerivedFrom(Arrays.asList("tosca.nodes.Root"));
- resource.setSystemName(ValidationUtils.convertToSystemName(resource.getName()));
- resource.setToscaResourceName(CommonBeUtils.generateToscaResourceName(ResourceTypeEnum.VFCMT.name(),
- resource.getSystemName()));
- handleCategories(context, data, resource, responseWrapper);
- }
- // Create the resource in the dataModel
- if (responseWrapper.isEmpty()) {
- Either<Resource, ResponseFormat> eitherCreateResponse = resourceBL.createResource(resource, null,
- modifier, null, null);
- if (eitherCreateResponse.isRight()) {
- responseWrapper.setInnerElement(eitherCreateResponse.right().value());
- } else {
- resource = eitherCreateResponse.left().value();
- }
- }
- Response response;
- //Build Response and store it in the response Wrapper
- if (responseWrapper.isEmpty()) {
- response = buildCreatedResourceResponse(resource, context, responseWrapper);
- }
- else{
- response = buildErrorResponse(responseWrapper.getInnerElement());
- }
- return response;
-
- } catch (Exception e) {
- final String message = "failed to create vfc monitoring template resource";
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
- log.debug(message, e);
- return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
- finally{
- prepareAdditionalAudit(resource, additionalParams);
-
- getComponentsUtils().auditExternalCrudApi(responseWrapper.getInnerElement(),
- ComponentTypeEnum.RESOURCE.getValue(), AuditingActionEnum.CREATE_RESOURCE_BY_API.getName(), request,
- additionalParams);
- }
- }
-
- /**
- * Changing the lifecycle of an asset
- * @param jsonChangeInfo The description - request body
- * @param assetType The requested asset type.Valid values are: resources / services (for VFCMT – use "resources")
- * @param uuid The uuid of the desired resource to be changed
- * @param lifecycleTransition The lifecycle operation to be performed on the asset.Valid values are:Checkin / Checkout / CERTIFICATION_REQUEST
- * @param userId
- * @return
- */
- @POST
- @Path("/{assetType}/{uuid}/lifecycleState/{lifecycleOperation}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Change Resource lifecycle State", httpMethod = "POST")
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "Resource state changed", response = AssetMetadata.class),
- @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
- @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
- @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
- @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
- @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
- @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"),
- @ApiResponse(code = 403, message = "Asset is already checked-out by another user - SVC4085"),
- @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4080")})
- @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction", paramType = "body", value = "userRemarks - Short description (free text) about the asset version being changed")
- public Response changeResourceStateExternal(
- @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
- @ApiParam(value = "The user id", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
- @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
- @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
- @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
- @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
- @ApiParam(allowableValues = "checkout, checkin", required = true) @PathParam(value = "lifecycleOperation") final String lifecycleTransition,
- @ApiParam(value = "id of component to be changed") @PathParam(value = "uuid") final String uuid,
- @ApiParam(value = "validValues: resources / services ", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam(value = "assetType") final String assetType,
- String jsonChangeInfo) {
-
- Response response = null;
- EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
-
- init(log);
-
- String requestURI = request.getRequestURI();
- String url = request.getMethod() + " " + requestURI;
- log.debug("Start handle request of {}", url);
-
- //get the business logic
- ServletContext context = request.getSession().getServletContext();
- LifecycleBusinessLogic businessLogic = getLifecycleBL(context);
-
- Wrapper<ResponseFormat> responseWrapper = runValidations(assetType);
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
- Component component = null;
- Component responseObject = null;
- User modifier = null;
-
- try{
- // Validate X-ECOMP-InstanceID Header
- if (responseWrapper.isEmpty()) {
- validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
- }
-
- if (responseWrapper.isEmpty()) {
- //get user
- Either<User, ResponseFormat> eitherGetUser = getUser(request, userId);
- if (eitherGetUser.isRight()) {
- ResponseFormat responseFormat = eitherGetUser.right().value();
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- }
- modifier = eitherGetUser.left().value();
-
- //get the component id from the uuid
- Either<Component, ResponseFormat> latestVersion = businessLogic.getLatestComponentByUuid(componentType, uuid);
- if (latestVersion.isRight()) {
- ResponseFormat responseFormat = latestVersion.right().value();
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- }
- component = latestVersion.left().value();
- String componentId = component.getUniqueId();
-
- //validate the transition is valid
- Either<LifeCycleTransitionEnum, ResponseFormat> validateEnum = validateTransitionEnum(lifecycleTransition, modifier);
- if (validateEnum.isRight()) {
- ResponseFormat responseFormat = validateEnum.right().value();
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- }
- LifeCycleTransitionEnum transitionEnum = validateEnum.left().value();
-
- //create changeInfo
- LifecycleChangeInfoWithAction changeInfo = new LifecycleChangeInfoWithAction();
- try {
- if (jsonChangeInfo != null && !jsonChangeInfo.isEmpty()) {
- ObjectMapper mapper = new ObjectMapper();
- changeInfo = new LifecycleChangeInfoWithAction(mapper.readValue(jsonChangeInfo, LifecycleChangeInfoBase.class).getUserRemarks());
- }
- }
- catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeInvalidJsonInput, "convertJsonToObject");
- BeEcompErrorManager.getInstance().logBeInvalidJsonInput("convertJsonToObject");
- log.debug("failed to convert from json {}", jsonChangeInfo, e);
- ResponseFormat responseFormat = getComponentsUtils().getInvalidContentErrorAndAudit(modifier, AuditingActionEnum.CHECKOUT_RESOURCE);
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- }
-
- //execute business logic
- Either<? extends Component, ResponseFormat> actionResponse = businessLogic.changeComponentState(componentType, componentId, modifier, transitionEnum, changeInfo, false, true);
- if (actionResponse.isRight()) {
- log.info("failed to change resource state");
- ResponseFormat responseFormat = actionResponse.right().value();
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- }
-
- log.debug("change state successful !!!");
- responseObject = actionResponse.left().value();
- response = buildCreatedResourceResponse(responseObject, context, responseWrapper);
- } else {
- response = buildErrorResponse(responseWrapper.getInnerElement());
- }
-
- return response;
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Change Lifecycle State");
- BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Change Lifecycle State");
- log.debug("change lifecycle state failed with exception", e);
- ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
- responseWrapper.setInnerElement(responseFormat);
- return buildErrorResponse(responseFormat);
- } finally{
- auditChnageLifecycleAction(additionalParams, responseWrapper, componentType, component, responseObject, modifier, userId);
- }
- }
-
- private void prepareAdditionalAudit(Resource resource, EnumMap<AuditingFieldsKeysEnum, Object> additionalParams) {
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, StringUtils.EMPTY);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, StringUtils.EMPTY);
-
- if( resource != null ){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resource.getName());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, resource.getUUID());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, resource.getInvariantUUID());
- } else {
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, StringUtils.EMPTY);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, StringUtils.EMPTY);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, StringUtils.EMPTY);
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, StringUtils.EMPTY);
- }
- }
-
- private Response buildCreatedResourceResponse(Component resource, ServletContext context,
- Wrapper<ResponseFormat> responseWrapper) throws IOException, JsonGenerationException, JsonMappingException {
- ResponseFormat responseFormat;
- Response response;
- AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
- Either<? extends AssetMetadata, ResponseFormat> resMetadata = assetMetadataUtils
- .convertToSingleAssetMetadata(resource, request.getRequestURL().toString(),
- true);
- if (resMetadata.isRight()) {
- log.debug("Asset conversion Failed");
- responseFormat = resMetadata.right().value();
- responseWrapper.setInnerElement(responseFormat);
- response = buildErrorResponse(responseFormat);
- }else{
- final AssetMetadata assetData = resMetadata.left().value();
- assetData.setToscaModelURL(null);
-
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.CREATED));
- Object representation = RepresentationUtils.toRepresentation(assetData);
- response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), representation);
- }
- return response;
- }
-
- private void handleCategories(ServletContext context, String data, Resource resource,
- Wrapper<ResponseFormat> responseWrapper) {
- try {
- JSONParser parser = new JSONParser();
- JSONObject jsonObj = (JSONObject) parser.parse(data);
- String category = (String) jsonObj.get(CategoryTypeEnum.CATEGORY.getValue());
- String subcategory = (String) jsonObj.get(CategoryTypeEnum.SUBCATEGORY.getValue());
- if (Strings.isEmpty(category)) {
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
- ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
- }
- else if (Strings.isEmpty(subcategory)) {
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
- ActionStatus.COMPONENT_MISSING_SUBCATEGORY));
- }
- if (responseWrapper.isEmpty()) {
- ElementBusinessLogic elementLogic = getElementBL(context);
- // get All Categories
- Either<List<CategoryDefinition>, ActionStatus> allResourceCategories = elementLogic
- .getAllResourceCategories();
- // Error fetching categories
- if (allResourceCategories.isRight()) {
- responseWrapper.setInnerElement(
- getComponentsUtils().getResponseFormat(allResourceCategories.right().value()));
- } else {
- addCategories(resource, category, subcategory, allResourceCategories, responseWrapper);
- }
- }
- } catch (Exception e) {
- log.debug("Exception occured in addCategories: {}", e.getMessage(), e);
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
-
- }
-
- private void addCategories(Resource resource, String category, String subcategory,
- Either<List<CategoryDefinition>, ActionStatus> allResourceCategories,
- Wrapper<ResponseFormat> responseWrapper) {
- Optional<CategoryDefinition> optionalCategory =
- // Stream of all the categories
- allResourceCategories.left().value().stream()
- // filter in only relevant category
- .filter(e -> e.getName().equals(category))
- // get the result
- .findAny();
- if (!optionalCategory.isPresent()) {
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
- ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
- } else {
- CategoryDefinition categoryDefinition = optionalCategory.get();
-
- List<SubCategoryDefinition> subCaregories =
- // Stream of all sub-categories of the relevant
- // category
- categoryDefinition.getSubcategories().stream()
- // filter in only relevant sub-category
- .filter(e -> e.getName().equals(subcategory))
- // get the result
- .collect(Collectors.toList());
-
- if( subCaregories.isEmpty() ){
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
- ActionStatus.COMPONENT_INVALID_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
- }
- else{
- categoryDefinition.setSubcategories(subCaregories);
- resource.setCategories(Arrays.asList(categoryDefinition));
- }
-
- }
- }
-
-
-
-
- private void auditChnageLifecycleAction(EnumMap<AuditingFieldsKeysEnum, Object> additionalParams,
- Wrapper<ResponseFormat> responseWrapper, ComponentTypeEnum componentType, Component component,
- Component responseObject, User modifier, String userId) {
- if (modifier!=null){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, modifier.getFullName());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, modifier.getUserId());
- } else {
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, userId);
- }
-
- if (component!=null){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, component.getVersion());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, component.getLifecycleState().name());
- } else {
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, "");
- }
-
- if (responseObject!=null){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, responseObject.getVersion());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, responseObject.getUUID());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, responseObject.getInvariantUUID());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,responseObject.getLifecycleState().name());
- } else {
- if (component!=null){
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, component.getVersion());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, component.getUUID());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, component.getInvariantUUID());
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,component.getLifecycleState().name());
- } else {
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, "");
- additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,"");
- }
- }
-
- getComponentsUtils().auditExternalCrudApi(responseWrapper.getInnerElement(),
- componentType.getValue(), AuditingActionEnum.CHANGE_LIFECYCLE_BY_API.getName(), request,
- additionalParams);
- }
-
- private Wrapper<ResponseFormat> runValidations(final String assetType) {
- Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
-
- // Validate X-ECOMP-InstanceID Header
- if (responseWrapper.isEmpty()) {
- String instanceId = request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER);
- validateXECOMPInstanceIDHeader(instanceId,responseWrapper);
- }
- // Validate USER_ID Header
- if (responseWrapper.isEmpty()) {
- validateHttpCspUserIdHeader(request.getHeader(Constants.USER_ID_HEADER),responseWrapper);
- }
- // Validate assetType
- if (responseWrapper.isEmpty()) {
- if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) && !AssetTypeEnum.SERVICES.getValue().equals(assetType)){
- responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
- }
- }
-
- return responseWrapper;
- }
-
- private Either<LifeCycleTransitionEnum, ResponseFormat> validateTransitionEnum(final String lifecycleTransition, User user) {
- LifeCycleTransitionEnum transitionEnum = LifeCycleTransitionEnum.CHECKOUT;
- try {
- transitionEnum = LifeCycleTransitionEnum.getFromDisplayName(lifecycleTransition);
- } catch (IllegalArgumentException e) {
- log.info("state operation is not valid. operations allowed are: {}", LifeCycleTransitionEnum.valuesAsString());
- ResponseFormat error = getComponentsUtils().getInvalidContentErrorAndAudit(user, AuditingActionEnum.CHECKOUT_RESOURCE);
- return Either.right(error);
- }
- return Either.left(transitionEnum);
- }
+
+ @Context
+ private HttpServletRequest request;
+
+ private static final Logger log = LoggerFactory.getLogger(CrudExternalServlet.class);
+
+ /**
+ * Creates a new Resource
+ *
+ * @param assetType
+ * @param data
+ * @param userId
+ * @param instanceIdHeader
+ * @return
+ */
+ @POST
+ @Path("/{assetType}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "creates a resource", httpMethod = "POST", notes = "Creates a resource")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "ECOMP component is authenticated and Asset created", response = Resource.class),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "The name provided for the newly created resource is already in use for another resource in SDC - SVC4050"),
+ @ApiResponse(code = 400, message = "Invalid field format. One of the provided fields does not comply with the field rules - SVC4126"),
+ @ApiResponse(code = 400, message = "Missing request body. The post request did not contain the expected body - SVC4500"),
+ @ApiResponse(code = 400, message = "The resource name is missing in the request body - SVC4062"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT description has wrong format - SVC4064"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT description has wrong format (exceeds limit) - SVC4065"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT tags exceeds character limit - SVC4066"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor name exceeds character limit - SVC4067"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor release exceeds character limit - SVC4068"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT ATT Contact has wrong format - SVC4069"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT name has wrong format - SVC4070"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor name has wrong format - SVC4071"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT vendor release has wrong format - SVC4072"),
+ @ApiResponse(code = 400, message = "Create VFCMT request: VFCMT name exceeds character limit - SVC4073")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.model.Resource", paramType = "body", value = "json describe the created resource")})
+ public Response createResourceExternal(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The user id", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The requested asset type", required = true, allowableValues = "resources, services")@PathParam("assetType") final String assetType,
+ String data) {
+
+ init(log);
+
+ Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("Start handle request of {}", url);
+ Resource resource = null;
+ User modifier = null;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ ServletContext context = request.getSession().getServletContext();
+ ResourceBusinessLogic resourceBL = getResourceBL(context);
+ try {
+ // Validate X-ECOMP-InstanceID Header
+ if (responseWrapper.isEmpty()) {
+ validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
+ }
+ // Validate USER_ID Header
+ if (responseWrapper.isEmpty()) {
+ validateHttpCspUserIdHeader(userId, responseWrapper);
+ }
+ // Validate assetType
+ if (responseWrapper.isEmpty()) {
+ if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) ){
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
+ }
+ }
+ //Validate resource type
+ if(responseWrapper.isEmpty()){
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj = (JSONObject) parser.parse(data);
+ String resourceType = (String) jsonObj.get(FilterKeyEnum.RESOURCE_TYPE.getName());
+ if( StringUtils.isEmpty(resourceType) || !ResourceTypeEnum.containsName(resourceType) ){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, (String) jsonObj.get("name"));
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
+ }
+ }
+ // Convert the user json to a resource
+ if (responseWrapper.isEmpty()) {
+ modifier = new User();
+ modifier.setUserId(userId);
+ Either<Resource, ResponseFormat> eitherResource = getComponentsUtils()
+ .convertJsonToObjectUsingObjectMapper(data, modifier, Resource.class,
+ null, ComponentTypeEnum.RESOURCE);
+ if( eitherResource.isRight() ){
+ responseWrapper.setInnerElement(eitherResource.right().value());
+ }
+ else{
+ resource = eitherResource.left().value();
+ }
+
+ }
+ //validate name exist
+ if(responseWrapper.isEmpty()){
+ if( Strings.isEmpty(resource.getName())){
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
+ ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue()));
+
+ }
+ }
+
+ if(responseWrapper.isEmpty()){
+ resource.setDerivedFrom(Arrays.asList("tosca.nodes.Root"));
+ resource.setSystemName(ValidationUtils.convertToSystemName(resource.getName()));
+ resource.setToscaResourceName(CommonBeUtils.generateToscaResourceName(ResourceTypeEnum.VFCMT.name(),
+ resource.getSystemName()));
+ handleCategories(context, data, resource, responseWrapper);
+ }
+ // Create the resource in the dataModel
+ if (responseWrapper.isEmpty()) {
+ Either<Resource, ResponseFormat> eitherCreateResponse = resourceBL.createResource(resource, null,
+ modifier, null, null);
+ if (eitherCreateResponse.isRight()) {
+ responseWrapper.setInnerElement(eitherCreateResponse.right().value());
+ } else {
+ resource = eitherCreateResponse.left().value();
+ }
+ }
+ Response response;
+ //Build Response and store it in the response Wrapper
+ if (responseWrapper.isEmpty()) {
+ response = buildCreatedResourceResponse(resource, context, responseWrapper);
+ }
+ else{
+ response = buildErrorResponse(responseWrapper.getInnerElement());
+ }
+ return response;
+
+ } catch (Exception e) {
+ final String message = "failed to create vfc monitoring template resource";
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(message);
+ log.debug(message, e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ finally{
+ prepareAdditionalAudit(resource, additionalParams);
+
+ getComponentsUtils().auditExternalCrudApi(responseWrapper.getInnerElement(),
+ ComponentTypeEnum.RESOURCE.getValue(), AuditingActionEnum.CREATE_RESOURCE_BY_API.getName(), request,
+ additionalParams);
+ }
+ }
+
+ /**
+ * Changing the lifecycle of an asset
+ * @param jsonChangeInfo The description - request body
+ * @param assetType The requested asset type.Valid values are: resources / services (for VFCMT – use "resources")
+ * @param uuid The uuid of the desired resource to be changed
+ * @param lifecycleTransition The lifecycle operation to be performed on the asset.Valid values are:Checkin / Checkout / CERTIFICATION_REQUEST
+ * @param userId
+ * @return
+ */
+ @POST
+ @Path("/{assetType}/{uuid}/lifecycleState/{lifecycleOperation}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Change Resource lifecycle State", httpMethod = "POST")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Resource state changed", response = AssetMetadata.class),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 403, message = "Asset is already checked-out by another user - SVC4085"),
+ @ApiResponse(code = 403, message = "Asset is being edited by different user. Only one user can checkout and edit an asset on given time. The asset will be available for checkout after the other user will checkin the asset - SVC4080")})
+ @ApiImplicitParams({@ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction", paramType = "body", value = "userRemarks - Short description (free text) about the asset version being changed")})
+ public Response changeResourceStateExternal(
+ @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The user id", required = true)@HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(allowableValues = "checkout, checkin", required = true) @PathParam(value = "lifecycleOperation") final String lifecycleTransition,
+ @ApiParam(value = "id of component to be changed") @PathParam(value = "uuid") final String uuid,
+ @ApiParam(value = "validValues: resources / services ", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam(value = "assetType") final String assetType,
+ String jsonChangeInfo) {
+
+ Response response = null;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+
+ init(log);
+
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ log.debug("Start handle request of {}", url);
+
+ //get the business logic
+ ServletContext context = request.getSession().getServletContext();
+ LifecycleBusinessLogic businessLogic = getLifecycleBL(context);
+
+ Wrapper<ResponseFormat> responseWrapper = runValidations(assetType);
+ ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(assetType);
+ Component component = null;
+ Component responseObject = null;
+ User modifier = null;
+
+ try{
+ // Validate X-ECOMP-InstanceID Header
+ if (responseWrapper.isEmpty()) {
+ validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
+ }
+
+ if (responseWrapper.isEmpty()) {
+ //get user
+ Either<User, ResponseFormat> eitherGetUser = getUser(request, userId);
+ if (eitherGetUser.isRight()) {
+ ResponseFormat responseFormat = eitherGetUser.right().value();
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ }
+ modifier = eitherGetUser.left().value();
+
+ //get the component id from the uuid
+ Either<Component, ResponseFormat> latestVersion = businessLogic.getLatestComponentByUuid(componentType, uuid);
+ if (latestVersion.isRight()) {
+ ResponseFormat responseFormat = latestVersion.right().value();
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ }
+ component = latestVersion.left().value();
+ String componentId = component.getUniqueId();
+
+ //validate the transition is valid
+ Either<LifeCycleTransitionEnum, ResponseFormat> validateEnum = validateTransitionEnum(lifecycleTransition, modifier);
+ if (validateEnum.isRight()) {
+ ResponseFormat responseFormat = validateEnum.right().value();
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ }
+ LifeCycleTransitionEnum transitionEnum = validateEnum.left().value();
+
+ //create changeInfo
+ LifecycleChangeInfoWithAction changeInfo = new LifecycleChangeInfoWithAction();
+ try {
+ if (jsonChangeInfo != null && !jsonChangeInfo.isEmpty()) {
+ ObjectMapper mapper = new ObjectMapper();
+ changeInfo = new LifecycleChangeInfoWithAction(mapper.readValue(jsonChangeInfo, LifecycleChangeInfoBase.class).getUserRemarks());
+ }
+ }
+ catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeInvalidJsonInput("convertJsonToObject");
+ log.debug("failed to convert from json {}", jsonChangeInfo, e);
+ ResponseFormat responseFormat = getComponentsUtils().getInvalidContentErrorAndAudit(modifier, componentId, AuditingActionEnum.CHECKOUT_RESOURCE);
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ }
+
+ //execute business logic
+ Either<? extends Component, ResponseFormat> actionResponse = businessLogic.changeComponentState(componentType, componentId, modifier, transitionEnum, changeInfo, false, true);
+ if (actionResponse.isRight()) {
+ log.info("failed to change resource state");
+ ResponseFormat responseFormat = actionResponse.right().value();
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ }
+
+ log.debug("change state successful !!!");
+ responseObject = actionResponse.left().value();
+ response = buildCreatedResourceResponse(responseObject, context, responseWrapper);
+ } else {
+ response = buildErrorResponse(responseWrapper.getInnerElement());
+ }
+
+ return response;
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Change Lifecycle State");
+ log.debug("change lifecycle state failed with exception", e);
+ ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
+ responseWrapper.setInnerElement(responseFormat);
+ return buildErrorResponse(responseFormat);
+ } finally{
+ auditChnageLifecycleAction(additionalParams, responseWrapper, componentType, component, responseObject, modifier, userId);
+ }
+ }
+
+ private void prepareAdditionalAudit(Resource resource, EnumMap<AuditingFieldsKeysEnum, Object> additionalParams) {
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, StringUtils.EMPTY);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, StringUtils.EMPTY);
+
+ if( resource != null ){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resource.getName());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, resource.getUUID());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, resource.getInvariantUUID());
+ } else {
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, StringUtils.EMPTY);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE, StringUtils.EMPTY);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, StringUtils.EMPTY);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, StringUtils.EMPTY);
+ }
+ }
+
+ private Response buildCreatedResourceResponse(Component resource, ServletContext context,
+ Wrapper<ResponseFormat> responseWrapper) throws IOException {
+ ResponseFormat responseFormat;
+ Response response;
+ AssetMetadataConverter assetMetadataUtils = getAssetUtils(context);
+ Either<? extends AssetMetadata, ResponseFormat> resMetadata = assetMetadataUtils
+ .convertToSingleAssetMetadata(resource, request.getRequestURL().toString(),
+ true);
+ if (resMetadata.isRight()) {
+ log.debug("Asset conversion Failed");
+ responseFormat = resMetadata.right().value();
+ responseWrapper.setInnerElement(responseFormat);
+ response = buildErrorResponse(responseFormat);
+ }else{
+ final AssetMetadata assetData = resMetadata.left().value();
+ assetData.setToscaModelURL(null);
+
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.CREATED));
+ Object representation = RepresentationUtils.toRepresentation(assetData);
+ response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), representation);
+ }
+ return response;
+ }
+
+ private void handleCategories(ServletContext context, String data, Resource resource,
+ Wrapper<ResponseFormat> responseWrapper) {
+ try {
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj = (JSONObject) parser.parse(data);
+ String category = (String) jsonObj.get(CategoryTypeEnum.CATEGORY.getValue());
+ String subcategory = (String) jsonObj.get(CategoryTypeEnum.SUBCATEGORY.getValue());
+ if (Strings.isEmpty(category)) {
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
+ ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
+ }
+ else if (Strings.isEmpty(subcategory)) {
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
+ ActionStatus.COMPONENT_MISSING_SUBCATEGORY));
+ }
+ if (responseWrapper.isEmpty()) {
+ ElementBusinessLogic elementLogic = getElementBL(context);
+ // get All Categories
+ Either<List<CategoryDefinition>, ActionStatus> allResourceCategories = elementLogic
+ .getAllResourceCategories();
+ // Error fetching categories
+ if (allResourceCategories.isRight()) {
+ responseWrapper.setInnerElement(
+ getComponentsUtils().getResponseFormat(allResourceCategories.right().value()));
+ } else {
+ addCategories(resource, category, subcategory, allResourceCategories, responseWrapper);
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Exception occured in addCategories: {}", e.getMessage(), e);
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+
+ }
+
+ private void addCategories(Resource resource, String category, String subcategory,
+ Either<List<CategoryDefinition>, ActionStatus> allResourceCategories,
+ Wrapper<ResponseFormat> responseWrapper) {
+ Optional<CategoryDefinition> optionalCategory =
+ // Stream of all the categories
+ allResourceCategories.left().value().stream()
+ // filter in only relevant category
+ .filter(e -> e.getName().equals(category))
+ // get the result
+ .findAny();
+ if (!optionalCategory.isPresent()) {
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
+ ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
+ } else {
+ CategoryDefinition categoryDefinition = optionalCategory.get();
+
+ List<SubCategoryDefinition> subCaregories =
+ // Stream of all sub-categories of the relevant
+ // category
+ categoryDefinition.getSubcategories().stream()
+ // filter in only relevant sub-category
+ .filter(e -> e.getName().equals(subcategory))
+ // get the result
+ .collect(Collectors.toList());
+
+ if( subCaregories.isEmpty() ){
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
+ ActionStatus.COMPONENT_INVALID_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue()));
+ }
+ else{
+ categoryDefinition.setSubcategories(subCaregories);
+ resource.setCategories(Arrays.asList(categoryDefinition));
+ }
+
+ }
+ }
+
+
+
+
+ private void auditChnageLifecycleAction(EnumMap<AuditingFieldsKeysEnum, Object> additionalParams,
+ Wrapper<ResponseFormat> responseWrapper, ComponentTypeEnum componentType, Component component,
+ Component responseObject, User modifier, String userId) {
+ if (modifier!=null){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, modifier.getFullName());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, modifier.getUserId());
+ } else {
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_NAME, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_MODIFIER_UID, userId);
+ }
+
+ if (component!=null){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, component.getVersion());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, component.getLifecycleState().name());
+ } else {
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_VERSION, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_PREV_STATE, "");
+ }
+
+ if (responseObject!=null){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, responseObject.getVersion());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, responseObject.getUUID());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, responseObject.getInvariantUUID());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,responseObject.getLifecycleState().name());
+ } else {
+ if (component!=null){
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, component.getVersion());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, component.getUUID());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, component.getInvariantUUID());
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,component.getLifecycleState().name());
+ } else {
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_VERSION, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_INVARIANT_UUID, "");
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_CURR_STATE,"");
+ }
+ }
+
+ getComponentsUtils().auditExternalCrudApi(responseWrapper.getInnerElement(),
+ componentType.getValue(), AuditingActionEnum.CHANGE_LIFECYCLE_BY_API.getName(), request,
+ additionalParams);
+ }
+
+ private Wrapper<ResponseFormat> runValidations(final String assetType) {
+ Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
+
+ // Validate X-ECOMP-InstanceID Header
+ if (responseWrapper.isEmpty()) {
+ String instanceId = request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER);
+ validateXECOMPInstanceIDHeader(instanceId,responseWrapper);
+ }
+ // Validate USER_ID Header
+ if (responseWrapper.isEmpty()) {
+ validateHttpCspUserIdHeader(request.getHeader(Constants.USER_ID_HEADER),responseWrapper);
+ }
+ // Validate assetType
+ if (responseWrapper.isEmpty()) {
+ if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) && !AssetTypeEnum.SERVICES.getValue().equals(assetType)){
+ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
+ }
+ }
+
+ return responseWrapper;
+ }
+
+ private Either<LifeCycleTransitionEnum, ResponseFormat> validateTransitionEnum(final String lifecycleTransition, User user) {
+ LifeCycleTransitionEnum transitionEnum = LifeCycleTransitionEnum.CHECKOUT;
+ try {
+ transitionEnum = LifeCycleTransitionEnum.getFromDisplayName(lifecycleTransition);
+ } catch (IllegalArgumentException e) {
+ log.info("state operation is not valid. operations allowed are: {}", LifeCycleTransitionEnum.valuesAsString(), e);
+ ResponseFormat error = getComponentsUtils().getInvalidContentErrorAndAudit(user, "", AuditingActionEnum.CHECKOUT_RESOURCE);
+ return Either.right(error);
+ }
+ return Either.left(transitionEnum);
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServlet.java
new file mode 100644
index 0000000000..7e48890c7d
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServlet.java
@@ -0,0 +1,214 @@
+package org.openecomp.sdc.be.externalapi.servlet;
+
+import fj.data.Either;
+import org.openecomp.sdc.be.components.impl.ExternalRefsBusinessLogic;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dto.ExternalRefDTO;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.datastructure.Wrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.Map;
+
+
+@Path("/v1/catalog")
+@Controller
+public class ExternalRefsServlet extends AbstractValidationsServlet {
+
+ private static final Logger log = LoggerFactory.getLogger(ExternalRefsServlet.class);
+
+ private ExternalRefsBusinessLogic businessLogic;
+
+ public ExternalRefsServlet(ExternalRefsBusinessLogic businessLogic, ComponentsUtils componentsUtils){
+ this.businessLogic = businessLogic;
+ this.componentsUtils = componentsUtils;
+ }
+
+ @GET
+ @Path("/{assetType}/{uuid}/version/{version}/resourceInstances/{componentInstanceName}/externalReferences/{objectType}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getComponentInstanceExternalRef(
+ @Context final HttpServletRequest request,
+ @PathParam("assetType") String assetType,
+ @PathParam("uuid") String uuid,
+ @PathParam("version") String version,
+ @PathParam("componentInstanceName") String componentInstanceName,
+ @PathParam("objectType") String objectType, @HeaderParam("USER_ID") String userId) {
+
+ log.debug("GET component instance external interfaces {} {} {} {}", assetType, uuid, componentInstanceName, objectType);
+
+ Response r = authorizeAndValidateRequest(request, userId);
+ if (r != null){
+ return r;
+ }
+
+ Either<List<String>, ActionStatus> refsResult = this.businessLogic.getExternalReferences(uuid, version, componentInstanceName, objectType);
+ if (refsResult.isLeft()){
+ return this.buildOkResponse(refsResult.left().value());
+ } else {
+ return this.buildExtRefErrorResponse(refsResult.right().value(), uuid, version, componentInstanceName, objectType, "");
+ }
+ }
+
+ @GET
+ @Path("/{assetType}/{uuid}/version/{version}/externalReferences/{objectType}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map<String, List<String>> getAssetExternalRefByObjectType(
+ @Context final HttpServletRequest request,
+ @PathParam("assetType") String assetType,
+ @PathParam("uuid") String uuid,
+ @PathParam("version") String version,
+ @PathParam("objectType") String objectType, @HeaderParam("USER_ID") String userId) {
+
+ log.debug("GET asset external references {} {} {}", assetType, uuid, objectType);
+
+ Response r = authorizeAndValidateRequest(request, userId);
+ if (r != null){
+ throw new WebApplicationException(r);
+ }
+
+ Either<Map<String, List<String>>, ActionStatus> refsResult = this.businessLogic.getExternalReferences(uuid, version, objectType);
+ if (refsResult.isLeft()){
+ return refsResult.left().value();
+ } else {
+ throw new WebApplicationException(this.buildExtRefErrorResponse(refsResult.right().value(), uuid, version, "", objectType, ""));
+ }
+ }
+
+ @POST
+ @Path("/{assetType}/{uuid}/resourceInstances/{componentInstanceName}/externalReferences/{objectType}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response addComponentInstanceExternalRef(
+ @Context final HttpServletRequest request,
+ @PathParam("assetType") String assetType,
+ @PathParam("uuid") String uuid,
+ @PathParam("componentInstanceName") String componentInstanceName,
+ @PathParam("objectType") String objectType, ExternalRefDTO ref, @HeaderParam("USER_ID") String userId) {
+
+ log.debug("POST component instance external interfaces {} {} {} {} {}", assetType, uuid, componentInstanceName, objectType, ref);
+
+ Response r = authorizeAndValidateRequest(request, userId);
+ if (r != null){
+ return r;
+ }
+
+ Either<String, ActionStatus> addResult = this.businessLogic.addExternalReference(uuid, componentInstanceName, objectType, ref);
+ if (addResult.isLeft()) {
+ return Response.status(Response.Status.CREATED)
+ .entity(ref)
+ .build();
+ } else {
+ return this.buildExtRefErrorResponse(addResult.right().value(), uuid, "", componentInstanceName, objectType, ref.getReferenceUUID());
+ }
+
+ }
+
+ @DELETE
+ @Path("/{assetType}/{uuid}/resourceInstances/{componentInstanceName}/externalReferences/{objectType}/{reference}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response deleteComponentInstanceReference(
+ @Context final HttpServletRequest request,
+ @PathParam("assetType") String assetType,
+ @PathParam("uuid") String uuid,
+ @PathParam("componentInstanceName") String componentInstanceName,
+ @PathParam("objectType") String objectType,
+ @PathParam("reference") String reference, @HeaderParam("USER_ID") String userId) {
+
+ log.debug("DELETE component instance external interfaces {} {} {} {}", assetType, uuid, componentInstanceName, objectType);
+
+ Response r = authorizeAndValidateRequest(request, userId);
+ if (r != null){
+ return r;
+ }
+
+ Either<String, ActionStatus> deleteStatus = this.businessLogic.deleteExternalReference(uuid, componentInstanceName, objectType, reference);
+ if (deleteStatus.isLeft()){
+ return this.buildOkResponse(new ExternalRefDTO(reference));
+ } else {
+ return this.buildExtRefErrorResponse(deleteStatus.right().value(), uuid, "", componentInstanceName, objectType, reference);
+ }
+ }
+
+ @PUT
+ @Path("/{assetType}/{uuid}/resourceInstances/{componentInstanceName}/externalReferences/{objectType}/{oldRefValue}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response updateComponentInstanceReference(
+ @Context final HttpServletRequest request,
+ @PathParam("assetType") String assetType,
+ @PathParam("uuid") String uuid,
+ @PathParam("componentInstanceName") String componentInstanceName,
+ @PathParam("objectType") String objectType,
+ @PathParam("oldRefValue") String oldRefValue,
+ ExternalRefDTO newRefValueDTO, @HeaderParam("USER_ID") String userId) {
+
+ log.debug("PUT component instance external interfaces {} {} {} {}", assetType, uuid, componentInstanceName, objectType);
+
+ Response r = authorizeAndValidateRequest(request, userId);
+ if (r != null){
+ return r;
+ }
+
+ String newRefValue = newRefValueDTO.getReferenceUUID();
+ Either<String, ActionStatus> updateResult = this.businessLogic.updateExternalReference(uuid, componentInstanceName, objectType, oldRefValue, newRefValue);
+ if (updateResult.isLeft()){
+ return this.buildOkResponse(new ExternalRefDTO(newRefValue));
+ } else {
+ return this.buildExtRefErrorResponse(updateResult.right().value(), uuid, "", componentInstanceName, objectType, oldRefValue);
+ }
+
+ }
+
+ private Response authorizeAndValidateRequest(final HttpServletRequest request, String userId) {
+ init(log);
+
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ Wrapper<User> userWrapper = new Wrapper<>();
+
+ //Validate X-ECOMP_INSTANCE_ID_HEADER
+ if (request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER) == null || request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER).isEmpty()){
+ return this.buildExtRefErrorResponse(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID, "", "", "", "", "");
+ }
+
+ String method = request.getMethod();
+ if (responseWrapper.isEmpty() && !"GET".equals(method)) {
+ validateUserExist(responseWrapper, userWrapper, userId);
+ validateUserRole(responseWrapper, userWrapper.getInnerElement());
+ }
+
+ return responseWrapper.getInnerElement();
+ }
+
+ private Response buildExtRefErrorResponse(ActionStatus status, String uuid, String version, String componentInstanceName, String objectType, String ref){
+ switch (status) {
+ case RESOURCE_NOT_FOUND:
+ return buildErrorResponse(componentsUtils.getResponseFormat(status, uuid));
+ case COMPONENT_VERSION_NOT_FOUND:
+ return buildErrorResponse(componentsUtils.getResponseFormat(status, uuid, version));
+ case COMPONENT_INSTANCE_NOT_FOUND:
+ return buildErrorResponse(componentsUtils.getResponseFormat(status, componentInstanceName, uuid));
+ case EXT_REF_ALREADY_EXIST:
+ return Response.status(Response.Status.OK)
+ .entity(new ExternalRefDTO(ref))
+ .build();
+ case EXT_REF_NOT_FOUND:
+ return buildErrorResponse(componentsUtils.getResponseFormat(status, objectType + "/" + ref));
+ case MISSING_X_ECOMP_INSTANCE_ID:
+ return buildErrorResponse(componentsUtils.getResponseFormat(status));
+ default:
+ return this.buildGeneralErrorResponse();
+ }
+ }
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java
new file mode 100644
index 0000000000..3f1bf18edb
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java
@@ -0,0 +1,167 @@
+package org.openecomp.sdc.be.externalapi.servlet;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.annotations.*;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceDistributionReqInfo;
+import org.openecomp.sdc.be.externalapi.servlet.representation.ServiceDistributionRespInfo;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
+import org.openecomp.sdc.be.servlets.RepresentationUtils;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.common.datastructure.Wrapper;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Singleton;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.EnumMap;
+
+/**
+ * Created by chaya on 10/17/2017.
+ */
+@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
+@Path("/v1/catalog")
+@Api(value = "Service Activation External Servlet", description = "This Servlet serves external users for activating a specific service")
+@Singleton
+public class ServiceActivationServlet extends AbstractValidationsServlet {
+
+ @Context
+ private HttpServletRequest request;
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceActivationServlet.class);
+
+ /**
+ * Activates a service on a specific environment
+ *
+ * @param serviceUUID
+ * @param opEnvId
+ * @param userId
+ * @param instanceIdHeader
+ * @return
+ */
+ @POST
+ @Path("/services/{serviceUUID}/distribution/{opEnvId}/activate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "activate a service", httpMethod = "POST", notes = "Activates a service")
+ @ApiResponses(value = {
+ @ApiResponse(code = 202, message = "ECOMP component is authenticated and required service may be distributed"),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
+ @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
+ @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
+ @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
+ @ApiResponse(code = 405, message = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
+ @ApiResponse(code = 500, message = "The request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"),
+ @ApiResponse(code = 400, message = "Invalid field format. One of the provided fields does not comply with the field rules - SVC4126"),
+ @ApiResponse(code = 400, message = "Missing request body. The post request did not contain the expected body - SVC4500"),
+ @ApiResponse(code = 400, message = "The resource name is missing in the request body - SVC4062"),
+ @ApiResponse(code = 409, message = "Service state is invalid for this action"),
+ @ApiResponse(code = 502, message = "The server was acting as a gateway or proxy and received an invalid response from the upstream server")})
+ public Response activateServiceExternal(
+ @ApiParam(value = "Determines the format of the body of the request", required = true) @HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
+ @ApiParam(value = "The user id", required = true) @HeaderParam(value = Constants.USER_ID_HEADER) final String userId,
+ @ApiParam(value = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
+ @ApiParam(value = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,
+ @ApiParam(value = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
+ @ApiParam(value = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
+ @ApiParam(value = "The serviceUUid to activate", required = true) @PathParam("serviceUUID") final String serviceUUID,
+ @ApiParam(value = "The operational environment on which to activate the service on", required = true) @PathParam("opEnvId") final String opEnvId,
+ String data) {
+
+ init(log);
+
+ ResponseFormat responseFormat = null;
+ String requestURI = request.getRequestURI();
+ String url = request.getMethod() + " " + requestURI;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_SERVICE_INSTANCE_ID, serviceUUID);
+ additionalParams.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
+ log.debug("Start handle request of {}", url);
+
+ ServletContext context = request.getSession().getServletContext();
+ try {
+
+ Wrapper<ResponseFormat> responseWrapper = validateRequestHeaders(instanceIdHeader, userId);
+
+ if (responseWrapper.isEmpty()) {
+ User modifier = new User();
+ modifier.setUserId(userId);
+ log.debug("modifier id is {}", userId);
+
+ ServiceBusinessLogic businessLogic = getServiceBL(context);
+ ServiceDistributionReqInfo reqMetadata = convertJsonToActivationMetadata(data);
+ Either<String, ResponseFormat> distResponse = businessLogic.activateServiceOnTenantEnvironment(serviceUUID, opEnvId, modifier, reqMetadata);
+
+ if (distResponse.isRight()) {
+ log.debug("failed to activate service distribution");
+ responseFormat = distResponse.right().value();
+ return buildErrorResponse(responseFormat);
+ }
+ String distributionId = distResponse.left().value();
+ Object result = RepresentationUtils.toRepresentation(new ServiceDistributionRespInfo(distributionId));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.ACCEPTED);
+ return buildOkResponse(responseFormat, result);
+ } else {
+ log.debug("request instanceId/userId header validation failed");
+ responseFormat = responseWrapper.getInnerElement();
+ return buildErrorResponse(responseFormat);
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Activate Distribution");
+ log.debug("activate distribution failed with exception", e);
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
+ return buildErrorResponse(responseFormat);
+ } finally {
+ getComponentsUtils().auditExternalActivateService(responseFormat, ComponentTypeEnum.SERVICE.name(), request, additionalParams);
+ }
+ }
+
+ private Wrapper<ResponseFormat> validateRequestHeaders(String instanceIdHeader, String userId) {
+ Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
+ if (responseWrapper.isEmpty()) {
+ validateXECOMPInstanceIDHeader(instanceIdHeader, responseWrapper);
+ }
+ if (responseWrapper.isEmpty()) {
+ validateHttpCspUserIdHeader(userId, responseWrapper);
+ }
+ return responseWrapper;
+ }
+
+ private ServiceDistributionReqInfo convertJsonToActivationMetadata(String data) {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.readValue(data, ServiceDistributionReqInfo.class);
+ } catch (IOException e) {
+ log.error("#convertJsonToActivationMetadata - json deserialization failed with error: ", e);
+ return new ServiceDistributionReqInfo(null);
+ }
+ }
+
+ @Override
+ protected void validateHttpCspUserIdHeader(String header, Wrapper<ResponseFormat> responseWrapper) {
+ ResponseFormat responseFormat;
+ if( StringUtils.isEmpty(header)){
+ log.debug("MissingUSER_ID");
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.AUTH_FAILED);
+ responseWrapper.setInnerElement(responseFormat);
+ }
+ }
+}
+
+
+
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadata.java
index 15ebceaa5d..e41d8d7548 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ArtifactMetadata.java
@@ -21,104 +21,104 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
public class ArtifactMetadata {
- private String artifactName;
- private String artifactType;
- private String artifactURL;
- private String artifactDescription;
- private Integer artifactTimeout;
- private String artifactChecksum;
- private String artifactUUID;
- private String artifactVersion;
- private String generatedFromUUID;
- private String artifactLabel;
- private String artifactGroupType;
-
- public String getArtifactName() {
- return artifactName;
- }
-
- public void setArtifactName(String artifactName) {
- this.artifactName = artifactName;
- }
-
- public String getArtifactType() {
- return artifactType;
- }
-
- public void setArtifactType(String artifactType) {
- this.artifactType = artifactType;
- }
-
- public String getArtifactURL() {
- return artifactURL;
- }
-
- public void setArtifactURL(String artifactURL) {
- this.artifactURL = artifactURL;
- }
-
- public String getArtifactDescription() {
- return artifactDescription;
- }
-
- public void setArtifactDescription(String artifactDescription) {
- this.artifactDescription = artifactDescription;
- }
-
- public Integer getArtifactTimeout() {
- return artifactTimeout;
- }
-
- public void setArtifactTimeout(Integer artifactTimeout) {
- this.artifactTimeout = artifactTimeout;
- }
-
- public String getArtifactChecksum() {
- return artifactChecksum;
- }
-
- public void setArtifactChecksum(String artifactChecksum) {
- this.artifactChecksum = artifactChecksum;
- }
-
- public String getArtifactUUID() {
- return artifactUUID;
- }
-
- public void setArtifactUUID(String artifactUUID) {
- this.artifactUUID = artifactUUID;
- }
-
- public String getArtifactVersion() {
- return artifactVersion;
- }
-
- public void setArtifactVersion(String artifactVersion) {
- this.artifactVersion = artifactVersion;
- }
-
- public String getGeneratedFromUUID() {
- return generatedFromUUID;
- }
-
- public void setGeneratedFromUUID(String generatedFromUUID) {
- this.generatedFromUUID = generatedFromUUID;
- }
-
- public String getArtifactLabel() {
- return artifactLabel;
- }
-
- public void setArtifactLabel(String artifactLabel) {
- this.artifactLabel = artifactLabel;
- }
-
- public String getArtifactGroupType() {
- return artifactGroupType;
- }
-
- public void setArtifactGroupType(String artifactGroupType) {
- this.artifactGroupType = artifactGroupType;
- }
+ private String artifactName;
+ private String artifactType;
+ private String artifactURL;
+ private String artifactDescription;
+ private Integer artifactTimeout;
+ private String artifactChecksum;
+ private String artifactUUID;
+ private String artifactVersion;
+ private String generatedFromUUID;
+ private String artifactLabel;
+ private String artifactGroupType;
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ public void setArtifactURL(String artifactURL) {
+ this.artifactURL = artifactURL;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getArtifactTimeout() {
+ return artifactTimeout;
+ }
+
+ public void setArtifactTimeout(Integer artifactTimeout) {
+ this.artifactTimeout = artifactTimeout;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ public void setArtifactUUID(String artifactUUID) {
+ this.artifactUUID = artifactUUID;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getGeneratedFromUUID() {
+ return generatedFromUUID;
+ }
+
+ public void setGeneratedFromUUID(String generatedFromUUID) {
+ this.generatedFromUUID = generatedFromUUID;
+ }
+
+ public String getArtifactLabel() {
+ return artifactLabel;
+ }
+
+ public void setArtifactLabel(String artifactLabel) {
+ this.artifactLabel = artifactLabel;
+ }
+
+ public String getArtifactGroupType() {
+ return artifactGroupType;
+ }
+
+ public void setArtifactGroupType(String artifactGroupType) {
+ this.artifactGroupType = artifactGroupType;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/AssetMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/AssetMetadata.java
index cb14f76aff..b12411a7b3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/AssetMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/AssetMetadata.java
@@ -21,109 +21,109 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
public abstract class AssetMetadata implements IAssetMetadata {
- private String uuid;
- private String invariantUUID;
- private String name;
- private String version;
- private String toscaModelURL;
+ private String uuid;
+ private String invariantUUID;
+ private String name;
+ private String version;
+ private String toscaModelURL;
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getUuid()
- */
- @Override
- public String getUuid() {
- return uuid;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getUuid()
+ */
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setUuid(java.lang.String)
- */
- @Override
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setUuid(java.lang.String)
+ */
+ @Override
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getInvariantUUID()
- */
- @Override
- public String getInvariantUUID() {
- return invariantUUID;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getInvariantUUID()
+ */
+ @Override
+ public String getInvariantUUID() {
+ return invariantUUID;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setInvariantUUID(java.lang.String)
- */
- @Override
- public void setInvariantUUID(String invariantUUID) {
- this.invariantUUID = invariantUUID;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setInvariantUUID(java.lang.String)
+ */
+ @Override
+ public void setInvariantUUID(String invariantUUID) {
+ this.invariantUUID = invariantUUID;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getName()
- */
- @Override
- public String getName() {
- return name;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getName()
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setName(java.lang.String)
- */
- @Override
- public void setName(String name) {
- this.name = name;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setName(java.lang.String)
+ */
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getVersion()
- */
- @Override
- public String getVersion() {
- return version;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# getVersion()
+ */
+ @Override
+ public String getVersion() {
+ return version;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setVersion(java.lang.String)
- */
- @Override
- public void setVersion(String version) {
- this.version = version;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# setVersion(java.lang.String)
+ */
+ @Override
+ public void setVersion(String version) {
+ this.version = version;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# toscaModelURL()
- */
- @Override
- public String getToscaModelURL() {
- return toscaModelURL;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# toscaModelURL()
+ */
+ @Override
+ public String getToscaModelURL() {
+ return toscaModelURL;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# toscaModelURL(java.lang.String)
- */
- @Override
- public void setToscaModelURL(String toscaModelURL) {
- this.toscaModelURL = toscaModelURL;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.be.distribution.servlet.representation.IAssetMetadata# toscaModelURL(java.lang.String)
+ */
+ @Override
+ public void setToscaModelURL(String toscaModelURL) {
+ this.toscaModelURL = toscaModelURL;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/IAssetMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/IAssetMetadata.java
index f95a8e9684..319e16a294 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/IAssetMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/IAssetMetadata.java
@@ -22,24 +22,24 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
public interface IAssetMetadata {
- String getUuid();
+ String getUuid();
- void setUuid(String uuid);
+ void setUuid(String uuid);
- String getInvariantUUID();
+ String getInvariantUUID();
- void setInvariantUUID(String invariantUUID);
+ void setInvariantUUID(String invariantUUID);
- String getName();
+ String getName();
- void setName(String name);
+ void setName(String name);
- String getVersion();
+ String getVersion();
- void setVersion(String version);
+ void setVersion(String version);
- String getToscaModelURL();
+ String getToscaModelURL();
- void setToscaModelURL(String toscaModelURL);
+ void setToscaModelURL(String toscaModelURL);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadata.java
index d2d9c2c902..40b78c12d3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductAssetMetadata.java
@@ -23,50 +23,50 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
public class ProductAssetMetadata extends AssetMetadata {
- private String lifecycleState;
- private String lastUpdaterUserId;
- private boolean isActive;
- private List<String> contacts;
- private List<ProductCategoryGroupMetadata> productGroupings;
+ private String lifecycleState;
+ private String lastUpdaterUserId;
+ private boolean isActive;
+ private List<String> contacts;
+ private List<ProductCategoryGroupMetadata> productGroupings;
- public String getLifecycleState() {
- return lifecycleState;
- }
+ public String getLifecycleState() {
+ return lifecycleState;
+ }
- public void setLifecycleState(String lifecycleState) {
- this.lifecycleState = lifecycleState;
- }
+ public void setLifecycleState(String lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
- public String getLastUpdaterUserId() {
- return lastUpdaterUserId;
- }
+ public String getLastUpdaterUserId() {
+ return lastUpdaterUserId;
+ }
- public void setLastUpdaterUserId(String lastUpdaterUserId) {
- this.lastUpdaterUserId = lastUpdaterUserId;
- }
+ public void setLastUpdaterUserId(String lastUpdaterUserId) {
+ this.lastUpdaterUserId = lastUpdaterUserId;
+ }
- public boolean isActive() {
- return isActive;
- }
+ public boolean isActive() {
+ return isActive;
+ }
- public void setActive(boolean isActive) {
- this.isActive = isActive;
- }
+ public void setActive(boolean isActive) {
+ this.isActive = isActive;
+ }
- public List<String> getContacts() {
- return contacts;
- }
+ public List<String> getContacts() {
+ return contacts;
+ }
- public void setContacts(List<String> contacts) {
- this.contacts = contacts;
- }
+ public void setContacts(List<String> contacts) {
+ this.contacts = contacts;
+ }
- public List<ProductCategoryGroupMetadata> getProductGroupings() {
- return productGroupings;
- }
+ public List<ProductCategoryGroupMetadata> getProductGroupings() {
+ return productGroupings;
+ }
- public void setProductGroupings(List<ProductCategoryGroupMetadata> productGroupings) {
- this.productGroupings = productGroupings;
- }
+ public void setProductGroupings(List<ProductCategoryGroupMetadata> productGroupings) {
+ this.productGroupings = productGroupings;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadata.java
index 047f9d6a2c..7d666df703 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ProductCategoryGroupMetadata.java
@@ -21,37 +21,37 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
public class ProductCategoryGroupMetadata {
- private String category;
- private String subCategory;
- private String group;
-
- public ProductCategoryGroupMetadata(String category, String subCategory, String group) {
- this.category = category;
- this.subCategory = subCategory;
- this.group = group;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getSubCategory() {
- return subCategory;
- }
-
- public void setSubCategory(String subCategory) {
- this.subCategory = subCategory;
- }
-
- public String getGroup() {
- return group;
- }
-
- public void setGroup(String group) {
- this.group = group;
- }
+ private String category;
+ private String subCategory;
+ private String group;
+
+ public ProductCategoryGroupMetadata(String category, String subCategory, String group) {
+ this.category = category;
+ this.subCategory = subCategory;
+ this.group = group;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getSubCategory() {
+ return subCategory;
+ }
+
+ public void setSubCategory(String subCategory) {
+ this.subCategory = subCategory;
+ }
+
+ public String getGroup() {
+ return group;
+ }
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadata.java
index 0952feea05..eb15e077de 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetDetailedMetadata.java
@@ -24,50 +24,50 @@ import java.util.List;
public class ResourceAssetDetailedMetadata extends ResourceAssetMetadata {
- private String lastUpdaterFullName;
- private String toscaResourceName;
- private List<ResourceInstanceMetadata> resources;
- private List<ArtifactMetadata> artifacts;
- private String description;
+ private String lastUpdaterFullName;
+ private String toscaResourceName;
+ private List<ResourceInstanceMetadata> resources;
+ private List<ArtifactMetadata> artifacts;
+ private String description;
- public String getLastUpdaterFullName() {
- return lastUpdaterFullName;
- }
+ public String getLastUpdaterFullName() {
+ return lastUpdaterFullName;
+ }
- public void setLastUpdaterFullName(String lastUpdaterFullName) {
- this.lastUpdaterFullName = lastUpdaterFullName;
- }
+ public void setLastUpdaterFullName(String lastUpdaterFullName) {
+ this.lastUpdaterFullName = lastUpdaterFullName;
+ }
- public String getToscaResourceName() {
- return toscaResourceName;
- }
+ public String getToscaResourceName() {
+ return toscaResourceName;
+ }
- public void setToscaResourceName(String toscaResourceName) {
- this.toscaResourceName = toscaResourceName;
- }
+ public void setToscaResourceName(String toscaResourceName) {
+ this.toscaResourceName = toscaResourceName;
+ }
- public List<ResourceInstanceMetadata> getResources() {
- return resources;
- }
+ public List<ResourceInstanceMetadata> getResources() {
+ return resources;
+ }
- public void setResources(List<ResourceInstanceMetadata> resources) {
- this.resources = resources;
- }
+ public void setResources(List<ResourceInstanceMetadata> resources) {
+ this.resources = resources;
+ }
- public List<ArtifactMetadata> getArtifacts() {
- return artifacts;
- }
+ public List<ArtifactMetadata> getArtifacts() {
+ return artifacts;
+ }
- public void setArtifacts(List<ArtifactMetadata> artifactMetaList) {
- this.artifacts = artifactMetaList;
- }
+ public void setArtifacts(List<ArtifactMetadata> artifactMetaList) {
+ this.artifacts = artifactMetaList;
+ }
- public String getDescription() {
- return description;
- }
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
- public void setDescription(String description) {
- this.description = description;
- }
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadata.java
index 2b75facc6c..455e125ffc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceAssetMetadata.java
@@ -21,49 +21,49 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
public class ResourceAssetMetadata extends AssetMetadata {
- private String category;
- private String subCategory;
- private String resourceType;
- private String lifecycleState;
- private String lastUpdaterUserId;
+ private String category;
+ private String subCategory;
+ private String resourceType;
+ private String lifecycleState;
+ private String lastUpdaterUserId;
- public String getCategory() {
- return category;
- }
+ public String getCategory() {
+ return category;
+ }
- public void setCategory(String category) {
- this.category = category;
- }
+ public void setCategory(String category) {
+ this.category = category;
+ }
- public String getSubCategory() {
- return subCategory;
- }
+ public String getSubCategory() {
+ return subCategory;
+ }
- public void setSubCategory(String subCategory) {
- this.subCategory = subCategory;
- }
+ public void setSubCategory(String subCategory) {
+ this.subCategory = subCategory;
+ }
- public String getResourceType() {
- return resourceType;
- }
+ public String getResourceType() {
+ return resourceType;
+ }
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
- public String getLifecycleState() {
- return lifecycleState;
- }
+ public String getLifecycleState() {
+ return lifecycleState;
+ }
- public void setLifecycleState(String lifecycleState) {
- this.lifecycleState = lifecycleState;
- }
+ public void setLifecycleState(String lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
- public String getLastUpdaterUserId() {
- return lastUpdaterUserId;
- }
+ public String getLastUpdaterUserId() {
+ return lastUpdaterUserId;
+ }
- public void setLastUpdaterUserId(String lastUpdaterUserId) {
- this.lastUpdaterUserId = lastUpdaterUserId;
- }
+ public void setLastUpdaterUserId(String lastUpdaterUserId) {
+ this.lastUpdaterUserId = lastUpdaterUserId;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadata.java
index a53422f311..1023f82249 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ResourceInstanceMetadata.java
@@ -23,67 +23,67 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
public class ResourceInstanceMetadata {
- private String resourceInstanceName;
- private String resourceName;
- private String resourceInvariantUUID;
- private String resourceVersion;
- private String resoucreType;
- private String resourceUUID;
- private List<ArtifactMetadata> artifacts;
-
- public String getResourceInstanceName() {
- return resourceInstanceName;
- }
-
- public void setResourceInstanceName(String resourceInstanceName) {
- this.resourceInstanceName = resourceInstanceName;
- }
-
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- public String getResourceInvariantUUID() {
- return resourceInvariantUUID;
- }
-
- public void setResourceInvariantUUID(String resourceInvariantUUID) {
- this.resourceInvariantUUID = resourceInvariantUUID;
- }
-
- public String getResourceVersion() {
- return resourceVersion;
- }
-
- public void setResourceVersion(String resourceVersion) {
- this.resourceVersion = resourceVersion;
- }
-
- public String getResoucreType() {
- return resoucreType;
- }
-
- public void setResoucreType(String resoucreType) {
- this.resoucreType = resoucreType;
- }
-
- public String getResourceUUID() {
- return resourceUUID;
- }
-
- public void setResourceUUID(String resourceUUID) {
- this.resourceUUID = resourceUUID;
- }
-
- public List<ArtifactMetadata> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(List<ArtifactMetadata> artifacts) {
- this.artifacts = artifacts;
- }
+ private String resourceInstanceName;
+ private String resourceName;
+ private String resourceInvariantUUID;
+ private String resourceVersion;
+ private String resoucreType;
+ private String resourceUUID;
+ private List<ArtifactMetadata> artifacts;
+
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceInvariantUUID() {
+ return resourceInvariantUUID;
+ }
+
+ public void setResourceInvariantUUID(String resourceInvariantUUID) {
+ this.resourceInvariantUUID = resourceInvariantUUID;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getResoucreType() {
+ return resoucreType;
+ }
+
+ public void setResoucreType(String resoucreType) {
+ this.resoucreType = resoucreType;
+ }
+
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ public List<ArtifactMetadata> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List<ArtifactMetadata> artifacts) {
+ this.artifacts = artifacts;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadata.java
index edd88b495d..e677fdc190 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetDetailedMetadata.java
@@ -23,31 +23,31 @@ package org.openecomp.sdc.be.externalapi.servlet.representation;
import java.util.List;
public class ServiceAssetDetailedMetadata extends ServiceAssetMetadata {
- private String lastUpdaterFullName;
- private List<ResourceInstanceMetadata> resources;
- private List<ArtifactMetadata> artifacts;
+ private String lastUpdaterFullName;
+ private List<ResourceInstanceMetadata> resources;
+ private List<ArtifactMetadata> artifacts;
- public String getLastUpdaterFullName() {
- return lastUpdaterFullName;
- }
+ public String getLastUpdaterFullName() {
+ return lastUpdaterFullName;
+ }
- public void setLastUpdaterFullName(String lastUpdaterFullName) {
- this.lastUpdaterFullName = lastUpdaterFullName;
- }
+ public void setLastUpdaterFullName(String lastUpdaterFullName) {
+ this.lastUpdaterFullName = lastUpdaterFullName;
+ }
- public List<ResourceInstanceMetadata> getResources() {
- return resources;
- }
+ public List<ResourceInstanceMetadata> getResources() {
+ return resources;
+ }
- public void setResources(List<ResourceInstanceMetadata> resources) {
- this.resources = resources;
- }
+ public void setResources(List<ResourceInstanceMetadata> resources) {
+ this.resources = resources;
+ }
- public List<ArtifactMetadata> getArtifacts() {
- return artifacts;
- }
+ public List<ArtifactMetadata> getArtifacts() {
+ return artifacts;
+ }
- public void setArtifacts(List<ArtifactMetadata> artifacts) {
- this.artifacts = artifacts;
- }
+ public void setArtifacts(List<ArtifactMetadata> artifacts) {
+ this.artifacts = artifacts;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadata.java
index 094f973553..6e5ac8426c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceAssetMetadata.java
@@ -21,40 +21,40 @@
package org.openecomp.sdc.be.externalapi.servlet.representation;
public class ServiceAssetMetadata extends AssetMetadata {
- private String category;
- private String lifecycleState;
- private String lastUpdaterUserId;
- private String distributionStatus;
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getLifecycleState() {
- return lifecycleState;
- }
-
- public void setLifecycleState(String lifecycleState) {
- this.lifecycleState = lifecycleState;
- }
-
- public String getLastUpdaterUserId() {
- return lastUpdaterUserId;
- }
-
- public void setLastUpdaterUserId(String lastUpdaterUserId) {
- this.lastUpdaterUserId = lastUpdaterUserId;
- }
-
- public String getDistributionStatus() {
- return distributionStatus;
- }
-
- public void setDistributionStatus(String distributionStatus) {
- this.distributionStatus = distributionStatus;
- }
+ private String category;
+ private String lifecycleState;
+ private String lastUpdaterUserId;
+ private String distributionStatus;
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getLifecycleState() {
+ return lifecycleState;
+ }
+
+ public void setLifecycleState(String lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+ public String getLastUpdaterUserId() {
+ return lastUpdaterUserId;
+ }
+
+ public void setLastUpdaterUserId(String lastUpdaterUserId) {
+ this.lastUpdaterUserId = lastUpdaterUserId;
+ }
+
+ public String getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ public void setDistributionStatus(String distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionReqInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionReqInfo.java
new file mode 100644
index 0000000000..5557c7a609
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionReqInfo.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+/**
+ * Created by chaya on 10/26/2017.
+ */
+public class ServiceDistributionReqInfo {
+
+ private String workloadContext;
+
+ public ServiceDistributionReqInfo() {
+ }
+ public ServiceDistributionReqInfo(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfo.java
new file mode 100644
index 0000000000..3fa54c3654
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/representation/ServiceDistributionRespInfo.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.be.externalapi.servlet.representation;
+
+/**
+ * Created by chaya on 10/26/2017.
+ */
+public class ServiceDistributionRespInfo {
+
+ private String distributionId;
+
+ public ServiceDistributionRespInfo() {
+ }
+
+ public ServiceDistributionRespInfo(String distributionId) {
+ this.distributionId = distributionId;
+ }
+
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ public void setDistributionId(String distributionId) {
+ this.distributionId = distributionId;
+ }
+}