diff options
author | shrikantawachar <shrikant.awachar@amdocs.com> | 2018-03-08 13:33:17 +0530 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-03-08 08:46:07 +0000 |
commit | 2b60bd08c6b209c0817fac84970c35df4abca6ed (patch) | |
tree | 46483522798ca139bce9ce8c08c988001aad730d /openecomp-be/api | |
parent | 9a79dcedfaaf173d2f301bb18b1832a799b1bc2f (diff) |
Download processed file
Download processed file
Change-Id: Ieaaea0ce231bc0418d9d997d652f85f1743031f0
Issue-ID: SDC-1087
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'openecomp-be/api')
2 files changed, 25 insertions, 8 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/OrchestrationTemplateCandidate.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/OrchestrationTemplateCandidate.java index cb3abeebc2..ee9ab56b15 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/OrchestrationTemplateCandidate.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/OrchestrationTemplateCandidate.java @@ -64,8 +64,8 @@ public interface OrchestrationTemplateCandidate extends VspEntities { @GET @Path("/") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation(value = "Get uploaded candidate HEAT file", - notes = "Downloads in process candidate HEAT file", + @ApiOperation(value = "Get uploaded Network Package file", + notes = "Downloads in uploaded Network Package file", response = File.class) Response get( @PathParam("vspId") String vspId, 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 d856cfc6e5..a152e44f98 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 @@ -25,6 +25,10 @@ import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.activitylog.dao.type.ActivityType; import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; @@ -54,12 +58,14 @@ import java.util.Optional; import static org.openecomp.core.utilities.file.FileUtils.getFileExtension; import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName; +import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; @Named @Service("orchestrationTemplateCandidate") @Scope(value = "prototype") public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate { - + private static final Logger LOGGER = + LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); private OrchestrationTemplateCandidateManager candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); private VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory @@ -84,13 +90,24 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate @Override public Response get(String vspId, String versionId, String user) throws IOException { Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId)); - - if (!zipFile.isPresent()) { - return Response.status(Response.Status.NOT_FOUND).build(); + String fileName = null; + if (zipFile.isPresent()) { + fileName = "Candidate." + zipFile.get().getLeft(); + } else { + zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId))); + + if (!zipFile.isPresent()) { + ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, + getErrorWithParameters( + Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), + "")); + LOGGER.error(errorMessage.getMessage()); + return Response.status(Response.Status.NOT_FOUND).build(); + } + fileName = "Processed." + zipFile.get().getLeft(); } Response.ResponseBuilder response = Response.ok(zipFile.get().getRight()); - String filename = "Candidate." + zipFile.get().getLeft(); - response.header("Content-Disposition", "attachment; filename=" + filename); + response.header("Content-Disposition", "attachment; filename=" + fileName); return response.build(); } |