Fix Owner Healer

Change-Id: I85371b7cd6e2fa6e929b42b4773eef685252bcff
Issue-ID: SDC-837
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
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 32975b3..550b4e6 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 @@
             <artifactId>togglz-servlet</artifactId>
             <version>${togglz.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.togglz</groupId>
+            <artifactId>togglz-console</artifactId>
+            <version>${togglz.version}</version>
+        </dependency>
     </dependencies>
 
 
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 acc20c9..b9fc33f 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.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 @@
 
   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 @@
       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());
   }