diff options
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r-- | openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java | 24 |
1 files changed, 24 insertions, 0 deletions
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()); } |