From 0c51c0f629767d17c364229e5d528c8b609334da Mon Sep 17 00:00:00 2001 From: ayalaben Date: Tue, 24 Apr 2018 15:57:52 +0300 Subject: notify catalog on items action Change-Id: I3be022809b83ec939eaa0a383fa9e7b659dc096b Issue-ID: SDC-1257 Signed-off-by: ayalaben --- .../openecomp/sdcrests/item/rest/services/ItemsImpl.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java index ae6e24bb65..359662ad33 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java @@ -21,7 +21,7 @@ import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; import java.util.Arrays; -import java.util.Collection; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; @@ -66,6 +66,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; + @Named @Service("items") @Scope(value = "prototype") @@ -85,6 +86,8 @@ public class ItemsImpl implements Items { private NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); + private CatalogNotifier catalogNotifier = new CatalogNotifier(); + private Map actionSideAffectsMap = new EnumMap<>(ItemAction.class); @PostConstruct @@ -97,6 +100,7 @@ public class ItemsImpl implements Items { private static final String ONBOARDING_METHOD = "onboardingMethod"; + @Override public Response actOn(ItemActionRequestDto request, String itemId, String user) { @@ -116,6 +120,7 @@ public class ItemsImpl implements Items { } actionSideAffectsMap.get(request.getAction()).execute(item, user); + catalogNotifier.execute(Collections.singleton(itemId),request.getAction(),2); return Response.ok().build(); } @@ -131,8 +136,8 @@ public class ItemsImpl implements Items { GenericCollectionWrapper results = new GenericCollectionWrapper<>(); MapItemToDto mapper = new MapItemToDto(); itemManager.list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) - .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); + .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); return Response.ok(results).build(); @@ -323,4 +328,4 @@ public class ItemsImpl implements Items { private enum OnboardingMethod { NetworkPackage, Manual; } -} +} \ No newline at end of file -- cgit 1.2.3-korg