summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-09-19 12:54:50 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-09-27 08:20:25 +0000
commitf02c8a02bf45824ef7f8bb76b55462960f561ec3 (patch)
tree61b445167b03b64ad742116d0f721fd5f770981b /catalog-be/src/main/java
parent3527b3e98ec9236072c97a66b3d74955316e094e (diff)
User is unable to modify name of VF
User is unable to modify name of VF having operations which was created via Heat Flow Change-Id: I42b666137b26755cccf71028b220560f42b0c0f7 Issue-ID: SDC-1771 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java50
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java73
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java7
4 files changed, 57 insertions, 77 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index fee386ab29..453564e2f8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -166,6 +166,10 @@ public abstract class BaseBusinessLogic {
public void setInterfaceOperation(InterfaceOperation interfaceOperation) {
this.interfaceOperation = interfaceOperation;
}
+ public void setInterfaceOperationBusinessLogic(InterfaceOperationBusinessLogic interfaceOperationBusinessLogic) {
+ this.interfaceOperationBusinessLogic = interfaceOperationBusinessLogic;
+ }
+
User validateUserNotEmpty(User user, String ecompErrorContext) {
return userValidations.validateUserNotEmpty(user, ecompErrorContext);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
index 792e23af3b..6f822fd7e3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
@@ -18,12 +18,9 @@
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
@@ -39,6 +36,12 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
@Component("interfaceOperationBusinessLogic")
public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
@@ -273,4 +276,43 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
}
return Either.left(true);
}
+
+ public Either<Boolean, ResponseFormat> validateComponentNameAndUpdateInterfaces(org.openecomp.sdc.be.model.Component oldComponent,
+ org.openecomp.sdc.be.model.Component newComponent) {
+ if(!oldComponent.getName().equals(newComponent.getName()) ) {
+ Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName = InterfaceUtils
+ .getInterfaceDefinitionListFromToscaName(oldComponent.getInterfaces().values(),
+ oldComponent.getName());
+ for (InterfaceDefinition interfaceDefinition : interfaceDefinitionListFromToscaName) {
+
+ Either<InterfaceDefinition, ResponseFormat> interfaceDefinitionResponseEither = updateInterfaceDefinition(oldComponent,
+ newComponent, interfaceDefinition);
+ if(interfaceDefinitionResponseEither.isRight()) {
+ return Either.right(interfaceDefinitionResponseEither.right().value());
+ }
+ }
+ }
+ return Either.left(Boolean.TRUE);
+ }
+ private Either<InterfaceDefinition, ResponseFormat > updateInterfaceDefinition(org.openecomp.sdc.be.model.Component oldComponent,
+ org.openecomp.sdc.be.model.Component newComponent,
+ InterfaceDefinition interfaceDefinition) {
+ InterfaceUtils.createInterfaceToscaResourceName(newComponent.getName());
+ interfaceDefinition.setToscaResourceName(InterfaceUtils
+ .createInterfaceToscaResourceName(newComponent.getName()));
+ try {
+ Either<InterfaceDefinition, StorageOperationStatus> interfaceUpdate = interfaceOperation
+ .updateInterface(oldComponent.getUniqueId(), interfaceDefinition);
+ if (interfaceUpdate.isRight()) {
+ LOGGER.error("Failed to Update interface {}. Response is {}. ", newComponent.getName(), interfaceUpdate.right().value());
+ titanDao.rollback();
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(interfaceUpdate.right().value(), ComponentTypeEnum.RESOURCE)));
+ }
+ } catch (Exception e) {
+ LOGGER.error("Exception occurred during update interface toscaResourceName : {}", e);
+ titanDao.rollback();
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ return Either.left( interfaceDefinition);
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 492f5bf850..6bb8c5c613 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -63,8 +63,6 @@ import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
-import org.openecomp.sdc.be.model.jsontitan.utils.InterfaceUtils;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.*;
@@ -171,13 +169,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
@Autowired
private CsarBusinessLogic csarBusinessLogic;
- @Autowired
- private InterfaceOperation interfaceOperation;
-
- public void setInterfaceOperation(InterfaceOperation interfaceOperation) {
- this.interfaceOperation = interfaceOperation;
- }
-
public LifecycleBusinessLogic getLifecycleBusinessLogic() {
return lifecycleBusinessLogic;
}
@@ -3987,7 +3978,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
newResource.setDerivedFrom(null);
}
- Either<Boolean, ResponseFormat> validateAndUpdateInterfacesEither = validateAndUpdateInterfaces(resourceIdToUpdate, newResource);
+ Either<Boolean, ResponseFormat> validateAndUpdateInterfacesEither =
+ interfaceOperationBusinessLogic.validateComponentNameAndUpdateInterfaces(currentResource, newResource);
if (validateAndUpdateInterfacesEither.isRight()) {
log.error("failed to validate and update Interfaces");
rollbackNeeded = true;
@@ -5172,65 +5164,4 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return super.shouldUpgradeToLatestDerived(clonedComponent);
}
}
-
- private Either<Boolean, ResponseFormat> validateAndUpdateInterfaces(String resourceId, Resource resourceUpdate) {
- Either<Resource, StorageOperationStatus> resourceStorageOperationStatusEither =
- toscaOperationFacade.getToscaElement(resourceId);
- if (resourceStorageOperationStatusEither.isRight()) {
- StorageOperationStatus errorStatus = resourceStorageOperationStatusEither.right().value();
- log.error("Failed to fetch resource information by resource id {}, error {}", resourceId, errorStatus);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(errorStatus)));
- }
-
- Resource storedResource = resourceStorageOperationStatusEither.left().value();
- Map<String, InterfaceDefinition> storedResourceInterfaces = storedResource.getInterfaces();
-
- if(!storedResource.getName().equals(resourceUpdate.getName()) ) {
- Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName = InterfaceUtils
- .getInterfaceDefinitionListFromToscaName(storedResource.getInterfaces().values(),
- storedResource.getName());
-
- for (InterfaceDefinition interfaceDefinition : storedResourceInterfaces.values()) {
- Either<InterfaceDefinition, ResponseFormat> updateInterfaceDefinitionEither = updateInterfaceDefinition(resourceUpdate,
- interfaceDefinition,
- interfaceDefinitionListFromToscaName);
- if(updateInterfaceDefinitionEither.isRight()) {
- return Either.right(updateInterfaceDefinitionEither.right().value());
- }
- }
- }
-
- return Either.left(Boolean.TRUE);
- }
-
- private Either<InterfaceDefinition, ResponseFormat > updateInterfaceDefinition(Resource resourceUpdate,
- InterfaceDefinition interfaceDefinition,
- Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName) {
- interfaceDefinitionListFromToscaName.forEach(interfaceDefinitionFromList -> {
- if(interfaceDefinitionFromList.getToscaResourceName().equals(interfaceDefinition.getToscaResourceName())) {
- log.info("Going to Update interface definition toscaResourceName {} to {}",
- interfaceDefinitionFromList.getToscaResourceName(),
- InterfaceUtils.createInterfaceToscaResourceName(resourceUpdate.getName()));
- interfaceDefinition.setToscaResourceName(InterfaceUtils
- .createInterfaceToscaResourceName(resourceUpdate.getName()));
- }
- } );
- try {
- Either<InterfaceDefinition, StorageOperationStatus> interfaceUpdate = interfaceOperation
- .updateInterface(resourceUpdate.getUniqueId(), interfaceDefinition);
- if (interfaceUpdate.isRight()) {
- log.error("Failed to Update interface {}. Response is {}. ", resourceUpdate.getName(), interfaceUpdate.right().value());
- titanDao.rollback();
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(interfaceUpdate.right().value(), ComponentTypeEnum.RESOURCE)));
- }
- } catch (Exception e) {
- log.error("Exception occurred during update interface toscaResourceName : {}", e);
- titanDao.rollback();
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
- }
-
- return Either.left( interfaceDefinition);
- }
-
} \ No newline at end of file
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index f30088ce9c..e85afdc48f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -518,7 +518,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
log.info("Restricted operation for user: {}, on service: {}", user.getUserId(), currentService.getCreatorUserId());
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
-
+ Either<Boolean, ResponseFormat> validateAndUpdateInterfacesEither = interfaceOperationBusinessLogic.validateComponentNameAndUpdateInterfaces(currentService, serviceUpdate);
+ if (validateAndUpdateInterfacesEither.isRight()) {
+ log.info("failed to validate and update Interfaces on service {}", currentService.getCreatorUserId());
+ return Either.right(validateAndUpdateInterfacesEither.right().value());
+ }
Either<Service, ResponseFormat> validationRsponse = validateAndUpdateServiceMetadata(user, currentService, serviceUpdate);
if (validationRsponse.isRight()) {
log.info("service update metadata: validations field.");
@@ -789,7 +793,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
validateAndUpdateEcompNaming(currentService, serviceUpdate);
currentService.setEnvironmentContext(serviceUpdate.getEnvironmentContext());
-
return Either.left(currentService);
} catch (ComponentException exception) {