summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidateUploadManagerController.java15
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/controllers/OrchestrationTemplateCandidateUploadManagerControllerImpl.java9
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/exception/OrchestrationTemplateCandidateUploadManagerExceptionSupplier.java2
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java17
4 files changed, 41 insertions, 2 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidateUploadManagerController.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidateUploadManagerController.java
index 971a1c42b5..19c27e4c56 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidateUploadManagerController.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidateUploadManagerController.java
@@ -31,6 +31,7 @@ import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
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;
@@ -62,4 +63,18 @@ public interface OrchestrationTemplateCandidateUploadManagerController extends V
@Parameter(description = "Vendor Software Product version id") @PathParam("versionId") String versionId,
@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
+ /**
+ * Creates the upload lock, setting the status to upload in progress.
+ *
+ * @param vspId the vsp id
+ * @param versionId the vsp version id
+ * @param user the username accessing the API
+ * @return if successful, an OK response with the created VspUploadStatus information
+ */
+ @POST
+ @Path("/")
+ Response createUploadLock(@Parameter(description = "Vendor Software Product id") @PathParam("vspId") String vspId,
+ @Parameter(description = "Vendor Software Product version id") @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/controllers/OrchestrationTemplateCandidateUploadManagerControllerImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/controllers/OrchestrationTemplateCandidateUploadManagerControllerImpl.java
index f96522aa75..aec877d777 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/controllers/OrchestrationTemplateCandidateUploadManagerControllerImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/controllers/OrchestrationTemplateCandidateUploadManagerControllerImpl.java
@@ -55,6 +55,15 @@ public class OrchestrationTemplateCandidateUploadManagerControllerImpl implement
return Response.ok(vspUploadStatus.get()).build();
}
+ public Response createUploadLock(String vspId, String versionId, String user) {
+ vspId = ValidationUtils.sanitizeInputString(vspId);
+ versionId = ValidationUtils.sanitizeInputString(versionId);
+ user = ValidationUtils.sanitizeInputString(user);
+
+ final VspUploadStatusDto vspUploadStatus = orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user);
+ return Response.status(Status.CREATED).entity(vspUploadStatus).build();
+ }
+
/**
* Builds the string representing the get API url.
*
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/exception/OrchestrationTemplateCandidateUploadManagerExceptionSupplier.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/exception/OrchestrationTemplateCandidateUploadManagerExceptionSupplier.java
index 643f59bffb..bea478cfef 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/exception/OrchestrationTemplateCandidateUploadManagerExceptionSupplier.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/exception/OrchestrationTemplateCandidateUploadManagerExceptionSupplier.java
@@ -44,7 +44,7 @@ public class OrchestrationTemplateCandidateUploadManagerExceptionSupplier {
}
public static Supplier<CoreException> vspUploadAlreadyInProgress(final String vspId, final String vspVersionId) {
- final String errorMsg = String.format("There is a processing in progress for the VSP '%s', version '%s'", vspId, vspVersionId);
+ final String errorMsg = String.format("Upload already in progress for the VSP '%s', version '%s'", vspId, vspVersionId);
return () -> new CoreException(new ErrorCodeBuilder().withId(VSP_PROCESSING_IN_PROGRESS).withMessage(errorMsg).build());
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index 01d2a59e45..93483f3de1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -30,6 +30,7 @@ import static org.openecomp.sdc.common.errors.Messages.ERROR_HAS_OCCURRED_WHILE_
import static org.openecomp.sdc.common.errors.Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST;
import static org.openecomp.sdc.common.errors.Messages.PACKAGE_PROCESS_ERROR;
import static org.openecomp.sdc.common.errors.Messages.UNEXPECTED_PROBLEM_HAPPENED_WHILE_GETTING;
+import static org.openecomp.sdcrests.vsp.rest.exception.OrchestrationTemplateCandidateUploadManagerExceptionSupplier.vspUploadAlreadyInProgress;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -144,7 +145,11 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
final Response response;
VspUploadStatusDto vspUploadStatus = null;
try {
- vspUploadStatus = orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user);
+ vspUploadStatus = getVspUploadStatus(vspId, versionId, user);
+
+ if (vspUploadStatus.getStatus() != VspUploadStatus.UPLOADING) {
+ throw vspUploadAlreadyInProgress(vspId, versionId).get();
+ }
final byte[] fileToUploadBytes;
final DataHandler dataHandler = fileToUpload.getDataHandler();
final var filename = ValidationUtils.sanitizeInputString(dataHandler.getName());
@@ -199,6 +204,16 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
return response;
}
+ private VspUploadStatusDto getVspUploadStatus(final String vspId, final String versionId, final String user) {
+ final Optional<VspUploadStatusDto> vspUploadStatusOpt =
+ orchestrationTemplateCandidateUploadManager.findLatestStatus(vspId, versionId, user);
+ if (vspUploadStatusOpt.isEmpty() || vspUploadStatusOpt.get().isComplete()) {
+ return orchestrationTemplateCandidateUploadManager.putUploadInProgress(vspId, versionId, user);
+ }
+
+ return vspUploadStatusOpt.get();
+ }
+
private ArtifactInfo handleArtifactStorage(final String vspId, final String versionId, final String filename,
final DataHandler artifactDataHandler) {
final Path tempArtifactPath;