diff options
author | 2022-01-18 10:16:37 +0000 | |
---|---|---|
committer | 2022-01-25 09:57:30 +0000 | |
commit | 3ba359e291789363ce2670c72da8eaa9caa5f956 (patch) | |
tree | bc3358369990f40b7ce994ab454094fc5b062270 /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 | |
parent | d77bdf472a4fb5b6cf8e17f2d0d8e8d2bababeaf (diff) |
Update onboarding upload status during processing
Updates the onboarding upload status during the VSP package processing
Change-Id: Idc705220ad26e62577b52c6f9126aeae51a33fe0
Issue-ID: SDC-3848
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to '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')
1 files changed, 32 insertions, 4 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/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 2eb0261a1b..643f59bffb 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 @@ -25,7 +25,9 @@ import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProdu import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_PROCESSING_IN_PROGRESS; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_UPDATE_UPLOAD_LOCK_ERROR; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_UPLOAD_ALREADY_FINISHED_ERROR; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_UPLOAD_ALREADY_IN_STATUS_ERROR; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_UPLOAD_LOCK_NOT_FOUND_ERROR; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_UPLOAD_STATUS_NOT_FOUND_ERROR; import java.util.UUID; import java.util.function.Supplier; @@ -42,12 +44,19 @@ 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("There is a processing in progress for the VSP '%s', version '%s'", vspId, vspVersionId); return () -> new CoreException(new ErrorCodeBuilder().withId(VSP_PROCESSING_IN_PROGRESS).withMessage(errorMsg).build()); } public static Supplier<CoreException> couldNotCreateLock(final String vspId, final String vspVersionId, final Exception exception) { - final String errorMsg = String.format("Could not create a lock for the VSP %s, version %s", vspId, vspVersionId); + final String errorMsg = String.format("Could not create a lock for the VSP '%s', version '%s'", vspId, vspVersionId); + final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_CREATE_UPLOAD_LOCK_ERROR).withMessage(errorMsg).build(); + return () -> new CoreException(errorCode, exception); + } + + public static Supplier<CoreException> couldNotUpdateStatus(final String vspId, final String vspVersionId, final VspUploadStatus status, + final Exception exception) { + final String errorMsg = String.format("Could not update upload status for the VSP '%s', version '%s', to '%s'", vspId, vspVersionId, status); final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_CREATE_UPLOAD_LOCK_ERROR).withMessage(errorMsg).build(); return () -> new CoreException(errorCode, exception); } @@ -59,11 +68,23 @@ public class OrchestrationTemplateCandidateUploadManagerExceptionSupplier { } public static Supplier<CoreException> couldNotFindLock(final UUID lockId, final String vspId, final String vspVersionId) { - final String errorMsg = String.format("Could not find lock '%s' for the VSP %s, version %s", lockId, vspId, vspVersionId); + final String errorMsg = String.format("Could not find lock '%s' for the VSP '%s', version '%s'", lockId, vspId, vspVersionId); final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_UPLOAD_LOCK_NOT_FOUND_ERROR).withMessage(errorMsg).build(); return () -> new CoreException(errorCode); } + public static Supplier<CoreException> couldNotFindStatus(final String vspId, final String vspVersionId) { + final String errorMsg = String.format("Could not find upload status for the VSP '%s', version '%s'", vspId, vspVersionId); + final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_UPLOAD_STATUS_NOT_FOUND_ERROR).withMessage(errorMsg).build(); + return () -> new CoreException(errorCode); + } + + public static Supplier<CoreException> alreadyInStatusBeingUpdated(final String vspId, final String vspVersionId, final VspUploadStatus status) { + final String errorMsg = String.format("The upload for the VSP '%s', version '%s' is already in the status '%s'", status, vspId, vspVersionId); + final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_UPLOAD_ALREADY_IN_STATUS_ERROR).withMessage(errorMsg).build(); + return () -> new CoreException(errorCode); + } + public static Supplier<CoreException> uploadAlreadyFinished(final UUID lockId, final String vspId, final String vspVersionId) { final String errorMsg = String.format("The upload was already finished for lock '%s', VSP '%s', version '%s'", lockId, vspId, vspVersionId); final ErrorCode errorCode = new ErrorCodeBuilder().withId(VSP_UPLOAD_ALREADY_FINISHED_ERROR).withMessage(errorMsg).build(); @@ -75,10 +96,17 @@ public class OrchestrationTemplateCandidateUploadManagerExceptionSupplier { } public static Supplier<IllegalArgumentException> invalidCompleteStatus(final VspUploadStatus status) { - String errorMsg = String.format("Invalid complete status '%s'. Expecting one of: %s", + final String errorMsg = String.format("Invalid complete status '%s'. Expecting one of: %s", status, VspUploadStatus.getCompleteStatus().stream().map(Enum::name).collect(Collectors.joining(", ")) ); return () -> new IllegalArgumentException(errorMsg); } + + public static Supplier<IllegalArgumentException> invalidCompletionStatus(final VspUploadStatus status) { + final String errorMsg = String.format("Can't update to a status that represents a upload completion as '%s'", status); + return () -> new IllegalArgumentException(errorMsg); + } + + } |