From ac7c685240c6cfa34a6e6afa86e602954b9a8047 Mon Sep 17 00:00:00 2001 From: ayalaben Date: Sun, 31 Dec 2017 17:57:36 +0200 Subject: Fix Owner Healer Change-Id: I85371b7cd6e2fa6e929b42b4773eef685252bcff Issue-ID: SDC-837 Signed-off-by: ayalaben --- .../onboarding-rest-war/pom.xml | 5 +++++ .../openecomp/sdc/healing/healers/OwnerHealer.java | 24 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'openecomp-be') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml index 32975b3ebf..550b4e610f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml @@ -176,6 +176,11 @@ togglz-servlet ${togglz.version} + + org.togglz + togglz-console + ${togglz.version} + diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java index acc20c97e4..b9fc33f47a 100644 --- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java +++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java @@ -7,11 +7,17 @@ import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory; import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes; import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.notification.dao.SubscribersDao; +import org.openecomp.sdc.notification.factories.SubscribersDaoFactory; +import org.openecomp.sdc.versioning.dao.ItemDao; +import org.openecomp.sdc.versioning.dao.ItemDaoFactory; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.Item; import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Objects; /** * Created by ayalaben on 8/28/2017 @@ -22,6 +28,10 @@ public class OwnerHealer implements Healer { private static final ItemPermissionsDao permissionsDao = ItemPermissionsDaoFactory.getInstance().createInterface(); + private static final ItemDao itemDao = ItemDaoFactory.getInstance().createInterface(); + + private static final SubscribersDao subscribersDao = SubscribersDaoFactory.getInstance() + .createInterface(); public Object heal(String itemId, Version version) { mdcDataDebugMessage.debugEntryMessage(null); @@ -36,11 +46,25 @@ public class OwnerHealer implements Healer { permissionsDao.updateItemPermissions(itemId, PermissionTypes.Owner.name(), Collections.singleton(currentUserId), new HashSet<>()); + updateItemOwner(itemId,currentUserId); + + subscribersDao.subscribe(currentUserId,itemId); + return currentUserId; } return itemPermissions.stream().filter(this::isOwnerPermission).findFirst().get().getUserId(); } + private void updateItemOwner(String itemId,String userId) { + Item item = new Item(); + item.setId(itemId); + Item retrievedItem = itemDao.get(item); + if (Objects.nonNull(retrievedItem)) { + retrievedItem.setOwner(userId); + itemDao.update(retrievedItem); + } + } + private boolean isOwnerPermission(ItemPermissionsEntity permissionsEntity) { return permissionsEntity.getPermission().equals(PermissionTypes.Owner.name()); } -- cgit 1.2.3-korg