aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Gaffa <avi.gaffa@amdocs.com>2017-10-09 10:22:16 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-09 10:22:16 +0000
commit1dc6dfd90d4208a2f63b0bc0860f762ed243e90e (patch)
tree31955eff553ccaa6f14458a1b8ff44b0eb56e679
parentc896f8387e1331098d9550d57ab0e14ce7c1d621 (diff)
parent723cec335bf69d656c8c3e53cd9c10422121c9ca (diff)
Merge "Fix VSP resubmit logic"
-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/VendorSoftwareProducts.java13
-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/VendorSoftwareProductsImpl.java101
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java45
4 files changed, 87 insertions, 77 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 c51fcc452b..20fe64b88f 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
@@ -209,17 +209,10 @@ public interface VendorSoftwareProducts extends VspEntities {
@PUT
@Path("/reSubmitAll")
- @ApiOperation(value = "Performs check out, check in and submit for ALL submitted VSPs", notes
+ @ApiOperation(value = "Performs healing ,check out, check in and submit for Network Package " +
+ "Based 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 27d4405fc7..4167785c02 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
@@ -48,7 +48,15 @@ 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.*;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.OnboardingMethod;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts;
import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto;
import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto;
@@ -69,6 +77,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
+import java.util.Objects;
import static org.openecomp.sdc.logging.messages.AuditMessages.SUBMIT_VSP_ERROR;
@@ -94,8 +103,9 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
+ vspDescriptionDto.getName());
VspCreationDto vspCreationDto = null;
- OnboardingMethod onboardingMethod = OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod());
- if (onboardingMethod == null){
+ OnboardingMethod onboardingMethod =
+ OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod());
+ if (onboardingMethod == null) {
return handleUnkownOnboardingMethod();
}
switch (onboardingMethod) {
@@ -155,7 +165,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- //
+
if (vspDetails.getOldVersion() != null && !"".equals(vspDetails.getOldVersion())) {
if (Version.valueOf(versionId).equals(versionInfo.getActiveVersion())) {
try {
@@ -389,67 +399,68 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
@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 = Objects.requireNonNull(
+ vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), user));
- List<VersionedVendorSoftwareProductInfo> vspList =
- vendorSoftwareProductManager.listVsps(null, user);
+ int healingCounter = 0;
+ int failedCounter = 0;
+
+ try {
+
+ logger.info("Total number of VSPs: {}. Performing healing and " +
+ "resubmit for all non-Manual VSPs in submitted status.\n No need to pre-set oldVersion " +
+ "field", vspList.size());
- for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) {
- String vspId = versionVspInfo.getVspDetails().getId();
- if (versionVspInfo.getVersionInfo().getStatus().equals(VersionStatus.Final)) {
+ for (VersionedVendorSoftwareProductInfo versionVspInfo : vspList) {
+
+ final VspDetails vspDetails = versionVspInfo.getVspDetails();
+ final String vspId = vspDetails.getId();
final Version latestFinalVersion =
getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion();
- if (latestFinalVersion != null) {
- reSubmit(vspId, user);
+
+ if (Objects.nonNull(latestFinalVersion) &&
+ (!OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod()))) {
+ reSubmit(vspDetails, user);
+ healingCounter++;
}
}
+
+ } catch (Exception e) {
+ logger.error("Failed during resubmitAll", e);
+ failedCounter++;
+ } finally {
+ logger.info("Finished attempted healing and resubmit for {} VSPs out " +
+ "of total # of {} submitted VSPs. Failure count during resubmitAll: {}",
+ healingCounter, vspList.size(), failedCounter);
}
+
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);
+ private void reSubmit(VspDetails vspDetails, String user) throws IOException {
+ final String vspId = vspDetails.getId();
+ long startTime = System.currentTimeMillis();
+ logger.info("Starting on healing and resubmit for VSP id[{}]", vspId);
+ vspDetails.setOldVersion("true");
- return Response.ok().build();
- }
+ vendorSoftwareProductManager.healAndAdvanceFinalVersion(vspId, vspDetails, user);
- 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));
- }
+ long endTime = System.currentTimeMillis();
+ long seconds = (endTime - startTime) / 1000;
+
+ logger.info("Completed healing and resubmit for VSP id [{}], duration: {} seconds",
+ vspId, seconds);
}
- private static void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
+ 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/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 738e267ca0..0adca1c695 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -34,7 +34,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
-public interface VendorSoftwareProductManager {
+public interface VendorSoftwareProductManager {
Version checkout(String vendorSoftwareProductId, String user);
@@ -78,4 +78,7 @@ public interface VendorSoftwareProductManager {
String fetchValidationVsp(String user);
Collection<ComputeEntity> getComputeByVsp(String vspId, Version version, String user);
+
+ Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
+ String user) throws IOException;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index f4015ab848..0a3428579d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -634,7 +634,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
try {
validateUniqueName(VALIDATION_VSP_NAME);
} catch (Exception ignored) {
- logger.debug("",ignored);
+ logger.debug("", ignored);
return VALIDATION_VSP_ID;
}
VspDetails validationVsp = new VspDetails();
@@ -708,7 +708,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
}
} catch (RuntimeException rte) {
- logger.debug("",rte);
+ logger.debug("", rte);
logger.error(
"Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
() + "] " +
@@ -789,8 +789,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
}
vsp.setValidationData(orchestrationTemplateDao.getValidationData(vspId, version));
-
- if (Objects.isNull(vsp.getOnboardingOrigin())) {
+ if (Objects.isNull(vsp.getOnboardingOrigin())) { //todo should this only be done for non-Manual?
vsp.setOnboardingOrigin(OnboardingTypesEnum.ZIP.toString());
}
@@ -818,22 +817,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
return checkin(vspId, user);
case Final:
- Version checkoutFinalVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutFinalVersion, vendorSoftwareProductInfo, user);
- Version checkinFinalVersion = checkin(vspId, user);
- ValidationResponse response = submit(vspId, user);
- if (!response.isValid()) {
- return checkout(vspId, user);
- }
-
- try {
- Version finalVersion = checkinFinalVersion.calculateNextFinal();
- createPackage(vspId, finalVersion, user);
- return finalVersion;
- } catch (IOException ex) {
- logger.debug("",ex);
- throw new Exception(ex.getMessage());
- }
+ return healAndAdvanceFinalVersion(vspId, vendorSoftwareProductInfo, user);
default:
//do nothing
break;
@@ -841,8 +825,27 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return versionInfo.getActiveVersion();
}
- @Override
+ public Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
+ String user) throws IOException {
+
+ Version checkoutFinalVersion = checkout(vspId, user);
+ autoHeal(vspId, checkoutFinalVersion, vendorSoftwareProductInfo, user);
+ Version checkinFinalVersion = checkin(vspId, user);
+
+ ValidationResponse response = Objects.requireNonNull(submit(vspId, user),
+ "Null response not expected");
+ if (!response.isValid()) {
+ return checkout(vspId, user);
+ }
+
+ Version finalVersion = checkinFinalVersion.calculateNextFinal();
+ createPackage(vspId, finalVersion, user);
+ return finalVersion;
+
+ }
+
+ @Override
public void deleteVsp(String vspId, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);