diff options
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java index 5342367a09..c66f7ea5dd 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTransition.java @@ -21,11 +21,13 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; +import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.facade.operations.CatalogOperation; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; @@ -46,6 +48,8 @@ import java.util.Arrays; public class UndoCheckoutTransition extends LifeCycleTransition { private static final Logger log = Logger.getLogger(CheckoutTransition.class); + private CatalogOperation catalogOperations; + public UndoCheckoutTransition(ComponentsUtils componentUtils, ToscaElementLifecycleOperation lifecycleOperation, ToscaOperationFacade toscaOperationFacade, JanusGraphDao janusGraphDao) { super(componentUtils, lifecycleOperation, toscaOperationFacade, janusGraphDao); @@ -68,6 +72,10 @@ public class UndoCheckoutTransition extends LifeCycleTransition { return AuditingActionEnum.UNDO_CHECKOUT_RESOURCE; } + void setCatalogOperations(CatalogOperation catalogOperations) { + this.catalogOperations = catalogOperations; + } + @Override public Either<Boolean, ResponseFormat> validateBeforeTransition(Component component, ComponentTypeEnum componentType, User modifier, User owner, LifecycleStateEnum oldState, LifecycleChangeInfoWithAction lifecycleChangeInfo) { String componentName = component.getComponentMetadataDefinition().getMetadataDataDefinition().getName(); @@ -110,7 +118,14 @@ public class UndoCheckoutTransition extends LifeCycleTransition { result = Either.right(responseFormat); } else { - result = Either.left(ModelConverter.convertFromToscaElement(undoCheckoutResourceResult.left().value())); + ToscaElement element = undoCheckoutResourceResult.left().value(); + if(element == null){ + catalogOperations.updateCatalog(ChangeTypeEnum.DELETE, component); + result = Either.left(null); + } + else{ + result = Either.left(ModelConverter.convertFromToscaElement(element)); + } } } finally { if (result == null || result.isRight()) { @@ -124,5 +139,6 @@ public class UndoCheckoutTransition extends LifeCycleTransition { } return result; } + } |