aboutsummaryrefslogtreecommitdiffstats
path: root/workflow-designer-be
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-07-29 14:46:38 +0300
committerayalaben <ayala.benzvi@amdocs.com>2018-07-31 14:42:06 +0300
commitbf350ee89ef5b73281d4cc5e78acd999ede66f88 (patch)
tree96999cd0c4db341cbec9bb62d1830c297044575e /workflow-designer-be
parent12fe45f7982fec92b39c8a981a0f42530e6c1c83 (diff)
Publish version exception handling
Change-Id: If4e172f40c7410c5fa90d5686733f4d995b98d17 Issue-ID: SDC-1518 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'workflow-designer-be')
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java10
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java28
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java1
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java11
-rw-r--r--workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java4
5 files changed, 41 insertions, 13 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
index ed9371e6..e10279fe 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
@@ -23,12 +23,14 @@ import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
public interface ArtifactRepository {
- void update(String id, String versionId,ArtifactEntity artifactEntity);
+ void update(String workflowId, String versionId,ArtifactEntity artifactEntity);
- Optional<ArtifactEntity> get(String id, String versionId);
+ Optional<ArtifactEntity> get(String workflowId, String versionId);
- void createStructure(String id, String versionId);
+ boolean isExist(String workflowId, String versionId);
- void delete(String id, String versionId);
+ void createStructure(String workflowId, String versionId);
+
+ void delete(String workflowId, String versionId);
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
index 3c528db1..b49433cc 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
@@ -20,6 +20,7 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElemen
import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
@@ -46,23 +47,23 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
@Override
- public void update(String id, String versionId, ArtifactEntity artifactEntity) {
+ public void update(String workflowId, String versionId, ArtifactEntity artifactEntity) {
ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.UPDATE);
artifactElement.setData(artifactEntity.getArtifactData());
artifactElement.getInfo().addProperty(FILE_NAME_PROPERTY, artifactEntity.getFileName());
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
zusammenAdaptor
.saveElement(context, elementContext, artifactElement, "Update WorkflowVersion Artifact Element");
}
@Override
- public Optional<ArtifactEntity> get(String id, String versionId) {
+ public Optional<ArtifactEntity> get(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
Optional<Element> elementOptional =
zusammenAdaptor.getElementByName(context, elementContext, null, WorkflowElementType.ARTIFACT.name());
@@ -80,9 +81,20 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
}
@Override
- public void createStructure(String id, String versionId) {
+ public boolean isExist(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ Optional<ElementInfo> optionalElementInfo = zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ WorkflowElementType.ARTIFACT.name());
+ return optionalElementInfo.isPresent() && optionalElementInfo.get().getInfo().getProperties()
+ .containsKey(FILE_NAME_PROPERTY);
+ }
+
+ @Override
+ public void createStructure(String workflowId, String versionId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.CREATE);
artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
@@ -93,9 +105,9 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
}
@Override
- public void delete(String id, String versionId) {
+ public void delete(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.UPDATE);
artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
index 1c828d43..17f95ae1 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
@@ -30,6 +30,7 @@ public class WorkflowVersion {
private String description;
private String baseId;
private WorkflowVersionState state;
+ private boolean hasArtifact;
private Collection<ParameterEntity> inputs = Collections.emptyList();
private Collection<ParameterEntity> outputs = Collections.emptyList();
private Date creationTime;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
index 484c598a..0f7c993d 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
@@ -18,6 +18,7 @@ package org.onap.sdc.workflow.services.impl;
import static org.onap.sdc.workflow.persistence.types.WorkflowVersionState.CERTIFIED;
+import com.amdocs.zusammen.datatypes.response.ErrorCode;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
@@ -43,6 +44,7 @@ import org.onap.sdc.workflow.services.exceptions.VersionModificationException;
import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
import org.onap.sdc.workflow.services.impl.mappers.VersionMapper;
import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.versioning.VersioningManager;
@@ -95,6 +97,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
public WorkflowVersion get(String workflowId, String versionId) {
WorkflowVersion workflowVersion = versionMapper.versionToWorkflowVersion(getVersion(workflowId, versionId));
loadAndAddParameters(workflowId, workflowVersion);
+ workflowVersion.setHasArtifact(artifactRepository.isExist(workflowId,versionId));
return workflowVersion;
}
@@ -140,9 +143,14 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
updateParameters(workflowId, version.getId(), workflowVersion.getInputs(), workflowVersion.getOutputs());
versioningManager.updateVersion(workflowId, version);
- versioningManager.publish(workflowId, version, "Update version");
+
+ Version updatedVersion = versioningManager.get(workflowId, version);
+ if(updatedVersion.getState().isDirty()) {
+ versioningManager.publish(workflowId, version, "Update version");
+ }
}
+
@Override
public WorkflowVersionState getState(String workflowId, String versionId) {
return versionStateMapper.versionStatusToWorkflowVersionState(getVersion(workflowId, versionId).getStatus());
@@ -274,4 +282,5 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
private static Optional<Version> findVersion(List<Version> versions, String versionId) {
return versions.stream().filter(version -> versionId.equals(version.getId())).findFirst();
}
+
} \ No newline at end of file
diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java
index 7dee5245..6e5a905b 100644
--- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java
+++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java
@@ -41,6 +41,7 @@ import org.onap.sdc.workflow.services.impl.mappers.VersionMapper;
import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionState;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import org.springframework.mock.web.MockMultipartFile;
@@ -101,6 +102,9 @@ public class WorkflowVersionManagerImplTest {
retrievedVersion.setName("1.0");
retrievedVersion.setDescription("WorkflowVersion description");
retrievedVersion.setStatus(VersionStatus.Draft);
+ VersionState versionState = new VersionState();
+ versionState.setDirty(true);
+ retrievedVersion.setState(versionState);
doReturn(retrievedVersion).when(versioningManagerMock).get(eq(ITEM1_ID), eqVersion(VERSION1_ID));
doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(retrievedVersion.getStatus());