diff options
Diffstat (limited to 'catalog-model/src/main')
6 files changed, 43 insertions, 184 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index a9543d240f..c17c3fcb81 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -20,7 +20,14 @@ package org.openecomp.sdc.be.model; -import static java.util.Collections.emptyList; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.dao.utils.MapUtil; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.model.category.CategoryDefinition; +import org.openecomp.sdc.be.model.category.SubCategoryDefinition; +import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum; +import org.openecomp.sdc.common.api.ArtifactTypeEnum; import java.io.Serializable; import java.util.ArrayList; @@ -32,15 +39,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import org.openecomp.sdc.be.config.ConfigurationManager; -import org.openecomp.sdc.be.dao.utils.MapUtil; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.openecomp.sdc.be.model.category.SubCategoryDefinition; -import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; - -import com.fasterxml.jackson.annotation.JsonIgnore; +import static java.util.Collections.emptyList; public abstract class Component implements Serializable { @@ -477,11 +476,7 @@ public abstract class Component implements Serializable { result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode()); result = prime * result + ((categories == null) ? 0 : categories.hashCode()); result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode()); -// result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode()); -// result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode()); result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode()); -// result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode()); -// result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode()); result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); result = prime * result + ((requirements == null) ? 0 : requirements.hashCode()); result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode()); @@ -522,31 +517,11 @@ public abstract class Component implements Serializable { return false; } else if (!componentMetadataDefinition.equals(other.componentMetadataDefinition)) return false; -// if (creatorUserId == null) { -// if (other.creatorUserId != null) -// return false; -// } else if (!creatorUserId.equals(other.creatorUserId)) -// return false; -// if (creatorFullName == null) { -// if (other.creatorFullName != null) -// return false; -// } else if (!creatorFullName.equals(other.creatorFullName)) -// return false; if (deploymentArtifacts == null) { if (other.deploymentArtifacts != null) return false; } else if (!deploymentArtifacts.equals(other.deploymentArtifacts)) return false; -// if (lastUpdaterUserId == null) { -// if (other.lastUpdaterUserId != null) -// return false; -// } else if (!lastUpdaterUserId.equals(other.lastUpdaterUserId)) -// return false; -// if (lastUpdaterFullName == null) { -// if (other.lastUpdaterFullName != null) -// return false; -// } else if (!lastUpdaterFullName.equals(other.lastUpdaterFullName)) -// return false; if (componentInstances == null) { if (other.componentInstances != null) return false; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java index 439b4346ef..4fa41e5bee 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ComponentCache.java @@ -20,22 +20,7 @@ package org.openecomp.sdc.be.model.cache; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.annotation.PostConstruct; - +import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -65,7 +50,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import fj.data.Either; +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Function; +import java.util.stream.Collectors; @org.springframework.stereotype.Component("component-cache") public class ComponentCache { @@ -344,9 +342,7 @@ public class ComponentCache { filteredComponent.setUniqueId(component.getUniqueId()); filteredComponent.setIcon(component.getIcon()); filteredComponent.setTags(component.getTags()); - // filteredComponent.setAllVersions(component.getAllVersions()); filteredComponent.setLifecycleState(component.getLifecycleState()); - // filteredComponent.setHighestVersion(component.isHighestVersion()); filteredComponent.setInvariantUUID(component.getInvariantUUID()); filteredComponent.setUUID(component.getUUID()); filteredComponent.setSystemName(component.getSystemName()); @@ -356,14 +352,7 @@ public class ComponentCache { Resource resource = (Resource) component; Resource filteredResource = (Resource) filteredComponent; filteredResource.setToscaResourceName(resource.getToscaResourceName()); - // filteredResource.setAbstract(resource.isAbstract()); - // filteredResource.setVendorName(resource.getVendorName()); - // filteredResource.setVendorRelease(resource.getVendorRelease()); filteredResource.setResourceType(resource.getResourceType()); - } else if (componentTypeEnum == ComponentTypeEnum.SERVICE) { - // Service service = (Service)component; - // Service filteredService = (Service)filteredComponent; - // filteredService.setDistributionStatus(service.getDistributionStatus()); } } @@ -377,10 +366,7 @@ public class ComponentCache { filteredComponent.setUniqueId(component.getUniqueId()); filteredComponent.setIcon(component.getIcon()); filteredComponent.setTags(component.getTags()); - // filteredComponent.setAllVersions(component.getAllVersions()); filteredComponent.setLifecycleState(component.getLifecycleState()); - // filteredComponent.setHighestVersion(component.isHighestVersion()); - // filteredComponent.setInvariantUUID(component.getInvariantUUID()); filteredComponent.setSystemName(component.getSystemName()); filteredComponent.setName(component.getName()); filteredComponent.setLastUpdateDate(component.getLastUpdateDate()); @@ -389,9 +375,6 @@ public class ComponentCache { Resource resource = (Resource) component; Resource filteredResource = (Resource) filteredComponent; filteredResource.setToscaResourceName(resource.getToscaResourceName()); - // filteredResource.setAbstract(resource.isAbstract()); - // filteredResource.setVendorName(resource.getVendorName()); - // filteredResource.setVendorRelease(resource.getVendorRelease()); filteredResource.setResourceType(resource.getResourceType()); } else if (componentTypeEnum == ComponentTypeEnum.SERVICE) { Service service = (Service) component; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java index 0cb71eeab3..df7b382503 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java @@ -20,16 +20,9 @@ package org.openecomp.sdc.be.model.jsontitan.operations; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import fj.data.Either; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -71,10 +64,15 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StopWatch; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import fj.data.Either; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; public abstract class ToscaElementOperation extends BaseOperation { private static Logger log = LoggerFactory.getLogger(ToscaElementOperation.class.getName()); @@ -194,9 +192,6 @@ public abstract class ToscaElementOperation extends BaseOperation { while (edgesToCopyIter.hasNext()) { Edge currEdge = edgesToCopyIter.next(); Vertex currVertex = currEdge.inVertex(); - // if(EdgeLabelEnum.getEdgeLabelEnum(currEdge.label()).equals(EdgeLabelEnum.VERSION)){ - // continue; - // } status = titanDao.createEdge(createdToscaElementVertex.getVertex(), currVertex, EdgeLabelEnum.getEdgeLabelEnum(currEdge.label()), currEdge); if (status != TitanOperationStatus.OK) { CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to create edge with label {} from tosca element vertex {} to vertex with label {} on graph. Status is {}. ", currEdge.label(), createdToscaElementVertex.getUniqueId(), diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java index 0ae3532169..168b127c9c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java @@ -2040,27 +2040,6 @@ public class ToscaOperationFacade { } } - // private Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria(List<Service> servicesAll, Map<GraphPropertyEnum, Object> propertiesToMatch, Map<GraphPropertyEnum, Object> propertiesNotToMatch) { - // Either<List<GraphVertex>, TitanOperationStatus> getRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll); - // if (getRes.isRight()) { - // if (getRes.right().value() != TitanOperationStatus.NOT_FOUND) { - // CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified services by match properties {} not match properties {} . Status is {}. ", propertiesToMatch, propertiesNotToMatch, getRes.right().value()); - // return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getRes.right().value())); - // } - // } else { - // for (GraphVertex vertex : getRes.left().value()) { - // Either<Component, StorageOperationStatus> getServiceRes = getToscaElementByOperation(vertex); - // if (getServiceRes.isRight()) { - // CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified service {}. Status is {}. ", vertex.getJsonMetadataField(JsonPresentationFields.NAME), getServiceRes.right().value()); - // return Either.right(getServiceRes.right().value()); - // } else { - // servicesAll.add((Service) getToscaElementByOperation(vertex).left().value()); - // } - // } - // } - // return Either.left(servicesAll); - // } - private Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria(List<Service> servicesAll, Map<GraphPropertyEnum, Object> propertiesToMatch, Map<GraphPropertyEnum, Object> propertiesNotToMatch) { Either<List<GraphVertex>, TitanOperationStatus> getRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll); if (getRes.isRight()) { @@ -2120,7 +2099,6 @@ public class ToscaOperationFacade { Either<PropertyDefinition, StorageOperationStatus> result = null; Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; newPropertyDefinition.setName(propertyName); - // newPropertyDefinition.setParentUniqueId(resource.getUniqueId()); //todo- DELETE me after 10.18, ownerId==null => current resource is the owner. ownerId should be null since coming for the servlet => changing self resource property, assigning a null value actually means that the property has no assigned owner ,therfor current resource is the owner StorageOperationStatus status = getToscaElementOperation(resource).addToscaDataToToscaElement(resource.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition, JsonPresentationFields.NAME); if (status != StorageOperationStatus.OK) { CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the resource {}. Status is {}. ", propertyName, resource.getName(), status); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java index 260763cced..3bda11641b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java @@ -65,35 +65,12 @@ public class DaoStatusConverter { case ILLEGAL_ARGUMENT: return StorageOperationStatus.BAD_REQUEST; - // case HTTP_PROTOCOL_ERROR: - // return StorageOperationStatus.HTTP_PROTOCOL_ERROR; - // case DB_NOT_AVAILABLE: - // return StorageOperationStatus.STORAGE_NOT_AVAILABLE; - // case DB_READ_ONLY: - // return StorageOperationStatus.READ_ONLY_STORAGE; - // case BAD_REQUEST: - // return StorageOperationStatus.BAD_REQUEST; - // case LEGACY_INDEX_ERROR: - // return StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR; - // case SCHEMA_ERROR: - // return StorageOperationStatus.SCHEMA_ERROR; - // case TRANSACTION_ERROR: - // return StorageOperationStatus.TRANSACTION_ERROR; - // case EXECUTION_FAILED: - // return StorageOperationStatus.EXEUCTION_FAILED; case ALREADY_EXIST: return StorageOperationStatus.ENTITY_ALREADY_EXISTS; case PROPERTY_NAME_ALREADY_EXISTS: return StorageOperationStatus.PROPERTY_NAME_ALREADY_EXISTS; case INVALID_PROPERTY: return StorageOperationStatus.INVALID_PROPERTY; - // case WRONG_INPUT: - // return StorageOperationStatus.BAD_REQUEST; - // case GENERAL_ERROR: - // return StorageOperationStatus.GENERAL_ERROR; - // case NOT_SUPPORTED: - // return StorageOperationStatus.OPERATION_NOT_SUPPORTED; - default: return StorageOperationStatus.GENERAL_ERROR; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java index 53a7f39001..c86559bb59 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java @@ -20,13 +20,7 @@ package org.openecomp.sdc.be.model.operations.impl; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - +import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; @@ -50,7 +44,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import fj.data.Either; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; @Component("interface-operation") public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation { @@ -194,34 +193,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation return Either.left(createNodeResult.left().value()); } - // @Override - // public Either<InterfaceDefinition, StorageOperationStatus> getInterface( - // String interfaceId) { - // - // /* - // * Either<InterfaceData, TitanOperationStatus> getResult = - // * this.titanGenericDao - // * .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), - // * interfaceId, InterfaceData.class); if (getResult.isLeft()) { - // * InterfaceData propertyData = getResult.left().value(); return - // * Either.left(convertPropertyDataToPropertyDefinition(propertyData)); } - // * else { TitanOperationStatus titanStatus = getResult.right().value(); - // * log.debug("Node with id " + propertyId + - // * " was not found in the graph. status: " + titanStatus); - // * StorageOperationStatus storageOperationStatus = - // * DaoStatusConverter.convertTitanStatusToStorageStatus(titanStatus); - // * return Either.right(storageOperationStatus); } - // */ - // return null; - // } - - // @Override - // public Either<InterfaceDefinition, StorageOperationStatus> getInterface( - // String interfaceId, boolean inTransaction) { - // // TODO Auto-generated method stub - // return null; - // } - @Override public Either<Map<String, InterfaceDefinition>, StorageOperationStatus> getAllInterfacesOfResource(String resourceIdn, boolean recursively) { return getAllInterfacesOfResource(resourceIdn, recursively, false); @@ -431,18 +402,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation @Override public Either<Operation, StorageOperationStatus> updateInterfaceOperation(String resourceId, String interfaceName, String operationName, Operation operation, boolean inTransaction) { Either<Operation, StorageOperationStatus> status = updateOperationOnGraph(operation, resourceId, interfaceName, operationName); - - /* - * if (status.isRight()) { if (false == inTransaction) { titanGenericDao.rollback(); } - * log.error("Failed to update operation {} of interfaceName {} of resource {}", operationName, interfaceName, resourceId); - * return - * Either.right(DaoStatusConverter .convertTitanStatusToStorageStatus(status.right().value())); } else { if (false == inTransaction) { titanGenericDao.commit(); } OperationData operationData = status.left().value(); - * - * Operation operationDefResult = convertOperationDataToOperation(operationData); - * - * - * log.debug("The returned OperationDefintion is {}", operationDefResult); return Either.left(operationDefResult); } - */ return status; } @@ -452,11 +411,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation InterfaceData.class); if (childrenNodes.isRight()) { - /* - * InterfaceDefinition intDef = new InterfaceDefinition(); intDef.setType(interfaceName); Map<String, Operation> opMap = new HashMap<String, Operation>(); opMap.put(operationName, operation); intDef.setOperations(opMap); - * Either<InterfaceDefinition, StorageOperationStatus> statusRes = this .createInterfaceOnResource(intDef, resourceId, interfaceName, true); if (statusRes.isRight()) return Either.right(statusRes.right().value()); else { - * InterfaceDefinition newDef = statusRes.left().value(); Operation res = newDef.getOperations().get(operationName); return Either.left(res); } - */ return updateOperationFromParentNode(operation, resourceId, interfaceName, operationName); } else { @@ -634,10 +588,7 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } } } - // if(newOperation == null) return Either.right(StorageOperationStatus.GENERAL_ERROR); - // else - // return Either.left(newOperation); } private Either<InterfaceData, TitanOperationStatus> findInterfaceOnParentNode(String resourceId, String interfaceName) { |