aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-09-14 17:54:11 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-09-14 17:05:59 +0000
commit458bf21d934e356c20b69a1c7b0aae79197e1023 (patch)
tree8594155677af5d12d7d4451200d9ab4e9363964a /catalog-be/src/main/java
parentcec4c5b5fac4fc0567535fa7254aae29160b2a0a (diff)
Improve error reporting during the service import
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I407d18e3b1c0757efb4623d73b21d98cbb76310a Issue-ID: SDC-4623
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java60
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java122
2 files changed, 87 insertions, 95 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
index 448077b6b5..93a55aebc8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
@@ -474,20 +474,22 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
jsonElement = gson.fromJson(artifactsMetaFile, jsonElement.getClass());
JsonElement importStructureElement = jsonElement.get(Constants.IMPORT_STRUCTURE);
if (importStructureElement == null || importStructureElement.isJsonNull()) {
- log.debug(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
+ log.error(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName,
+ ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName));
}
Map<String, List<Map<String, Object>>> artifactTemplateMap;
artifactTemplateMap = ComponentsUtils.parseJsonToObject(importStructureElement.toString(), HashMap.class);
if (artifactTemplateMap.isEmpty()) {
- log.debug(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
+ log.error(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName,
+ ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName));
}
Set<String> artifactsTypeKeys = artifactTemplateMap.keySet();
Map<String, List<ArtifactTemplateInfo>> artifactsMap = new HashMap<>();
@@ -508,12 +510,13 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
}
return Either.left(artifactsMap);
} catch (Exception e) {
- log.debug(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
- log.debug("failed with exception.", e);
+ log.error(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
+ log.error("failed with exception.", e);
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName,
+ ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName));
}
}
@@ -524,7 +527,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
List<Map<String, Object>> o = artifactTemplateMap.get(artifactsTypeKey);
Either<List<ArtifactTemplateInfo>, ResponseFormat> artifactTemplateInfoListPairStatus = createArtifactTemplateInfoModule(artifactsTypeKey, o);
if (artifactTemplateInfoListPairStatus.isRight()) {
- log.debug(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
+ log.error(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
ErrorSeverity.ERROR);
@@ -532,11 +535,12 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
}
List<ArtifactTemplateInfo> artifactTemplateInfoList = artifactTemplateInfoListPairStatus.left().value();
if (artifactTemplateInfoList == null) {
- log.debug(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
+ log.error(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName);
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, artifactFileName,
+ ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME, artifactFileName));
}
if (!artifactsTypeKey.equalsIgnoreCase(ArtifactTemplateInfo.CSAR_ARTIFACT)) {
allGroups.addAll(artifactTemplateInfoList);
@@ -707,7 +711,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
if (op.isPresent()) {
res = op.get();
if (!res.getArtifactType().equalsIgnoreCase(artifactTemplateInfo.getType())) {
- log.debug(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
+ log.error(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
res.getArtifactType());
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
@@ -784,7 +788,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResource = artifactToscaOperation
.updateArtifactOnResource(artifactInfoHeatEnv, updatedResource, artifactInfoHeatEnv.getUniqueId(), null, null, true);
if (updateArtifactOnResource.isRight()) {
- log.debug("Failed to update heat env on CSAR flow for component {} artifact {} label {}", updatedResource.getUniqueId(),
+ log.error("Failed to update heat env on CSAR flow for component {} artifact {} label {}", updatedResource.getUniqueId(),
artifactInfoHeatEnv.getUniqueId(), artifactInfoHeatEnv.getArtifactLabel());
return Either.right(
componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateArtifactOnResource.right().value())));
@@ -804,7 +808,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils
.getHeatParamsWithoutImplicitTypes(heatDecodedPayload, artifactType);
if (heatParameters.isRight()) {
- log.debug("File {} is not in expected key-value form in csar ", fileName);
+ log.error("File {} is not in expected key-value form in csar ", fileName);
BeEcompErrorManager.getInstance()
.logInternalDataError("File " + fileName + " is not in expected key-value form in csar ", "CSAR internals are invalid",
ErrorSeverity.ERROR);
@@ -844,7 +848,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResource = artifactToscaOperation
.updateArtifactOnResource(currentInfo, resource, currentInfo.getUniqueId(), null, null, true);
if (updateArtifactOnResource.isRight()) {
- log.debug("Failed to update heat parameters of heat on CSAR flow for component {} artifact {} label {}", resource.getUniqueId(),
+ log.error("Failed to update heat parameters of heat on CSAR flow for component {} artifact {} label {}", resource.getUniqueId(),
currentInfo.getUniqueId(), currentInfo.getArtifactLabel());
return Either
.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateArtifactOnResource.right().value())));
@@ -865,11 +869,11 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
result = artifactsBusinessLogic
.handleLoadedArtifact(component, user, operation, false, true, component.getComponentType(), artifactDefinitionFromJson);
} catch (ComponentException e) {
- log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, component.getComponentType(), component.getName());
+ log.error(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, component.getComponentType(), component.getName());
return Either.right(componentsUtils.getResponseFormat(e));
} catch (Exception e) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
- log.debug("Exception occurred when createOrUpdateCsarArtifactFromJson, error is:{}", e.getMessage(), e);
+ log.error("Exception occurred when createOrUpdateCsarArtifactFromJson, error is:{}", e.getMessage(), e);
return Either.right(responseFormat);
}
return Either.left(result);
@@ -1239,7 +1243,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
artifactUid = artifactFromResource.getUniqueId();
artifactUUID = artifactFromResource.getArtifactUUID();
if (!artifactFromResource.getArtifactType().equalsIgnoreCase(artifactTemplateInfo.getType())) {
- log.debug(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
+ log.error(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
artifactFromResource.getArtifactType());
BeEcompErrorManager.getInstance().logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName,
ARTIFACT_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
@@ -1259,7 +1263,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
artifactUid = createdArtifact.getUniqueId();
artifactUUID = createdArtifact.getArtifactUUID();
if (!createdArtifact.getArtifactType().equalsIgnoreCase(artifactTemplateInfo.getType())) {
- log.debug(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
+ log.error(ARTIFACT_WITH_NAME_AND_TYPE_ALREADY_EXIST_WITH_TYPE, artifactFileName, artifactTemplateInfo.getType(),
createdArtifact.getArtifactType());
BeEcompErrorManager.getInstance().logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName,
ARTIFACT_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
@@ -1374,17 +1378,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
List<ArtifactTemplateInfo> associatedArtifact = associateEntry.getValue();
Set<String> arifactsUids = new HashSet<>();
Set<String> arifactsUuids = new HashSet<>();
- for (ArtifactTemplateInfo artifactTemplate : associatedArtifact) { // try
-
- // to
-
- // find
-
- // artifact
-
- // in
-
- // resource
+ for (ArtifactTemplateInfo artifactTemplate : associatedArtifact) { // try to find artifact in resource
boolean isCreate = true;
for (ArtifactDefinition createdArtifact : createdDeploymentArtifactsAfterDelete) {
if (artifactTemplate.getFileName().equalsIgnoreCase(createdArtifact.getArtifactName())) {
@@ -1474,7 +1468,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
for (ArtifactDefinition updatedArtifact : updatedArtifacts) {
if (updatedArtifact.getArtifactName().equals(artifactFileName)) {
if (!updatedArtifact.getArtifactType().equalsIgnoreCase(artifactTemplateInfo.getType())) {
- log.debug("Artifact with name {} and type {} already updated with type {}", artifactFileName, artifactTemplateInfo.getType(),
+ log.error("Artifact with name {} and type {} already updated with type {}", artifactFileName, artifactTemplateInfo.getType(),
updatedArtifact.getArtifactType());
BeEcompErrorManager.getInstance()
.logInternalDataError(ARTIFACT_FILE_IS_NOT_IN_EXPECTED_FORMAT_FILE_NAME + artifactFileName, ARTIFACT_INTERNALS_ARE_INVALID,
@@ -1507,7 +1501,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<ArtifactDefinition, ResponseFormat> updateEnvEither = updateHeatParamsFromCsar(resource, csarInfo, artifactTemplateInfo, currentInfo,
true);
if (updateEnvEither.isRight()) {
- log.debug("failed to update parameters to artifact {}", artifactFileName);
+ log.error("failed to update parameters to artifact {}", artifactFileName);
return Either.right(updateEnvEither.right().value());
}
artifactsBusinessLogic.updateGroupForHeat(previousInfo, updateEnvEither.left().value(), resource);
@@ -1529,7 +1523,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
.handleDelete(updatedResource.getUniqueId(), artifactId, csarInfo.getModifier(), updatedResource, shouldLock,
inTransaction);
if (handleDelete.isRight()) {
- log.debug("Couldn't delete artifact {}", artifactId);
+ log.error("Couldn't delete artifact {}", artifactId);
return Either.right(handleDelete.right().value());
}
}
@@ -1574,7 +1568,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<ArtifactDefinition, ResponseFormat> handleDelete = artifactsBusinessLogic
.handleDelete(resource.getUniqueId(), artifactId, csarInfo.getModifier(), resource, shouldLock, inTransaction);
if (handleDelete.isRight()) {
- log.debug("Couldn't delete artifact {}", artifactId);
+ log.error("Couldn't delete artifact {}", artifactId);
return Either.right(handleDelete.right().value());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
index 1f7d9493d4..539b6b8536 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
@@ -50,9 +50,9 @@ public class CsarValidationUtils {
private static final String CSAR_VERSION = "CSAR-Version";
private static final String CREATED_BY = "Created-By";
private static final String NEW_LINE_DELM = "\n";
- public static final String TOSCA_METADATA = "TOSCA-Metadata";
- public static final String TOSCA_FILE = "TOSCA.meta";
- public static final String DEL_PATTERN = "([/\\\\]+)";
+ private static final String TOSCA_METADATA = "TOSCA-Metadata";
+ private static final String TOSCA_FILE = "TOSCA.meta";
+ private static final String DEL_PATTERN = "([/\\\\]+)";
public static final String TOSCA_METADATA_PATH_PATTERN = TOSCA_METADATA +
// Artifact Group (i.e Deployment/Informational)
DEL_PATTERN + TOSCA_FILE;
@@ -86,13 +86,13 @@ public class CsarValidationUtils {
public static Either<Boolean, ResponseFormat> validateCsar(Map<String, byte[]> csar, String csarUUID, ComponentsUtils componentsUtils) {
Either<Boolean, ResponseFormat> validateStatus = validateIsTOSCAMetadataExist(csar, csarUUID, componentsUtils);
if (validateStatus.isRight()) {
- return Either.right(validateStatus.right().value());
+ return validateStatus;
}
removeNonUniqueArtifactsFromCsar(csar);
log.trace("TOSCA-Metadata/TOSCA.meta file found, CSAR id {}", csarUUID);
validateStatus = validateTOSCAMetadataFile(csar, csarUUID, componentsUtils);
if (validateStatus.isRight()) {
- return Either.right(validateStatus.right().value());
+ return validateStatus;
}
return Either.left(true);
}
@@ -148,51 +148,50 @@ public class CsarValidationUtils {
Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
if (keyOp.isEmpty()) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
- .logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
- CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ .logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
+ CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
Properties props = new Properties();
try {
props.load(new StringReader(new String(csar.get(keyOp.get())).replace("\\", "\\\\")));
} catch (IOException e) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID, e);
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID, e);
BeEcompErrorManager.getInstance()
- .logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
- CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ .logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
+ CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
String yamlFileName = props.getProperty(TOSCA_META_ENTRY_DEFINITIONS);
- String[] ops = yamlFileName.split(DEL_PATTERN);
- List<String> list = Arrays.asList(ops);
- String result = list.stream().map(x -> x).collect(Collectors.joining(DEL_PATTERN));
+ String result = Arrays.asList(yamlFileName.split(DEL_PATTERN)).stream().map(x -> x).collect(Collectors.joining(DEL_PATTERN));
keyOp = csar.keySet().stream().filter(k -> Pattern.compile(result).matcher(k).matches()).findAny();
- if (!keyOp.isPresent()) {
- log.debug(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID, csarUUID);
+ if (keyOp.isEmpty()) {
+ log.error(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
- .logInternalDataError(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID + csarUUID,
- CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
+ .logInternalDataError(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID + csarUUID,
+ CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.YAML_NOT_FOUND_IN_CSAR, csarUUID, yamlFileName));
}
log.trace("Found Entry-Definitions property in TOSCA-Metadata/TOSCA.meta, Entry-Definitions: {}, CSAR id: {}", yamlFileName, csarUUID);
byte[] yamlFileBytes = csar.get(yamlFileName);
if (yamlFileBytes == null) {
- log.debug("Entry-Definitions {} file not found in csar, csar ID {}", yamlFileName, csarUUID);
+ log.error("Entry-Definitions {} file not found in csar, csar ID {}", yamlFileName, csarUUID);
BeEcompErrorManager.getInstance()
- .logInternalDataError(ENTRY_DEFINITIONS + yamlFileName + FILE_NOT_FOUND_IN_CSAR_WITH_ID + csarUUID, CSAR_STRUCTURE_IS_INVALID,
- ErrorSeverity.ERROR);
+ .logInternalDataError(ENTRY_DEFINITIONS + yamlFileName + FILE_NOT_FOUND_IN_CSAR_WITH_ID + csarUUID, CSAR_STRUCTURE_IS_INVALID,
+ ErrorSeverity.ERROR);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.YAML_NOT_FOUND_IN_CSAR, csarUUID, yamlFileName));
}
- String yamlFileContents = new String(yamlFileBytes);
- return Either.left(new ImmutablePair<>(yamlFileName, yamlFileContents));
+ return Either.left(new ImmutablePair<>(yamlFileName, new String(yamlFileBytes)));
}
public static Either<ImmutablePair<String, String>, ResponseFormat> getArtifactsMeta(Map<String, byte[]> csar, String csarUUID,
ComponentsUtils componentsUtils) {
if (!csar.containsKey(CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE)) {
- log.debug(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID, csarUUID);
+ log.error(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
@@ -202,22 +201,21 @@ public class CsarValidationUtils {
csarUUID);
byte[] artifactsMetaBytes = csar.get(CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE);
if (artifactsMetaBytes == null) {
- log.debug("Entry-Definitions {}{} file not found in csar, csar ID {}", CsarUtils.ARTIFACTS_PATH, ARTIFACTS_METADATA_FILE, csarUUID);
+ log.error("Entry-Definitions {}{} file not found in csar, csar ID {}", CsarUtils.ARTIFACTS_PATH, ARTIFACTS_METADATA_FILE, csarUUID);
BeEcompErrorManager.getInstance().logInternalDataError(
ENTRY_DEFINITIONS + CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE + FILE_NOT_FOUND_IN_CSAR_WITH_ID + csarUUID,
CSAR_STRUCTURE_IS_INVALID, ErrorSeverity.ERROR);
return Either.right(
componentsUtils.getResponseFormat(ActionStatus.YAML_NOT_FOUND_IN_CSAR, csarUUID, CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE));
}
- String artifactsFileContents = new String(artifactsMetaBytes);
- return Either.left(new ImmutablePair<>(CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE, artifactsFileContents));
+ return Either.left(new ImmutablePair<>(CsarUtils.ARTIFACTS_PATH + ARTIFACTS_METADATA_FILE, new String(artifactsMetaBytes)));
}
public static Either<ImmutablePair<String, byte[]>, ResponseFormat> getArtifactContent(String csarUUID, Map<String, byte[]> csar,
String artifactPath, String artifactName,
ComponentsUtils componentsUtils) {
if (!csar.containsKey(artifactPath)) {
- log.debug("Entry-Definitions entry not found in Artifacts/HEAT.meta file, csar ID {}", csarUUID);
+ log.error("Entry-Definitions entry not found in Artifacts/HEAT.meta file, csar ID {}", csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(ENTRY_DEFINITIONS_ENTRY_NOT_FOUND_IN_TOSCA_METADATA_TOSCA_META_FILE_CSAR_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
@@ -227,7 +225,7 @@ public class CsarValidationUtils {
log.trace("Found Entry-Definitions property in Artifacts/HEAT.meta, Entry-Definitions: {}, CSAR id: {}", artifactPath, csarUUID);
byte[] artifactFileBytes = csar.get(artifactPath);
if (artifactFileBytes == null) {
- log.debug("Entry-Definitions {}{} file not found in csar, csar ID {}", CsarUtils.ARTIFACTS_PATH, artifactName, csarUUID);
+ log.error("Entry-Definitions {}{} file not found in csar, csar ID {}", CsarUtils.ARTIFACTS_PATH, artifactName, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(ENTRY_DEFINITIONS + artifactPath + FILE_NOT_FOUND_IN_CSAR_WITH_ID + csarUUID, CSAR_STRUCTURE_IS_INVALID,
ErrorSeverity.ERROR);
@@ -240,26 +238,27 @@ public class CsarValidationUtils {
ComponentsUtils componentsUtils) {
Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
- if (!keyOp.isPresent()) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
+ if (keyOp.isEmpty()) {
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
- byte[] toscaMetaBytes = csar.get(keyOp.get());
- String toscaMetadata = new String(toscaMetaBytes);
+ String toscaMetadata = new String(csar.get(keyOp.get()));
String[] splited = toscaMetadata.split(NEW_LINE_DELM);
if (splited == null || splited.length < TOSCA_METADATA_FIELDS.length) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
Either<Boolean, ResponseFormat> blockStatus = validateBlock(csarUUID, splited, componentsUtils);
if (blockStatus.isRight()) {
- return Either.right(blockStatus.right().value());
+ return blockStatus;
}
return Either.left(true);
}
@@ -271,36 +270,38 @@ public class CsarValidationUtils {
try {
props.load(new ByteArrayInputStream(splited[index].getBytes()));
} catch (IOException e) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID, e);
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID, e);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
if (!props.containsKey(toscaField)) {
- log.debug("TOSCA.meta file format is invalid: No new line after block_0 as expected in csar, csar ID {}", csarUUID);
+ final String msg = "TOSCA.meta file format is invalid: No new line after block_0 as expected in csar, csar ID {}";
+ log.error(msg, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID, msg, csarUUID));
}
- String value = props.getProperty(toscaField);
+ final String value = props.getProperty(toscaField);
if (value == null || value.isEmpty()) {
- log.debug(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
+ log.error(TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID,
+ TOSCA_METADATA_TOSCA_META_FILE_IS_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_CSAR_ID, csarUUID));
}
- // TOSCA-Meta-File-Version & CSAR-Version : digit.digit - format
-
- // validation
+ // TOSCA-Meta-File-Version & CSAR-Version : digit.digit - format validation
if ((toscaField.equals(TOSCA_META_FILE_VERSION) || toscaField.equals(CSAR_VERSION)) && !validateTOSCAMetaProperty(value)) {
- log.debug("TOSCA-Metadata/TOSCA.meta file contains {} in wrong format (digit.digit), csar ID {}", toscaField, csarUUID);
+ final String msg = "TOSCA-Metadata/TOSCA.meta file contains {} in wrong format (digit.digit), csar ID {}";
+ log.error(msg, toscaField, csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError(TOSCA_METADATA_TOSCA_META_FILE_NOT_IN_EXPECTED_KEY_VALUE_FORM_IN_CSAR_WITH_ID + csarUUID,
CSAR_INTERNALS_ARE_INVALID, ErrorSeverity.ERROR);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID, msg, toscaField, csarUUID));
}
index++;
}
@@ -308,22 +309,20 @@ public class CsarValidationUtils {
}
private static boolean validateTOSCAMetaProperty(String toscaProperty) {
- Matcher floatMatcher = floatPattern.matcher(toscaProperty);
- return floatMatcher.matches();
+ return floatPattern.matcher(toscaProperty).matches();
}
private static Either<Boolean, ResponseFormat> validateIsTOSCAMetadataExist(Map<String, byte[]> csar, String csarUUID,
ComponentsUtils componentsUtils) {
if (csar == null || csar.isEmpty()) {
- log.debug("Error when fetching csar with ID {}", csarUUID);
+ log.error("Error when fetching csar with ID {}", csarUUID);
BeEcompErrorManager.getInstance().logBeDaoSystemError("Creating resource from CSAR: fetching CSAR with id " + csarUUID + " failed");
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID, csarUUID);
- return Either.right(responseFormat);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID, csarUUID));
}
Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
- if (!keyOp.isPresent()) {
- log.debug("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
+ if (keyOp.isEmpty()) {
+ log.error("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError("TOSCA-Metadata/TOSCA.meta file not found in CSAR with id " + csarUUID, CSAR_STRUCTURE_IS_INVALID,
ErrorSeverity.ERROR);
@@ -331,7 +330,7 @@ public class CsarValidationUtils {
}
byte[] toscaMetaBytes = csar.get(keyOp.get());
if (toscaMetaBytes == null || toscaMetaBytes.length == 0) {
- log.debug("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
+ log.error("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
BeEcompErrorManager.getInstance()
.logInternalDataError("TOSCA-Metadata/TOSCA.meta file not found in CSAR with id " + csarUUID, CSAR_STRUCTURE_IS_INVALID,
ErrorSeverity.ERROR);
@@ -343,11 +342,10 @@ public class CsarValidationUtils {
public static Either<String, ResponseFormat> getToscaYamlChecksum(Map<String, byte[]> csar, String csarUUID, ComponentsUtils componentsUtils) {
Either<ImmutablePair<String, String>, ResponseFormat> toscaYamlRes = getToscaYaml(csar, csarUUID, componentsUtils, AuditingActionEnum.GET_TOSCA_MODEL);
if (toscaYamlRes.isRight() || toscaYamlRes.left().value() == null || toscaYamlRes.left().value().getRight() == null) {
- log.debug("Faild to create toscaYamlChecksum for csar, csar ID {}", csarUUID);
+ log.error("Faild to create toscaYamlChecksum for csar, csar ID {}", csarUUID);
return Either.right(toscaYamlRes.right().value());
}
- String newCheckSum = GeneralUtility.calculateMD5Base64EncodedByByteArray(toscaYamlRes.left().value().getRight().getBytes());
- return Either.left(newCheckSum);
+ return Either.left(GeneralUtility.calculateMD5Base64EncodedByByteArray(toscaYamlRes.left().value().getRight().getBytes()));
}
public static boolean isCsarPayloadName(String payloadName) {