summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java21
3 files changed, 19 insertions, 9 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 038778be88..f994652751 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -53,7 +53,7 @@ public enum Messages {
MODULE_IN_MANIFEST_VOL_ENV_NO_VOL("Module '%s', has volume Env. reference with no Volume " +
"reference"),
ILLEGAL_MANIFEST("Illegal Manifest"),
- NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST("no zip file was uploaded or zip file doesn't exist"),
+ NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST("no %s file was uploaded or file doesn't exist"),
MAPPING_OBJECTS_FAILURE("Failed to map object %s to %s. Exception message: %s"),
MORE_THEN_ONE_VOL_FOR_HEAT("heat contains more then one vol. selecting only first vol"),
FILE_CONTENT_MAP("failed to load %s content"),
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 697dab27e9..08dc908a3f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -40,9 +40,10 @@ import java.util.Map;
import java.util.Optional;
public interface CandidateService {
- Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload);
+ Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload,
+ String fileSuffix);
- Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData);
+ Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData);
OrchestrationTemplateCandidateData createCandidateDataEntity(
CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 45746ed84e..e6e89a6cd4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -71,6 +71,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public class CandidateServiceImpl implements CandidateService {
protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -90,27 +92,32 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
- public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
+ public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload,
+ String fileSuffix) {
mdcDataDebugMessage.debugEntryMessage(null);
+ String errorMessage =
+ getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
+ fileSuffix);
+
if (Objects.isNull(fileToUpload)) {
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ errorMessage));
} else {
try {
int available = fileToUpload.available();
if (available == 0) {
mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ errorMessage));
}
} catch (IOException e) {
logger.debug(e.getMessage(), e);
mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ errorMessage));
}
}
@@ -119,10 +126,12 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
- public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) {
+ public Optional<ErrorMessage> validateRawZipData(String fileSuffix,
+ byte[] uploadedFileData) {
if (Objects.isNull(uploadedFileData)) {
return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
+ fileSuffix)));
}
return Optional.empty();
}