aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-25 15:05:31 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-25 14:24:44 +0000
commit05c625fb9c3673d6c60511958f7e051257247c2b (patch)
tree28df153c7f9bdfd5b5682a6ff4cbeced23f30d3c /openecomp-be/api
parent22f1220c2dda43e3dcbadd70180db521a7984d1d (diff)
Refactor list revisions api
Remove zusammen-api dependency in versioning-api, enhance version zusammen dao impl UT. Issue-ID: SDC-779 Change-Id: Ic792462eac52f1f5129f92ce80d3deb641c90916 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/api')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
index 466734208d..c2f6c4708d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.versioning.ItemManager;
import org.openecomp.sdc.versioning.ItemManagerFactory;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.RevisionIdNotFoundErrorBuilder;
@@ -63,6 +64,7 @@ import org.springframework.stereotype.Service;
import javax.inject.Named;
import javax.ws.rs.core.Response;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
@@ -146,8 +148,19 @@ public class VersionsImpl implements Versions {
GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>();
MapRevisionToDto mapper = new MapRevisionToDto();
- versioningManager.listRevisions(itemId, new Version(versionId))
- .forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class)));
+ List<Revision> revisions = versioningManager.listRevisions(itemId, new Version(versionId));
+ /* When creating a new item an initial version is created with invalid data.
+ This revision is not an applicable revision. The logic of identifying this revision is:
+ 1- only the first version of item has this issue
+ 2- only in the first item version there are 2 revisions created
+ 3- the second revision is in format "Initial <vlm/vsp>: <name of the vlm/vsp>"
+ 4- only if a revision in this format exists we remove the first revision. */
+ if (revisions.size() > 1 &&
+ revisions.get(revisions.size() - 2).getMessage().matches("Initial .*:.*")) {
+ revisions.remove(revisions.size() - 1);
+ }
+
+ revisions.forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class)));
return Response.ok(results).build();
}