diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index d8e85a6..baec3d2 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -686,9 +686,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT NotificationsProducer np = getNotificationProducer(); - np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); - - workspaceLogger.trace("The notifies sent correctly"); + if(destinationSharedFolder instanceof WorkspaceSharedFolder){ + np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); + workspaceLogger.trace("The notifies sent correctly"); + } + else + workspaceLogger.warn("Notifies added item: "+sourceItem+ "to share doesn't sent because "+destinationSharedFolder+" is not istance of WorkspaceSharedFolder"); // np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); } } @@ -740,10 +743,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT NotificationsProducer np = getNotificationProducer(); - np.notifyMovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder); - - workspaceLogger.trace("The notifies was sent correctly"); - + if(sourceSharedFolder instanceof WorkspaceSharedFolder){ + np.notifyMovedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) sourceSharedFolder); + workspaceLogger.trace("The notifies was sent correctly"); + }else + workspaceLogger.warn("Notifies moved item: "+sourceItem+ "from share doesn't sent because "+sourceSharedFolder+" is not istance of WorkspaceSharedFolder"); } }else @@ -852,8 +856,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(NotificationsUtil.isASharedFolder(wsItem)){ notification.notifyFolderRenamed(listSharedContact, wsItem, previousName, newName, wsItem.getIdSharedFolder()); }else{ - WorkspaceFolder sharedFolder = (WorkspaceFolder) workspace.getItem(wsItem.getIdSharedFolder()); - notification.notifyItemRenamed(listSharedContact, previousName, wsItem, sharedFolder); + + //TWO CASES: EITHER ROOT FOLDER AS WorkspaceSharedFolder OR DOESN'T. + WorkspaceItem sharedFolder = workspace.getItem(wsItem.getIdSharedFolder()); + if(sharedFolder instanceof WorkspaceSharedFolder) + notification.notifyItemRenamed(listSharedContact, previousName, wsItem, (WorkspaceSharedFolder) sharedFolder); + else + workspaceLogger.trace("Notifies for rename item itemId: "+itemId+" doesn't sent because: "+sharedFolder+" is not an instance of WorkspaceSharedFolder"); +// notification.notifyItemRenamed(listSharedContact, previousName, wsItem, sharedFolder); } }catch (Exception e) { workspaceLogger.error("An error occurred in checkNotify ", e); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java index cd5b8ea..6ce8e4c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsProducer.java @@ -64,7 +64,7 @@ public class NotificationsProducer { * @param listContacts * @param sharedFolder */ - public void notifyFolderSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + public void notifyFolderSharing(final List listContacts, final WorkspaceSharedFolder sharedFolder) { new Thread(){ @Override @@ -164,7 +164,7 @@ public class NotificationsProducer { * @param listContacts * @param sharedFolder */ - public void notifyItemRenamed(final List listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceFolder sharedFolder) { + public void notifyItemRenamed(final List listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder) { new Thread(){ @Override @@ -300,7 +300,7 @@ public class NotificationsProducer { * @param listContacts * @param unSharedFolder */ - public void notifyFolderUnSharing(final List listContacts, final WorkspaceFolder unSharedFolder) { + public void notifyFolderUnSharing(final List listContacts, final WorkspaceSharedFolder unSharedFolder) { new Thread() { @@ -320,8 +320,7 @@ public class NotificationsProducer { //DEBUG // System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName()); - - boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), unSharedFolder); + boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder); if(!notify) logger.error("An error occured when notifies user: "+infoContactModel.getLogin()); @@ -346,7 +345,7 @@ public class NotificationsProducer { * @param listContacts * @param workspaceItem */ - public void notifyAddedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { + public void notifyAddedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { new Thread() { @Override @@ -401,7 +400,7 @@ public class NotificationsProducer { * @param listContacts * @param workspaceItem */ - public void notifyUpdatedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { + public void notifyUpdatedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { new Thread() { @Override @@ -459,7 +458,7 @@ public class NotificationsProducer { * @param listContacts * @param sharedFolder */ - public void notifyMovedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { + public void notifyMovedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { new Thread() { @@ -529,7 +528,7 @@ public class NotificationsProducer { * @param listContacts * @param sharedFolder */ - public void notifyRemovedItemToSharing(final List listContacts, final String itemName, final WorkspaceFolder sharedFolder) { + public void notifyRemovedItemToSharing(final List listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) { new Thread() { diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java index 064a595..dedd3c8 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/notifications/NotificationsUtil.java @@ -64,14 +64,18 @@ public class NotificationsUtil { NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession)); - //SWITCH BEETWEEN ADDED OR UPDATED - if(!isOverwrite) - np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); - else - np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); - - - logger.trace("The notifies was sent correctly"); + if(destinationSharedFolder instanceof WorkspaceSharedFolder){ + + //SWITCH BEETWEEN ADDED OR UPDATED + if(!isOverwrite) + np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); + else + np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); + + + logger.trace("The notifies was sent correctly"); + }else + logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder"); // np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); } } @@ -187,8 +191,13 @@ public class NotificationsUtil { //Notify Removed Item To Sharing? if(!isRootFolderShared){ - np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceFolder) sourceSharedFolder); - logger.trace("The notifies was sent correctly"); + if(sourceSharedFolder instanceof WorkspaceSharedFolder){ + np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceSharedFolder) sourceSharedFolder); + logger.trace("The notifies was sent correctly"); + } + else + logger.trace("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder"); + }else{ //Case removed shared folder np.notifySharedFolderDeleted(listContacts, oldItemName);