summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src
diff options
context:
space:
mode:
authorayalaben <Ayala.Benzvi@Amdocs.Com>2017-12-31 17:57:36 +0200
committerayalaben <ayala.benzvi@amdocs.com>2017-12-31 17:57:36 +0200
commitac7c685240c6cfa34a6e6afa86e602954b9a8047 (patch)
tree7e1f77bd4f0f2745ff0282a79a36ca3244ea2b2a /openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src
parentfa79ba2e1b23504e07f1fa8019050594ac7dfdf0 (diff)
Fix Owner Healer
Change-Id: I85371b7cd6e2fa6e929b42b4773eef685252bcff Issue-ID: SDC-837 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java24
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());
}