diff options
Diffstat (limited to 'openecomp-be')
5 files changed, 132 insertions, 38 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java index 1a68d49479..c51fcc452b 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/VendorSoftwareProducts.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/VendorSoftwareProducts.java @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -35,8 +32,6 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import java.io.File; -import java.io.IOException; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.ws.rs.Consumes; @@ -51,6 +46,11 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.File; +import java.io.IOException; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -206,4 +206,20 @@ public interface VendorSoftwareProducts extends VspEntities { @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/reSubmitAll") + @ApiOperation(value = "Performs check out, check in and submit for ALL submitted VSPs", notes + = "Please note - only submitted VSPs will be processed") + Response reSubmitAll(@NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; + + @PUT + @Path("/{vspId}/reSubmit") + @ApiOperation(value = "Performs check out, check in and submit for a specific Vendor Software " + + "Product") + Response reSubmit(@PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws IOException; } 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/VendorSoftwareProductsImpl.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/VendorSoftwareProductsImpl.java index 0b73cbcee6..27d4405fc7 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/VendorSoftwareProductsImpl.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/VendorSoftwareProductsImpl.java @@ -45,6 +45,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; import org.openecomp.sdc.versioning.types.VersionInfo; import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; @@ -86,35 +87,35 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - @Override - public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { - MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); - logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP - + vspDescriptionDto.getName()); + @Override + public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + + vspDescriptionDto.getName()); + + VspCreationDto vspCreationDto = null; + OnboardingMethod onboardingMethod = OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod()); + if (onboardingMethod == null){ + return handleUnkownOnboardingMethod(); + } + switch (onboardingMethod) { + case NetworkPackage: + case Manual: + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails(). + applyMapping(vspDescriptionDto, VspDetails.class); - VspCreationDto vspCreationDto = null; - OnboardingMethod onboardingMethod = OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod()); - if (onboardingMethod == null){ - return handleUnkownOnboardingMethod(); - } - switch (onboardingMethod) { - case NetworkPackage: - case Manual: - VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails(). - applyMapping(vspDescriptionDto, VspDetails.class); - - vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); - - MapVspDetailsToVspCreationDto mapping = new MapVspDetailsToVspCreationDto(); - vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); - break; - default: - return handleUnkownOnboardingMethod(); - } + vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); - return Response.ok(vspCreationDto).build(); + MapVspDetailsToVspCreationDto mapping = new MapVspDetailsToVspCreationDto(); + vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + break; + default: + return handleUnkownOnboardingMethod(); } + return Response.ok(vspCreationDto).build(); + } + private Response handleUnkownOnboardingMethod() { ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder .getInvalidOnboardingMethodErrorBuilder(); @@ -363,14 +364,14 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { vendorSoftwareProductManager.getInformationArtifact(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); - Response.ResponseBuilder response = Response.ok(textInformationArtifact); - if (textInformationArtifact == null) { - return Response.status(Response.Status.NOT_FOUND).build(); - } - response - .header("Content-Disposition", "attachment; filename=" + textInformationArtifact.getName()); - return response.build(); + Response.ResponseBuilder response = Response.ok(textInformationArtifact); + if (textInformationArtifact == null) { + return Response.status(Response.Status.NOT_FOUND).build(); } + response + .header("Content-Disposition", "attachment; filename=" + textInformationArtifact.getName()); + return response.build(); + } public Response listCompute(String vspId, String version, String user) { @@ -386,8 +387,69 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { return Response.ok(results).build(); } - private void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) { + @Override + public Response reSubmitAll(String user) throws IOException { + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Re_Submit_ALL_Final_VSPs.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.RESUBMIT_ALL_FINAL_VSPS); + + + List<VersionedVendorSoftwareProductInfo> vspList = + vendorSoftwareProductManager.listVsps(null, user); + + for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) { + String vspId = versionVspInfo.getVspDetails().getId(); + if (versionVspInfo.getVersionInfo().getStatus().equals(VersionStatus.Final)) { + final Version latestFinalVersion = + getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion(); + if (latestFinalVersion != null) { + reSubmit(vspId, user); + } + } + } + + return Response.ok().build(); + } + + @Override + public Response reSubmit(String vspId, String user) + throws IOException { + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_VSP.toString()); + vendorSoftwareProductManager.checkout(vspId, user); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VSP + vspId); + + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkin_VSP.toString()); + vendorSoftwareProductManager.checkin(vspId, user); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VSP + vspId); + + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Submit_VSP.toString()); + ValidationResponse validationResponse = vendorSoftwareProductManager.submit(vspId, user); + if (!validationResponse.isValid()) { + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP_FAIL + vspId); + logAuditErrors(vspId, validationResponse); + + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapValidationResponseToDto() + .applyMapping(validationResponse, ValidationResponseDto.class)).build(); + } + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId); + + + return Response.ok().build(); + } + + private void logAuditErrors(String vspId, ValidationResponse validationResponse) { + if (validationResponse.getVspErrors() != null) { + validationResponse.getVspErrors().forEach(errorCode -> logger.audit(AuditMessages + .AUDIT_MSG + String.format(SUBMIT_VSP_ERROR, errorCode.message(), vspId))); + } + if (validationResponse.getUploadDataErrors() != null) { + validationResponse.getUploadDataErrors().values().forEach(errorMessages + -> VendorSoftwareProductsImpl.printAuditForErrors(errorMessages, vspId, + SUBMIT_VSP_ERROR)); + } + } + private static void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) { errorList.forEach(errorMessage -> { if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) { logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(), diff --git a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java index 387b2046fd..d562ae5dd8 100644 --- a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java +++ b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java @@ -15,6 +15,8 @@ public class AuditMessages { public static final String CREATE_VSP = "Create VSP. VSP Name: "; public static final String CHECK_IN_VSP = "Check in VSP. VSP Id: "; public static final String CHECK_OUT_VSP = "Check out VSP. VSP Id: "; + public static final String RESUBMIT_ALL_FINAL_VSPS = "Check out, check in and submit all " + + "submitted VSPs, see ids below "; public static final String SUBMIT_VSP = "Submit VSP. VSP Id: "; public static final String SUBMIT_VSP_FAIL = "Submit VSP failed!. VSP Id: "; public static final String SUBMIT_VSP_ERROR = "Submit VSP error: %s. VSP Id: %s"; diff --git a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java index c6d9ebb77f..e72d66aac9 100644 --- a/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java +++ b/openecomp-be/lib/openecomp-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java @@ -70,6 +70,7 @@ public enum LoggerServiceName { Undo_Checkout_VSP, Submit_VSP, Update_VSP, + Re_Submit_ALL_Final_VSPs, Create_Package, List_VSP, Upload_File, diff --git a/openecomp-be/tools/migration/resubmit.sh b/openecomp-be/tools/migration/resubmit.sh new file mode 100644 index 0000000000..64164a3327 --- /dev/null +++ b/openecomp-be/tools/migration/resubmit.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +########################################################################################################### +# script name - resubmit.sh +# run script - ./resubmit.sh +# this script performs check out, check in, submit for all submitted Vendor Software Products +# working vs. localhost +########################################################################################################### + + +# check out, check in, submit for all submitted Vendor Software Products +curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" "http://localhost:8080/onboarding-api/v1.0/vendor-software-products/reSubmitAll" + |