diff options
Diffstat (limited to 'catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java | 436 |
1 files changed, 207 insertions, 229 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java index baf1d22cb2..fd2f5d5bbf 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java @@ -17,10 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.model.jsonjanusgraph.operations; import fj.data.Either; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.text.StrBuilder; import org.apache.commons.lang3.tuple.ImmutableTriple; @@ -57,54 +66,49 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.GeneralUtility; import org.slf4j.MDC; -import java.util.*; -import java.util.Map.Entry; -import java.util.stream.Collectors; - @org.springframework.stereotype.Component("artifacts-operations") public class ArtifactsOperations extends BaseOperation { - private static final String FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR = "failed to fetch {} for tosca element with id {}, error {}"; - private static final Logger log = Logger.getLogger(ArtifactsOperations.class.getName()); - public Either<ArtifactDefinition, StorageOperationStatus> addArtifactToComponent(ArtifactDefinition artifactInfo, - Component component, NodeTypeEnum type, boolean failIfExist, String instanceId) { + private static final String FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR = "failed to fetch {} for tosca element with id {}, error {}"; + private static final Logger log = Logger.getLogger(ArtifactsOperations.class.getName()); + public Either<ArtifactDefinition, StorageOperationStatus> addArtifactToComponent(ArtifactDefinition artifactInfo, Component component, + NodeTypeEnum type, boolean failIfExist, String instanceId) { String parentId = component.getUniqueId(); String artifactId = artifactInfo.getUniqueId(); if (artifactId == null && artifactInfo.getEsId() != null) { artifactId = artifactInfo.getEsId(); } - Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(component, artifactInfo, type, artifactId, instanceId, false, false); + Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(component, artifactInfo, type, artifactId, instanceId, + false, false); if (status.isRight()) { - - log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), parentId, status.right().value()); - BeEcompErrorManager.getInstance().logBeFailedUpdateNodeError("Update Artifact", artifactInfo.getArtifactName(), String.valueOf(status.right().value())); + log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), parentId, + status.right().value()); + BeEcompErrorManager.getInstance() + .logBeFailedUpdateNodeError("Update Artifact", artifactInfo.getArtifactName(), String.valueOf(status.right().value())); return Either.right(status.right().value()); } else { - ArtifactDataDefinition artifactData = status.left().value(); - ArtifactDefinition artifactDefResult = convertArtifactDataToArtifactDefinition(artifactInfo, artifactData); log.debug("The returned ArtifactDefintion is {}", artifactDefResult); return Either.left(artifactDefResult); } - } - public Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResource(ArtifactDefinition artifactInfo, - Component component, String artifactId, NodeTypeEnum type, String instanceId, boolean isUpdate) { - + public Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResource(ArtifactDefinition artifactInfo, Component component, + String artifactId, NodeTypeEnum type, String instanceId, + boolean isUpdate) { String id = component.getUniqueId(); - Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(component, artifactInfo, type, artifactId, instanceId, isUpdate, false); + Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(component, artifactInfo, type, artifactId, instanceId, + isUpdate, false); if (status.isRight()) { - - log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), id, status.right().value()); - BeEcompErrorManager.getInstance().logBeFailedUpdateNodeError("Update Artifact", artifactInfo.getArtifactName(), String.valueOf(status.right().value())); + log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), id, + status.right().value()); + BeEcompErrorManager.getInstance() + .logBeFailedUpdateNodeError("Update Artifact", artifactInfo.getArtifactName(), String.valueOf(status.right().value())); return Either.right(status.right().value()); } else { - ArtifactDataDefinition artifactData = status.left().value(); - ArtifactDefinition artifactDefResult = convertArtifactDataToArtifactDefinition(artifactInfo, artifactData); log.debug("The returned ArtifactDefinition is {}", artifactDefResult); return Either.left(artifactDefResult); @@ -113,7 +117,6 @@ public class ArtifactsOperations extends BaseOperation { public Either<Boolean, StorageOperationStatus> isCloneNeeded(String parentId, ArtifactDefinition artifactInfo, NodeTypeEnum type) { ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); - Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(groupType, type); EdgeLabelEnum edgeLabelEnum = triple.getLeft(); return super.isCloneNeeded(parentId, edgeLabelEnum); @@ -123,7 +126,8 @@ public class ArtifactsOperations extends BaseOperation { return getArtifactById(parentId, id, null, null); } - public Either<ArtifactDefinition, StorageOperationStatus> getArtifactById(String parentId, String id, ComponentTypeEnum componentType, String containerId) { + public Either<ArtifactDefinition, StorageOperationStatus> getArtifactById(String parentId, String id, ComponentTypeEnum componentType, + String containerId) { Either<ArtifactDefinition, StorageOperationStatus> result = null; ArtifactDataDefinition foundArtifact = null; if (componentType != null && componentType == ComponentTypeEnum.RESOURCE_INSTANCE) { @@ -138,90 +142,79 @@ public class ArtifactsOperations extends BaseOperation { if (foundArtifact == null) { foundArtifact = getArtifactByLabelAndId(parentId, id, EdgeLabelEnum.TOSCA_ARTIFACTS); } - if (foundArtifact == null) { foundArtifact = getArtifactByLabelAndId(parentId, id, EdgeLabelEnum.ARTIFACTS); } - if (foundArtifact == null) { foundArtifact = getArtifactByLabelAndId(parentId, id, EdgeLabelEnum.SERVICE_API_ARTIFACTS); } - if (foundArtifact == null) { - foundArtifact = findInterfaceArtifact(parentId, id); - - } - + if (foundArtifact == null) { + foundArtifact = findInterfaceArtifact(parentId, id); + } if (foundArtifact == null) { result = Either.right(StorageOperationStatus.NOT_FOUND); return result; } - ArtifactDefinition artifactDefResult = convertArtifactDataToArtifactDefinition(null, foundArtifact); return Either.left(artifactDefResult); + } + + private ArtifactDataDefinition findInterfaceArtifact(String parentId, String id) { + Either<Map<String, InterfaceDefinition>, JanusGraphOperationStatus> dataFromGraph = getDataFromGraph(parentId, EdgeLabelEnum.INTERFACE); + if (dataFromGraph.isRight()) { + log.debug("failed to fetch interfaces {} for tosca element with id {}, error {}", id, parentId, dataFromGraph.right().value()); + return null; + } + Map<String, InterfaceDefinition> interfaceDefinitionMap = dataFromGraph.left().value(); + if (interfaceDefinitionMap == null) { + return null; + } + Collection<InterfaceDefinition> interfaces = interfaceDefinitionMap.values(); + if (interfaces == null) { + return null; + } + for (InterfaceDataDefinition interfaceDataDefinition : interfaces) { + Map<String, OperationDataDefinition> operationsMap = interfaceDataDefinition.getOperations(); + if (operationsMap == null) { + return null; + } + ArtifactDataDefinition implementationArtifact = getArtifactDataDefinition(id, operationsMap); + if (implementationArtifact != null) { + return implementationArtifact; + } + } + return null; + } + private ArtifactDataDefinition getArtifactDataDefinition(String id, Map<String, OperationDataDefinition> operationsMap) { + for (OperationDataDefinition operationDataDefinition : operationsMap.values()) { + ArtifactDataDefinition implementationArtifact = operationDataDefinition.getImplementation(); + if (implementationArtifact != null) { + String uniqueId = implementationArtifact.getUniqueId(); + if (id.equals(uniqueId)) { + return implementationArtifact; + } + } + } + return null; } - private ArtifactDataDefinition findInterfaceArtifact(String parentId, String id) { - Either<Map<String, InterfaceDefinition>, JanusGraphOperationStatus> dataFromGraph = getDataFromGraph(parentId, EdgeLabelEnum.INTERFACE); - if (dataFromGraph.isRight()){ - log.debug("failed to fetch interfaces {} for tosca element with id {}, error {}", id, parentId ,dataFromGraph.right().value()); - return null; - } - - Map<String, InterfaceDefinition> interfaceDefinitionMap = dataFromGraph.left().value(); - if(interfaceDefinitionMap == null) { - return null; - } - Collection<InterfaceDefinition> interfaces = interfaceDefinitionMap.values(); - if (interfaces == null){ - return null; - } - for (InterfaceDataDefinition interfaceDataDefinition : interfaces){ - Map<String, OperationDataDefinition> operationsMap = interfaceDataDefinition.getOperations(); - if (operationsMap == null) { - return null; - } - ArtifactDataDefinition implementationArtifact = getArtifactDataDefinition(id, operationsMap); - if (implementationArtifact != null) - return implementationArtifact; - } - return null; - } - - private ArtifactDataDefinition getArtifactDataDefinition(String id, - Map<String, OperationDataDefinition> operationsMap) { - for(OperationDataDefinition operationDataDefinition : operationsMap.values()){ - ArtifactDataDefinition implementationArtifact = operationDataDefinition.getImplementation(); - if(implementationArtifact != null){ - String uniqueId = implementationArtifact.getUniqueId(); - if (id.equals(uniqueId)) { - return implementationArtifact; - } - } - } - return null; - } - - - public Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromResource(String id, String artifactId, NodeTypeEnum type, boolean deleteMandatoryArtifact) { - Either<ArtifactDefinition, StorageOperationStatus> status = removeArtifactOnGraph(id, artifactId, type, deleteMandatoryArtifact); + public Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromResource(String id, String artifactId, NodeTypeEnum type, + boolean deleteMandatoryArtifact) { + Either<ArtifactDefinition, StorageOperationStatus> status = removeArtifactOnGraph(id, artifactId, type, deleteMandatoryArtifact); if (status.isRight()) { - log.debug("Failed to delete artifact {} of resource {}", artifactId, id); - BeEcompErrorManager.getInstance().logBeFailedDeleteNodeError("Delete Artifact", artifactId, String.valueOf(status.right().value())); return Either.right(status.right().value()); } else { - return Either.left(status.left().value()); } } - public Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getArtifacts(String parentId, NodeTypeEnum parentType, ArtifactGroupTypeEnum groupType, String instanceId) { - + public Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getArtifacts(String parentId, NodeTypeEnum parentType, + ArtifactGroupTypeEnum groupType, String instanceId) { Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(groupType, parentType); EdgeLabelEnum edgeLabelEnum = triple.getLeft(); - Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> foundArtifact = null; Map<String, ArtifactDefinition> resMap = new HashMap<>(); foundArtifact = getArtifactByLabel(parentId, instanceId, edgeLabelEnum); @@ -229,9 +222,7 @@ public class ArtifactsOperations extends BaseOperation { log.debug("Failed to find artifact in component {} with label {} ", parentId, edgeLabelEnum); return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(foundArtifact.right().value())); } - resMap.putAll(foundArtifact.left().value()); - return Either.left(resMap); } @@ -242,11 +233,13 @@ public class ArtifactsOperations extends BaseOperation { */ public Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getAllInstanceArtifacts(String parentId, String instanceId) { Map<String, ArtifactDataDefinition> resMap = new HashMap<>(); - Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> instArtifacts = getInstanceArtifactsByLabel(parentId, instanceId, EdgeLabelEnum.INSTANCE_ARTIFACTS); + Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> instArtifacts = getInstanceArtifactsByLabel(parentId, instanceId, + EdgeLabelEnum.INSTANCE_ARTIFACTS); if (instArtifacts.isRight()) { return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(instArtifacts.right().value())); } - Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> deployInstArtifacts = getInstanceArtifactsByLabel(parentId, instanceId, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS); + Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> deployInstArtifacts = getInstanceArtifactsByLabel(parentId, instanceId, + EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS); if (deployInstArtifacts.isRight()) { return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(deployInstArtifacts.right().value())); } @@ -256,29 +249,25 @@ public class ArtifactsOperations extends BaseOperation { } public Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getArtifacts(String parentId) { - Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> foundArtifact = null; Map<String, ArtifactDefinition> resMap = new HashMap<>(); foundArtifact = getArtifactByLabel(parentId, null, EdgeLabelEnum.ARTIFACTS); if (foundArtifact.isLeft()) { resMap.putAll(foundArtifact.left().value()); - } foundArtifact = getArtifactByLabel(parentId, null, EdgeLabelEnum.DEPLOYMENT_ARTIFACTS); if (foundArtifact.isLeft()) { resMap.putAll(foundArtifact.left().value()); - } foundArtifact = getArtifactByLabel(parentId, null, EdgeLabelEnum.TOSCA_ARTIFACTS); if (foundArtifact.isLeft()) { resMap.putAll(foundArtifact.left().value()); } return Either.left(resMap); - } - public Either<ArtifactDefinition, StorageOperationStatus> removeArtifactOnGraph(String id, String artifactId, NodeTypeEnum type, boolean deleteMandatoryArtifact) { - + public Either<ArtifactDefinition, StorageOperationStatus> removeArtifactOnGraph(String id, String artifactId, NodeTypeEnum type, + boolean deleteMandatoryArtifact) { Either<ArtifactDefinition, StorageOperationStatus> artifactData = this.getArtifactById(id, artifactId); if (artifactData.isRight()) { log.debug("Failed to find artifact in component {} with id {} ", id, artifactId); @@ -290,30 +279,29 @@ public class ArtifactsOperations extends BaseOperation { // return Either.left(artifactData.left().value()); isMandatory = true; } - - Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(artifactDefinition.getArtifactGroupType(), type); + Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(artifactDefinition.getArtifactGroupType(), + type); EdgeLabelEnum edgeLabelEnum = triple.getLeft(); VertexTypeEnum vertexTypeEnum = triple.getRight(); - if (!isMandatory) { - StorageOperationStatus status = deleteToscaDataElement(id, edgeLabelEnum, vertexTypeEnum, artifactDefinition.getArtifactLabel(), JsonPresentationFields.ARTIFACT_LABEL); - if (status != StorageOperationStatus.OK) + StorageOperationStatus status = deleteToscaDataElement(id, edgeLabelEnum, vertexTypeEnum, artifactDefinition.getArtifactLabel(), + JsonPresentationFields.ARTIFACT_LABEL); + if (status != StorageOperationStatus.OK) { return Either.right(status); + } } - return Either.left(artifactData.left().value()); - } - private void updateUUID(Map<String, ArtifactDefinition> deploymentArtifacts, ArtifactDefinition updateArtifactData, String oldChecksum, String oldVesrion, boolean isUpdate, EdgeLabelEnum edgeLabel, String prevArtUid) { + private void updateUUID(Map<String, ArtifactDefinition> deploymentArtifacts, ArtifactDefinition updateArtifactData, String oldChecksum, + String oldVesrion, boolean isUpdate, EdgeLabelEnum edgeLabel, String prevArtUid) { if (oldVesrion == null || oldVesrion.isEmpty()) { oldVesrion = "0"; } String currentChecksum = updateArtifactData.getArtifactChecksum(); - if (isUpdate) { final ArtifactTypeEnum type = ArtifactTypeEnum.parse(updateArtifactData.getArtifactType()); - if(type == null) { + if (type == null) { generateUUIDForNonHeatArtifactType(updateArtifactData, oldChecksum, oldVesrion, currentChecksum); return; } @@ -327,34 +315,30 @@ public class ArtifactsOperations extends BaseOperation { case HEAT_NET: case HEAT_VOL: boolean changed = false; - Optional<Entry<String, ArtifactDefinition>> any = deploymentArtifacts.entrySet() - .stream() - .filter(e -> e.getKey().equals(updateArtifactData.getArtifactLabel())) - .findAny(); - if ( any.isPresent() ){ - if ( !any.get().getValue().getArtifactChecksum().equals(updateArtifactData.getArtifactChecksum()) ){ + Optional<Entry<String, ArtifactDefinition>> any = deploymentArtifacts.entrySet().stream() + .filter(e -> e.getKey().equals(updateArtifactData.getArtifactLabel())).findAny(); + if (any.isPresent()) { + if (!any.get().getValue().getArtifactChecksum().equals(updateArtifactData.getArtifactChecksum())) { changed = true; } } - Optional<Entry<String, ArtifactDefinition>> anyEnv = deploymentArtifacts.entrySet() - .stream() - .filter(e -> prevArtUid.equals(e.getValue().getGeneratedFromId())) - .findAny(); - if ( anyEnv.isPresent() && anyEnv.get().getValue().getHeatParamUpdated()){ + Optional<Entry<String, ArtifactDefinition>> anyEnv = deploymentArtifacts.entrySet().stream() + .filter(e -> prevArtUid.equals(e.getValue().getGeneratedFromId())).findAny(); + if (anyEnv.isPresent() && anyEnv.get().getValue().getHeatParamUpdated()) { String newCheckSum = sortAndCalculateChecksumForHeatParameters(updateArtifactData.getHeatParameters()); - if ( !anyEnv.get().getValue().getArtifactChecksum().equals(newCheckSum) ){ + if (!anyEnv.get().getValue().getArtifactChecksum().equals(newCheckSum)) { changed = true; anyEnv.get().getValue().setArtifactChecksum(newCheckSum); UUID uuid = UUID.randomUUID(); anyEnv.get().getValue().setArtifactUUID(uuid.toString()); } } - if ( changed && anyEnv.isPresent() ){ - generateUUID(updateArtifactData, oldVesrion); - anyEnv.get().getValue().setGeneratedFromId(updateArtifactData.getUniqueId()); - anyEnv.get().getValue().setDuplicated(false); - anyEnv.get().getValue().setArtifactVersion(updateArtifactData.getArtifactVersion()); - anyEnv.get().getValue().setHeatParamUpdated(false); + if (changed && anyEnv.isPresent()) { + generateUUID(updateArtifactData, oldVesrion); + anyEnv.get().getValue().setGeneratedFromId(updateArtifactData.getUniqueId()); + anyEnv.get().getValue().setDuplicated(false); + anyEnv.get().getValue().setArtifactVersion(updateArtifactData.getArtifactVersion()); + anyEnv.get().getValue().setHeatParamUpdated(false); } break; default: @@ -366,7 +350,8 @@ public class ArtifactsOperations extends BaseOperation { } } - private void generateUUIDForNonHeatArtifactType(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion, String currentChecksum) { + private void generateUUIDForNonHeatArtifactType(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion, + String currentChecksum) { if (oldChecksum == null || oldChecksum.isEmpty()) { if (currentChecksum != null) { generateUUID(artifactData, oldVesrion); @@ -376,72 +361,68 @@ public class ArtifactsOperations extends BaseOperation { } } - public Either<ArtifactDefinition, StorageOperationStatus> addHeatEnvArtifact(ArtifactDefinition artifactHeatEnv, - ArtifactDefinition artifactHeat, Component component, NodeTypeEnum parentType, boolean failIfExist, String instanceId) { + public Either<ArtifactDefinition, StorageOperationStatus> addHeatEnvArtifact(ArtifactDefinition artifactHeatEnv, ArtifactDefinition artifactHeat, + Component component, NodeTypeEnum parentType, boolean failIfExist, + String instanceId) { artifactHeatEnv.setGeneratedFromId(artifactHeat.getUniqueId()); return addArtifactToComponent(artifactHeatEnv, component, parentType, failIfExist, instanceId); } - public Either<ArtifactDefinition, StorageOperationStatus> getHeatArtifactByHeatEnvId(final String parentId, - final ArtifactDefinition heatEnv, + public Either<ArtifactDefinition, StorageOperationStatus> getHeatArtifactByHeatEnvId(final String parentId, final ArtifactDefinition heatEnv, final String containerId, final ComponentTypeEnum componentType) { return getArtifactById(parentId, heatEnv.getGeneratedFromId(), componentType, containerId); } - public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifact(Component component, ArtifactDefinition artifactEnvInfo, String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) { - - Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactByLabel(component.getUniqueId(), instanceId, EdgeLabelEnum.DEPLOYMENT_ARTIFACTS); + public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifact(Component component, ArtifactDefinition artifactEnvInfo, + String artifactId, String newArtifactId, NodeTypeEnum type, + String instanceId) { + Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactByLabel(component.getUniqueId(), instanceId, + EdgeLabelEnum.DEPLOYMENT_ARTIFACTS); return updateHeatEnvArtifact(artifactsEither, component, artifactEnvInfo, artifactId, newArtifactId, type, instanceId); } private Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifact( - Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither, Component component, - ArtifactDefinition artifactEnvInfo, String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) { - + Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither, Component component, ArtifactDefinition artifactEnvInfo, + String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) { String id = component.getUniqueId(); if (artifactsEither.isRight()) { log.debug("Failed to find artifacts in component {} with id {} ", id, artifactsEither.right().value()); return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(artifactsEither.right().value())); } - Map<String, ArtifactDefinition> artifacts = artifactsEither.left().value(); List<ArtifactDefinition> envList = artifacts.values().stream() - .filter(a -> a.getGeneratedFromId() != null && a.getGeneratedFromId().equals(artifactId)) - .collect(Collectors.toList()); + .filter(a -> a.getGeneratedFromId() != null && a.getGeneratedFromId().equals(artifactId)).collect(Collectors.toList()); if (envList != null && !envList.isEmpty()) { envList.forEach(a -> { a.setGeneratedFromId(newArtifactId); updateArtifactOnResource(a, component, a.getUniqueId(), type, instanceId, true); - }); - } return Either.left(artifactEnvInfo); } - public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifactOnInstance( - Component component, ArtifactDefinition artifactEnvInfo, String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) { - + public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifactOnInstance(Component component, ArtifactDefinition artifactEnvInfo, + String artifactId, String newArtifactId, + NodeTypeEnum type, String instanceId) { String id = component.getUniqueId(); - Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactByLabel(id, instanceId, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS); + Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactByLabel(id, instanceId, + EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS); return updateHeatEnvArtifact(artifactsEither, component, artifactEnvInfo, artifactId, newArtifactId, type, instanceId); } - public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvPlaceholder(ArtifactDefinition artifactInfo, Component parent, NodeTypeEnum type) { - return updateArtifactOnResource(artifactInfo, parent, artifactInfo.getUniqueId(), type, null, true); + public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvPlaceholder(ArtifactDefinition artifactInfo, Component parent, + NodeTypeEnum type) { + return updateArtifactOnResource(artifactInfo, parent, artifactInfo.getUniqueId(), type, null, true); } - ///////////////////////////////////////////// private methods //////////////////////////////////////////////////// - protected ArtifactDefinition convertArtifactDataToArtifactDefinition(ArtifactDefinition artifactInfo, ArtifactDataDefinition artifactDefResult) { log.debug("The object returned after create property is {}", artifactDefResult); - ArtifactDefinition propertyDefResult = new ArtifactDefinition(artifactDefResult); - if (artifactInfo != null) + if (artifactInfo != null) { propertyDefResult.setPayload(artifactInfo.getPayloadData()); - + } List<HeatParameterDefinition> parameters = new ArrayList<>(); /* * StorageOperationStatus heatParametersOfNode = heatParametersOperation.getHeatParametersOfNode(NodeTypeEnum.ArtifactRef, artifactDefResult.getUniqueId().toString(), parameters); if ((heatParametersOfNode.equals(StorageOperationStatus.OK)) @@ -457,15 +438,15 @@ public class ArtifactsOperations extends BaseOperation { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, edgeLabelEnum, containerId, artifactsEither.right().value()); return null; } - Map<String, MapArtifactDataDefinition> artifacts = artifactsEither.left().value(); - MapArtifactDataDefinition artifactsPerInstance = artifacts.get(parentId); if (artifactsPerInstance == null) { - log.debug("failed to fetch artifacts for instance {} in tosca element with id {}, error {}", parentId, containerId, artifactsEither.right().value()); + log.debug("failed to fetch artifacts for instance {} in tosca element with id {}, error {}", parentId, containerId, + artifactsEither.right().value()); return null; } - Optional<ArtifactDataDefinition> op = artifactsPerInstance.getMapToscaDataDefinition().values().stream().filter(p -> p.getUniqueId().equals(id)).findAny(); + Optional<ArtifactDataDefinition> op = artifactsPerInstance.getMapToscaDataDefinition().values().stream() + .filter(p -> p.getUniqueId().equals(id)).findAny(); if (op.isPresent()) { foundArtifact = op.get(); } @@ -479,7 +460,6 @@ public class ArtifactsOperations extends BaseOperation { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, edgeLabelEnum, parentId, artifactsEither.right().value()); return null; } - Map<String, ArtifactDataDefinition> artifacts = artifactsEither.left().value(); Optional<ArtifactDataDefinition> op = artifacts.values().stream().filter(p -> p.getUniqueId().equals(id)).findAny(); if (op.isPresent()) { @@ -488,8 +468,10 @@ public class ArtifactsOperations extends BaseOperation { return foundArtifact; } - private Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> getArtifactByLabel(String parentId, String instanceId, EdgeLabelEnum edgeLabelEnum) { - Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactsDataByLabel(parentId, instanceId, edgeLabelEnum); + private Either<Map<String, ArtifactDefinition>, JanusGraphOperationStatus> getArtifactByLabel(String parentId, String instanceId, + EdgeLabelEnum edgeLabelEnum) { + Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = getArtifactsDataByLabel(parentId, instanceId, + edgeLabelEnum); if (artifactsEither.isRight()) { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, edgeLabelEnum, parentId, artifactsEither.right().value()); return Either.right(artifactsEither.right().value()); @@ -498,19 +480,23 @@ public class ArtifactsOperations extends BaseOperation { return Either.left(convertArtifactMapToArtifactDefinitionMap(artifactDataMap)); } - private Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> getArtifactsDataByLabel(String parentId, String instanceId, EdgeLabelEnum edgeLabelEnum) { - return edgeLabelEnum.isInstanceArtifactsLabel() ? getInstanceArtifactsByLabel(parentId, instanceId, edgeLabelEnum) : getDataFromGraph(parentId, edgeLabelEnum); + private Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> getArtifactsDataByLabel(String parentId, String instanceId, + EdgeLabelEnum edgeLabelEnum) { + return edgeLabelEnum.isInstanceArtifactsLabel() ? getInstanceArtifactsByLabel(parentId, instanceId, edgeLabelEnum) + : getDataFromGraph(parentId, edgeLabelEnum); } private Map<String, ArtifactDefinition> convertArtifactMapToArtifactDefinitionMap(Map<String, ArtifactDataDefinition> artifactDataMap) { Map<String, ArtifactDefinition> artMap = new HashMap<>(); if (artifactDataMap != null && !artifactDataMap.isEmpty()) { - artMap = artifactDataMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, e -> convertArtifactDataToArtifactDefinition(null, e.getValue()))); + artMap = artifactDataMap.entrySet().stream() + .collect(Collectors.toMap(Entry::getKey, e -> convertArtifactDataToArtifactDefinition(null, e.getValue()))); } return artMap; } - private Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> getInstanceArtifactsByLabel(String parentId, String instanceId, EdgeLabelEnum edgeLabelEnum) { + private Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> getInstanceArtifactsByLabel(String parentId, String instanceId, + EdgeLabelEnum edgeLabelEnum) { Either<Map<String, MapArtifactDataDefinition>, JanusGraphOperationStatus> resultEither = getDataFromGraph(parentId, edgeLabelEnum); if (resultEither.isRight()) { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, edgeLabelEnum, parentId, resultEither.right().value()); @@ -521,7 +507,8 @@ public class ArtifactsOperations extends BaseOperation { return artifactPerInstance != null ? Either.left(artifactPerInstance.getMapToscaDataDefinition()) : Either.left(new HashMap<>()); } - private Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> getEdgeLabelEnumFromArtifactGroupType(ArtifactGroupTypeEnum groupType, NodeTypeEnum nodeType) { + private Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> getEdgeLabelEnumFromArtifactGroupType(ArtifactGroupTypeEnum groupType, + NodeTypeEnum nodeType) { EdgeLabelEnum edgeLabelEnum; VertexTypeEnum vertexTypeEnum; Boolean isDeepElement = false; @@ -560,27 +547,24 @@ public class ArtifactsOperations extends BaseOperation { } // } return new ImmutableTriple<>(edgeLabelEnum, isDeepElement, vertexTypeEnum); - } - public Either<ArtifactDataDefinition, StorageOperationStatus> updateArtifactOnGraph(Component component, ArtifactDefinition artifactInfo, NodeTypeEnum type, String artifactId, String instanceId, boolean isUpdate, boolean isDeletePlaceholder) { + public Either<ArtifactDataDefinition, StorageOperationStatus> updateArtifactOnGraph(Component component, ArtifactDefinition artifactInfo, + NodeTypeEnum type, String artifactId, String instanceId, + boolean isUpdate, boolean isDeletePlaceholder) { String componentId = component.getUniqueId(); Either<ArtifactDataDefinition, StorageOperationStatus> res = null; ArtifactDefinition artifactToUpdate = new ArtifactDefinition(artifactInfo); ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); - Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(groupType, type); EdgeLabelEnum edgeLabelEnum = triple.getLeft(); VertexTypeEnum vertexTypeEnum = triple.getRight(); - Either<Boolean, StorageOperationStatus> isNeedToCloneEither = isCloneNeeded(componentId, edgeLabelEnum); if (isNeedToCloneEither.isRight()) { log.debug("Failed check is clone needed {}", componentId); return Either.right(isNeedToCloneEither.right().value()); - } boolean isNeedToClone = isNeedToCloneEither.left().value(); - String prevArtUid = artifactToUpdate.getUniqueId(); if (artifactId == null || isNeedToClone) { String uniqueId; @@ -591,17 +575,17 @@ public class ArtifactsOperations extends BaseOperation { } prevArtUid = artifactToUpdate.getUniqueId(); artifactToUpdate.setUniqueId(uniqueId); - if (!isDeletePlaceholder) + if (!isDeletePlaceholder) { artifactToUpdate.setEsId(uniqueId); - } else + } + } else { artifactToUpdate.setUniqueId(artifactId); - + } Map<String, ArtifactDefinition> artifacts = new HashMap<>(); Map<String, MapArtifactDataDefinition> artifactInst = null; if (edgeLabelEnum != EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS && edgeLabelEnum != EdgeLabelEnum.INSTANCE_ARTIFACTS) { - - Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = this.getDataFromGraph(componentId, edgeLabelEnum); - + Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = this + .getDataFromGraph(componentId, edgeLabelEnum); if (artifactsEither.isLeft() && artifactsEither.left().value() != null && !artifactsEither.left().value().isEmpty()) { artifacts = convertArtifactMapToArtifactDefinitionMap(artifactsEither.left().value()); if (isNeedToClone && artifacts != null) { @@ -609,8 +593,8 @@ public class ArtifactsOperations extends BaseOperation { } } } else { - - Either<Map<String, MapArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = this.getDataFromGraph(componentId, edgeLabelEnum); + Either<Map<String, MapArtifactDataDefinition>, JanusGraphOperationStatus> artifactsEither = this + .getDataFromGraph(componentId, edgeLabelEnum); if (artifactsEither.isLeft()) { artifactInst = artifactsEither.left().value(); if (isNeedToClone && artifactInst != null) { @@ -630,27 +614,25 @@ public class ArtifactsOperations extends BaseOperation { oldVersion = oldArtifactData.getArtifactVersion(); //duplicated flag didn't receive from UI, take from DB artifactToUpdate.setDuplicated(oldArtifactData.getDuplicated()); - - if (isNeedToClone) + if (isNeedToClone) { artifactToUpdate.setDuplicated(Boolean.FALSE); - else { + } else { if (artifactToUpdate.getDuplicated()) { String uniqueId = ""; - if(type != NodeTypeEnum.ResourceInstance) + if (type != NodeTypeEnum.ResourceInstance) { uniqueId = UniqueIdBuilder.buildPropertyUniqueId(componentId, artifactToUpdate.getArtifactLabel()); - else + } else { uniqueId = UniqueIdBuilder.buildInstanceArtifactUniqueId(componentId, instanceId, artifactToUpdate.getArtifactLabel()); - + } artifactToUpdate.setUniqueId(uniqueId); - if (!isDeletePlaceholder) + if (!isDeletePlaceholder) { artifactToUpdate.setEsId(uniqueId); + } artifactToUpdate.setDuplicated(Boolean.FALSE); } } } - updateUUID(artifacts, artifactToUpdate, oldChecksum, oldVersion, isUpdate, edgeLabelEnum, prevArtUid); - if (artifactInfo.getPayloadData() == null) { if (!artifactToUpdate.getMandatory() || artifactToUpdate.getEsId() != null) { artifactToUpdate.setEsId(artifactToUpdate.getUniqueId()); @@ -660,17 +642,17 @@ public class ArtifactsOperations extends BaseOperation { artifactToUpdate.setEsId(artifactToUpdate.getUniqueId()); } } - StorageOperationStatus status = StorageOperationStatus.OK; if (edgeLabelEnum != EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS && edgeLabelEnum != EdgeLabelEnum.INSTANCE_ARTIFACTS) { List<ArtifactDefinition> toscaDataList = new ArrayList<>(); toscaDataList.add(artifactToUpdate); - if (isNeedToClone && artifacts != null) { - artifacts.values().stream().filter(a -> !a.getArtifactLabel().equals(artifactToUpdate.getArtifactLabel())).forEach(toscaDataList::add); - }else{ - if ( artifacts != null ) { - artifacts.values().stream().filter(a -> artifactToUpdate.getUniqueId().equals(a.getGeneratedFromId())).forEach(toscaDataList::add); + artifacts.values().stream().filter(a -> !a.getArtifactLabel().equals(artifactToUpdate.getArtifactLabel())) + .forEach(toscaDataList::add); + } else { + if (artifacts != null) { + artifacts.values().stream().filter(a -> artifactToUpdate.getUniqueId().equals(a.getGeneratedFromId())) + .forEach(toscaDataList::add); } } status = updateToscaDataOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, JsonPresentationFields.ARTIFACT_LABEL); @@ -683,42 +665,39 @@ public class ArtifactsOperations extends BaseOperation { if (artifactInst != null) { MapArtifactDataDefinition artifatcsOnInstance = artifactInst.get(instanceId); if (artifatcsOnInstance != null) { - Map<String, ArtifactDataDefinition> mapToscaDataDefinition = artifatcsOnInstance - .getMapToscaDataDefinition(); - ArtifactDataDefinition artifactDataDefinitionToUpdate = new ArtifactDataDefinition( - artifactToUpdate); + Map<String, ArtifactDataDefinition> mapToscaDataDefinition = artifatcsOnInstance.getMapToscaDataDefinition(); + ArtifactDataDefinition artifactDataDefinitionToUpdate = new ArtifactDataDefinition(artifactToUpdate); mapToscaDataDefinition.put(artifactToUpdate.getArtifactLabel(), artifactDataDefinitionToUpdate); } - for (Entry<String, MapArtifactDataDefinition> e : artifactInst.entrySet()) { - List<ArtifactDataDefinition> toscaDataListPerInst = e.getValue().getMapToscaDataDefinition() - .values().stream().collect(Collectors.toList()); + List<ArtifactDataDefinition> toscaDataListPerInst = e.getValue().getMapToscaDataDefinition().values().stream() + .collect(Collectors.toList()); List<String> pathKeysPerInst = new ArrayList<>(); pathKeysPerInst.add(e.getKey()); - status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, - toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.ARTIFACT_LABEL); + status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataListPerInst, + pathKeysPerInst, JsonPresentationFields.ARTIFACT_LABEL); if (status != StorageOperationStatus.OK) { - log.debug( - "Failed to update atifacts group for instance {} in component {} edge type {} error {}", - instanceId, componentId, edgeLabelEnum, status); + log.debug("Failed to update atifacts group for instance {} in component {} edge type {} error {}", instanceId, + componentId, edgeLabelEnum, status); res = Either.right(status); break; } } } } else { - status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, pathKeys, JsonPresentationFields.ARTIFACT_LABEL); + status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, pathKeys, + JsonPresentationFields.ARTIFACT_LABEL); } } - if (status == StorageOperationStatus.OK) + if (status == StorageOperationStatus.OK) { res = Either.left(artifactToUpdate); - else + } else { res = Either.right(status); + } return res; } public void generateUUID(ArtifactDataDefinition artifactData, String oldVesrion) { - UUID uuid = UUID.randomUUID(); artifactData.setArtifactUUID(uuid.toString()); MDC.put(ILogConfiguration.MDC_SERVICE_INSTANCE_ID, uuid.toString()); @@ -735,44 +714,46 @@ public class ArtifactsOperations extends BaseOperation { artifactData.setArtifactVersion(String.valueOf(newVersion)); } - public Either<ArtifactDataDefinition, StorageOperationStatus> removeArtifactOnGraph(ArtifactDefinition artifactFromGraph, String componentId, String instanceId, NodeTypeEnum type, boolean deleteMandatoryArtifact) { - + public Either<ArtifactDataDefinition, StorageOperationStatus> removeArtifactOnGraph(ArtifactDefinition artifactFromGraph, String componentId, + String instanceId, NodeTypeEnum type, + boolean deleteMandatoryArtifact) { Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(artifactFromGraph.getArtifactGroupType(), type); EdgeLabelEnum edgeLabelEnum = triple.getLeft(); VertexTypeEnum vertexTypeEnum = triple.getRight(); - if (deleteMandatoryArtifact || !(artifactFromGraph.getMandatory() || artifactFromGraph.getServiceApi())) { StorageOperationStatus status; if (triple.getMiddle()) { List<String> pathKeys = new ArrayList<>(); pathKeys.add(instanceId); - status = deleteToscaDataDeepElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(), pathKeys, JsonPresentationFields.ARTIFACT_LABEL); + status = deleteToscaDataDeepElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(), pathKeys, + JsonPresentationFields.ARTIFACT_LABEL); } else { - status = deleteToscaDataElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(), JsonPresentationFields.ARTIFACT_LABEL); + status = deleteToscaDataElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(), + JsonPresentationFields.ARTIFACT_LABEL); } - if (status != StorageOperationStatus.OK) + if (status != StorageOperationStatus.OK) { return Either.right(status); + } } return Either.left(artifactFromGraph); - } - public Either<ArtifactDataDefinition, StorageOperationStatus> deleteArtifactWithCloningOnGraph(String componentId, ArtifactDefinition artifactToDelete, NodeTypeEnum type, String instanceId, boolean deleteMandatoryArtifact) { - + public Either<ArtifactDataDefinition, StorageOperationStatus> deleteArtifactWithCloningOnGraph(String componentId, + ArtifactDefinition artifactToDelete, + NodeTypeEnum type, String instanceId, + boolean deleteMandatoryArtifact) { Either<ArtifactDataDefinition, StorageOperationStatus> result = null; Triple<EdgeLabelEnum, Boolean, VertexTypeEnum> triple = getEdgeLabelEnumFromArtifactGroupType(artifactToDelete.getArtifactGroupType(), type); EdgeLabelEnum edgeLabel = triple.getLeft(); VertexTypeEnum vertexLabel = triple.getRight(); - Boolean deleteElement = deleteMandatoryArtifact || !(artifactToDelete.getMandatory() || artifactToDelete.getServiceApi()); Map<String, ToscaDataDefinition> artifacts = null; GraphVertex parentVertex = null; Either<Map<String, ToscaDataDefinition>, JanusGraphOperationStatus> getArtifactsRes = null; - - Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes = janusGraphDao - .getVertexById(componentId, JsonParseFlagEnum.NoParse); + Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse); if (getToscaElementRes.isRight()) { - CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get tosca element {} upon getting tosca data from graph. Status is {}. ", componentId, getToscaElementRes.right().value()); + CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get tosca element {} upon getting tosca data from graph. Status is {}. ", + componentId, getToscaElementRes.right().value()); result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getToscaElementRes.right().value())); } if (result == null) { @@ -785,7 +766,8 @@ public class ArtifactsOperations extends BaseOperation { if (result == null) { artifacts = getArtifactsRes.left().value(); if (triple.getMiddle()) { - artifacts.values().forEach(ma -> ((MapArtifactDataDefinition) ma).getMapToscaDataDefinition().values().forEach(a -> a.setDuplicated(Boolean.TRUE))); + artifacts.values() + .forEach(ma -> ((MapArtifactDataDefinition) ma).getMapToscaDataDefinition().values().forEach(a -> a.setDuplicated(Boolean.TRUE))); MapArtifactDataDefinition artifatcsOnInstance = (MapArtifactDataDefinition) artifacts.get(instanceId); if (artifatcsOnInstance != null && deleteElement) { artifatcsOnInstance.getMapToscaDataDefinition().remove(artifactToDelete.getArtifactLabel()); @@ -799,8 +781,7 @@ public class ArtifactsOperations extends BaseOperation { artifactToDelete.setDuplicated(Boolean.TRUE); } if (artifacts != null) { - JanusGraphOperationStatus - status = janusGraphDao.deleteEdgeByDirection(parentVertex, Direction.OUT, edgeLabel); + JanusGraphOperationStatus status = janusGraphDao.deleteEdgeByDirection(parentVertex, Direction.OUT, edgeLabel); if (status != JanusGraphOperationStatus.OK) { result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)); } else if (MapUtils.isNotEmpty(artifacts)) { @@ -818,11 +799,8 @@ public class ArtifactsOperations extends BaseOperation { public String sortAndCalculateChecksumForHeatParameters(List<HeatParameterDataDefinition> heatParameters) { StrBuilder sb = new StrBuilder(); - heatParameters.stream() - .sorted(Comparator.comparingInt(HeatParameterDataDefinition::hashCode)) - .map(HeatParameterDataDefinition::hashCode) - .collect(Collectors.toSet()) - .forEach(sb::append); + heatParameters.stream().sorted(Comparator.comparingInt(HeatParameterDataDefinition::hashCode)).map(HeatParameterDataDefinition::hashCode) + .collect(Collectors.toSet()).forEach(sb::append); return GeneralUtility.calculateMD5Base64EncodedByString(sb.toString()); } } |