summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java73
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java19
2 files changed, 50 insertions, 42 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 857c5e32b7..b47c3928e8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -522,8 +522,7 @@ public class ServiceImportBusinessLogic{
return Either.right(createArtifactsFromCsar.right().value());
}
return Either.left(createArtifactsFromCsar.left().value());
- }catch(Exception e)
- {
+ }catch(Exception e) {
log.debug("Exception occured in getResourceResponseFormatEither, message:{}", e.getMessage(), e);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
@@ -3026,39 +3025,7 @@ public class ServiceImportBusinessLogic{
serviceImportParseLogic.validateResourceFieldsBeforeUpdate(oldResource, newResource, inTransaction, isNested);
serviceImportParseLogic
.validateCapabilityTypesCreate(user, serviceImportParseLogic.getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
- newResource.setContactId(newResource.getContactId().toLowerCase());
- newResource.setCreatorUserId(user.getUserId());
- newResource.setCreatorFullName(user.getFullName());
- newResource.setLastUpdaterUserId(user.getUserId());
- newResource.setLastUpdaterFullName(user.getFullName());
- newResource.setUniqueId(oldResource.getUniqueId());
- newResource.setVersion(oldResource.getVersion());
- newResource.setInvariantUUID(oldResource.getInvariantUUID());
- newResource.setLifecycleState(oldResource.getLifecycleState());
- newResource.setUUID(oldResource.getUUID());
- newResource.setNormalizedName(oldResource.getNormalizedName());
- newResource.setSystemName(oldResource.getSystemName());
- if (oldResource.getCsarUUID() != null) {
- newResource.setCsarUUID(oldResource.getCsarUUID());
- }
- if (oldResource.getImportedToscaChecksum() != null) {
- newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
- }
- if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType().isEmpty()) {
- newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
- }
- if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion().isEmpty()) {
- newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
- }
- if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts().isEmpty()) {
- serviceBusinessLogic.setToscaArtifactsPlaceHolders(newResource, user);
- }
- if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
- newResource.setInterfaces(oldResource.getInterfaces());
- }
- if (CollectionUtils.isEmpty(newResource.getProperties())) {
- newResource.setProperties(oldResource.getProperties());
- }
+ createNewResourceToOldResource(newResource, oldResource, user);
Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
.overrideComponent(newResource, oldResource);
@@ -3084,6 +3051,42 @@ public class ServiceImportBusinessLogic{
}
}
+ protected void createNewResourceToOldResource(Resource newResource, Resource oldResource, User user) {
+ newResource.setContactId(newResource.getContactId().toLowerCase());
+ newResource.setCreatorUserId(user.getUserId());
+ newResource.setCreatorFullName(user.getFullName());
+ newResource.setLastUpdaterUserId(user.getUserId());
+ newResource.setLastUpdaterFullName(user.getFullName());
+ newResource.setUniqueId(oldResource.getUniqueId());
+ newResource.setVersion(oldResource.getVersion());
+ newResource.setInvariantUUID(oldResource.getInvariantUUID());
+ newResource.setLifecycleState(oldResource.getLifecycleState());
+ newResource.setUUID(oldResource.getUUID());
+ newResource.setNormalizedName(oldResource.getNormalizedName());
+ newResource.setSystemName(oldResource.getSystemName());
+ if (oldResource.getCsarUUID() != null) {
+ newResource.setCsarUUID(oldResource.getCsarUUID());
+ }
+ if (oldResource.getImportedToscaChecksum() != null) {
+ newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
+ }
+ if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType().isEmpty()) {
+ newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
+ }
+ if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion().isEmpty()) {
+ newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
+ }
+ if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts().isEmpty()) {
+ serviceBusinessLogic.setToscaArtifactsPlaceHolders(newResource, user);
+ }
+ if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
+ newResource.setInterfaces(oldResource.getInterfaces());
+ }
+ if (CollectionUtils.isEmpty(newResource.getProperties())) {
+ newResource.setProperties(oldResource.getProperties());
+ }
+ }
+
protected Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map<String, Object> mappedToscaTemplate, boolean needLock,
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index 65576d1567..935a5d6796 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -2198,13 +2198,18 @@ public class ServiceImportParseLogic {
}
public void associateComponentInstancePropertiesToComponent(String yamlName, Resource resource, Map<String, List<ComponentInstanceProperty>> instProperties) {
- Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
- .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
- if (addPropToInst.isRight()) {
- log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
- addPropToInst.right().value());
- throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ try {
+ Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
+ .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
+ if (addPropToInst.isRight()) {
+ log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
+ addPropToInst.right().value());
+ throw new ComponentException(componentsUtils.getResponseFormat(
+ componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ }
+ } catch (Exception e) {
+ log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage());
+ throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}