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 8654345..38a4359 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 @@ -1511,7 +1511,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT fileModel.setParentFileModel(parent); } - workspaceLogger.trace("list parents return size: "+listParents.size()); 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 df1cc1a..a285268 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 @@ -63,10 +63,12 @@ public class NotificationsProducer { @Override public void run() { + gcubeLogger.trace("Send notify folder sharing is running..."); + for (InfoContactModel infoContactModel : listContacts) { try{ //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER -// if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment + if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment gcubeLogger.trace("Send notify folder sharing for user "+infoContactModel.getId()); @@ -79,7 +81,7 @@ public class NotificationsProducer { if(!notify) gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); -// } + } }catch (Exception e) { gcubeLogger.error("An error occured in notifyFolderSharing ", e); e.printStackTrace(); @@ -105,38 +107,128 @@ public class NotificationsProducer { @Override public void run() { - printContacts(listContacts); +// printContacts(listContacts); + gcubeLogger.trace("Send notify folder un share is running..."); for (InfoContactModel infoContactModel : listContacts) { try{ //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER -// if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment + if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment gcubeLogger.trace("Send notify folder un share user "+infoContactModel.getId()); //DEBUG - System.out.println("Send notify folder un share user "+infoContactModel.getId()); +// System.out.println("Send notify folder un share user "+infoContactModel.getId()); boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), sharedFolder, userId); if(!notify) gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); -// } + } }catch (Exception e) { gcubeLogger.error("An error occured in notifyFolderSharing ", e); e.printStackTrace(); } } - gcubeLogger.trace("un share notifications is completed"); - System.out.println("un share folder completed"); + gcubeLogger.trace("notify of un share notifications is completed"); + } + + }.start(); + } + + + + /** + * Runs a new thread to notify the contacts passed in input + * @param listContacts + * @param sharedFolder + */ + public void notifyAddedItemToSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + + + new Thread() { + @Override + public void run() { + +// printContacts(listContacts); + gcubeLogger.trace("Send notify added item in sharedfolder is running..."); + + for (InfoContactModel infoContactModel : listContacts) { + try{ + + //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER + if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment + + gcubeLogger.trace("Send notify added item in sharedfolder + "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + + //DEBUG +// System.out.println("Send notify folder un share user "+infoContactModel.getId()); + + boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getId(), sharedFolder); + + if(!notify) + gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); + } + }catch (Exception e) { + gcubeLogger.error("An error occured in notifyAddedItemToSharing ", e); + e.printStackTrace(); + } + } + + gcubeLogger.trace("notigy of added item in shared folder is completed"); + } + + }.start(); + } + + + + /** + * Runs a new thread to notify the contacts passed in input + * @param listContacts + * @param sharedFolder + */ + public void notifyRemovedItemToSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + + + new Thread() { + @Override + public void run() { + +// printContacts(listContacts); + gcubeLogger.trace("Send notify remove item in sharedfolder is running..."); + + for (InfoContactModel infoContactModel : listContacts) { + try{ + + //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER + if(infoContactModel.getId().compareTo(userId)!=0){ //TODO remove this comment + + gcubeLogger.trace("Send notify remove item in sharedfolder + "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + + //DEBUG +// System.out.println("Send notify folder un share user "+infoContactModel.getId()); + + boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getId(), sharedFolder); + + if(!notify) + gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); + } + }catch (Exception e) { + gcubeLogger.error("An error occured in notifyRemovedItemToSharing ", e); + e.printStackTrace(); + } + } + + gcubeLogger.trace("notify of removed item in shared folder is completed"); } }.start(); } - + //DEBUG private void printContacts(List listContacts){ System.out.println("Print contacts"); @@ -164,6 +256,8 @@ public class NotificationsProducer { NotificationsProducer feeder = new NotificationsProducer(session); + + } }