From daaf1d69901a91d642152953433333949adb55e1 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Wed, 27 Feb 2013 18:17:22 +0000 Subject: [PATCH] notifier has been update git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69701 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 1 - pom.xml | 32 +- .../client/AppControllerExplorer.java | 22 +- .../client/model/InfoContactModel.java | 9 + .../view/sharing/DialogShareFolder.java | 15 +- .../multisuggest/MultiDragContact.java | 2 +- .../sharing/multisuggest/MultiValuePanel.java | 3 +- .../client/view/tree/AsyncTreePanel.java | 4 +- .../server/GWTWorkspaceServiceImpl.java | 348 ++++++++++++++++-- .../notifications/NotificationsProducer.java | 163 ++++++-- .../user/workspace/server/util/Util.java | 5 +- 11 files changed, 488 insertions(+), 116 deletions(-) diff --git a/.classpath b/.classpath index 98b6678..8854796 100644 --- a/.classpath +++ b/.classpath @@ -13,7 +13,6 @@ - diff --git a/pom.xml b/pom.xml index 1756083..5b0562f 100644 --- a/pom.xml +++ b/pom.xml @@ -145,29 +145,27 @@ provided - - - - - - - - - org.gcube.portlets.user opengcubeapplication 1.0.0-SNAPSHOT - system - /home/backup-old-home/francesco-mangiacrapa/workspace/opengcubeapplication/target/opengcubeapplication-1.0.0-SNAPSHOT.jar - - - opengcubeapplication - org.gcube.portlets.user - - + + + + + + + + + + + + + + + diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 65c8ffc..4229e26 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -257,15 +257,17 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(isNewFolder){ //create a lowest object to send to server fileModel = new FileModel("tempId", finalDialog.getName(), parentModel, true, false); //create new shared folder + } else{ fileModel = finalDialog.getParentFolder(); //add user for share //create a lowest object to send to server fileModel = new FileModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), fileModel.isDirectory(), fileModel.isShared()); - fileModel.setDescription(finalDialog.getDescription()); } + fileModel.setDescription(finalDialog.getDescription()); + //DEBUG // System.out.println("FileModel id "+fileModel.getIdentifier() + " name: "+fileModel.getName() + " parent " + fileModel.getParentFileModel()); // for(InfoContactModel contact:finalDialog.getSharedListUsers() ){ @@ -721,7 +723,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { // explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " deleting smart folder. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " deleting smart folder.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -763,7 +765,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " saving smart folder. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " saving smart folder.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -827,7 +829,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " renaming item. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " renaming item.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -873,7 +875,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", caught.getMessage()+". Reload root", null); + new MessageBoxAlert("Error", caught.getMessage()+".", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -1020,7 +1022,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { - new MessageBoxAlert("Error", caught.getMessage()+". Reload root" , null); + new MessageBoxAlert("Error", caught.getMessage()+"." , null); System.out.println(caught.getMessage()); explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier()); explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getFileSourceModel().getParentFileModel().getIdentifier()); @@ -1065,7 +1067,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " imaging preview. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " imaging preview.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -1101,7 +1103,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " clicking url. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " clicking url.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -1155,7 +1157,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" creating url. Reload root", null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" creating url.", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); } @@ -1529,7 +1531,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt @Override public void onFailure(Throwable caught) { explorerPanel.getAsycTreePanel().unmask(); - new MessageBoxAlert("Error", "Sorry - getChildrenSubTreeToRootByIdentifier - Reload root", null); + new MessageBoxAlert("Error", "Sorry - getChildrenSubTreeToRootByIdentifier", null); explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/InfoContactModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/InfoContactModel.java index e918416..a8ba10f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/InfoContactModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/InfoContactModel.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.workspace.client.model; import java.io.Serializable; +import java.util.Comparator; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; @@ -59,6 +60,14 @@ public class InfoContactModel extends BaseModelData implements Serializable { public Boolean isCheck(){ return (Boolean) get("check"); } + + public static Comparator COMPARATOR = new Comparator() { + // This is where the sorting happens. + public int compare(InfoContactModel o1, InfoContactModel o2) { + return o1.getLogin().compareToIgnoreCase(o2.getLogin()); + } + }; + @Override public String toString() { diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java index 4586321..4d253b7 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/DialogShareFolder.java @@ -123,7 +123,7 @@ public class DialogShareFolder extends Dialog { buttonMultiDrag.setStyleName("wizardButton"); // buttonMultiDrag.setIcon(Resources.getIconUsers()); - flexTable.setWidget(1, 0, new Label("Add contacts by group dragging")); + flexTable.setWidget(1, 0, new Label("Add more")); flexTable.setWidget(1, 1, buttonMultiDrag); Label labelDescription = new Label("Description"); @@ -233,7 +233,7 @@ public class DialogShareFolder extends Dialog { buttonMultiDrag.setStyleName("wizardButton"); // buttonMultiDrag.setIcon(Resources.getIconUsers()); - flexTable.setWidget(1, 0, new Label("Add contacts by group dragging")); + flexTable.setWidget(1, 0, new Label("Add more")); flexTable.setWidget(1, 1, buttonMultiDrag); Label labelDescription = new Label("Description"); @@ -252,6 +252,7 @@ public class DialogShareFolder extends Dialog { public List getSharedListUsers() { + printSelectedUser(); return suggestPanel.getSelectedUser(); } @@ -305,12 +306,22 @@ public class DialogShareFolder extends Dialog { } suggestPanel.boxSetFocus(); + + printSelectedUser(); } }); } }); } + //DEBUG + private void printSelectedUser(){ + + System.out.println("SELETECTED USERS: "); + for (InfoContactModel contact : suggestPanel.getSelectedUser()) + System.out.println(contact); + } + private void initSuggestContacts(){ suggestPanel.resetItemSelected(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java index 5c866bd..a85e10d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiDragContact.java @@ -60,7 +60,7 @@ public class MultiDragContact extends Dialog { @Override public void componentSelected(ButtonEvent ce) { - MessageBox.info("Group dragging action", "Drag one or more contacts from left list (All Contacts) to right list (Share with contacts) to add the users in your sharing list", null); + MessageBox.info("Group dragging action", "Drag one or more contacts from the left (All Contacts) to the right (Share with contacts) to add users in your sharing list.", null); } }); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java index 010fa92..80a6ba6 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/multisuggest/MultiValuePanel.java @@ -143,9 +143,10 @@ public class MultiValuePanel extends Composite { return new ArrayList(); else { List toReturn = new ArrayList(); + for (String login : itemsSelected) { InfoContactModel wsuser = users.get(login); - if(!toReturn.contains(wsuser)) + if(wsuser!= null && !toReturn.contains(wsuser)) toReturn.add(wsuser); } return toReturn; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java index bdd8cf3..a35e525 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java @@ -705,7 +705,7 @@ public class AsyncTreePanel extends LayoutContainer { @Override public void onFailure(Throwable caught) { - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items. Reload root" +ConstantsExplorer.TRY_AGAIN, null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items." +ConstantsExplorer.TRY_AGAIN, null); removeAllAndRecoveryRoot(); } @@ -737,7 +737,7 @@ public class AsyncTreePanel extends LayoutContainer { @Override public void onFailure(Throwable caught) { - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items. Reload root" +ConstantsExplorer.TRY_AGAIN, null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items. " +ConstantsExplorer.TRY_AGAIN, null); removeAllAndRecoveryRoot(); } 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 38a4359..22d304d 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 @@ -86,9 +86,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public FolderModel getRootForTree() throws Exception { - workspaceLogger.info("getRoot"); - - workspaceLogger.trace("getting workspace"); + workspaceLogger.trace("getRoot"); try { @@ -243,7 +241,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT List listFileGridModels = new ArrayList(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get children for Grid"); + logger.trace("get children for Grid"); workspaceLogger.trace("get children for Grid"); @@ -258,7 +256,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Long endTime = System.currentTimeMillis() - startTime; String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - logger.info("grid getChildren() returning "+listItems.size()+" elements in " + time); + logger.trace("grid getChildren() returning "+listItems.size()+" elements in " + time); listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder); @@ -276,14 +274,101 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public Boolean moveItem(String itemId, String destinationId) throws Exception { - workspaceLogger.info("moveItem itemId: "+itemId+" destination: "+destinationId); + workspaceLogger.trace("moveItem itemId: "+itemId+" destination: "+destinationId); try { Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("moveItem item: "+itemId+" destination: "+destinationId); + logger.trace("moveItem item: "+itemId+" destination: "+destinationId); - workspace.moveItem(itemId, destinationId); + WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE OF MOVE + + if(sourceItem==null) + return Boolean.FALSE; + + String sourceSharedId = null; + boolean sourceItemIsShared = sourceItem.isShared(); + + if(sourceItemIsShared) + sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE + + + System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId); + + workspace.moveItem(itemId, destinationId); //move item + + WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination + + System.out.println("sourceItem.isShared() "+sourceItemIsShared ); + System.out.println("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared()); + + if(folderDestinationItem!=null){ + +// //if folder destination is shared folder +// if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? +// +// //share condition is true if source shared folder is null or not equal to destination shared folder +// shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0); +// +// System.out.println("shareChangeCondition add item: "+ shareChangeCondition); +// +// +// //if shareChangeCondition is true.. notifies added item to sharing +// if(shareChangeCondition){ +// +// List listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder()); +// +// //DEBUG +// printContacts(listContacts); +// +// WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); +// +// np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); +// +//// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); +// } +// } + + try{ + checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem); + + checkNotifyRemoveItemToShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem); + + }catch (Exception e) { + workspaceLogger.error("An error occurred in checkNotify ", e); + } + +// System.out.println("folderDestinationItem.isShared() "+ folderDestinationItem.getName() + ": "+ folderDestinationItem.isShared()); +// +// +// String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():""; +// +// //share condition is true if source shared folder is not equal to destination shared folder +// shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0); +// +// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition); +// +// //Notify Removed Item To Sharing? +// //if source Item is shared and folder destination is not shared or shareChangeCondition is true.. notifies removed item to sharing +// if(sourceItemIsShared && (!folderDestinationItem.isShared() || shareChangeCondition)){ +// +// //get contacts +// List listContacts = getListUserSharedByFolderSharedId(sourceSharedId); +// +// //DEBUG +// printContacts(listContacts); +// +// WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId); +// +// System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName()); +// +// np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder); +// +// } + } + + + return Boolean.TRUE; }catch (InsufficientPrivilegesException e) { @@ -298,15 +383,170 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } + + private void checkNotifyAddItemToShare(WorkspaceItem sourceItem, String sourceSharedId, WorkspaceItem folderDestinationItem) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{ + + if(folderDestinationItem!=null){ + + //if folder destination is shared folder + if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? + + //share condition is true if source shared folder is null or not equal to destination shared folder + boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0); + + System.out.println("shareChangeCondition add item: "+ shareChangeCondition); + + //if shareChangeCondition is true.. notifies added item to sharing + if(shareChangeCondition){ + + List listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder()); + + //DEBUG + printContacts(listContacts); + + Workspace workspace = getWorkspace(); + + WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); + + NotificationsProducer np = getNotificationProducer(); + + np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); + +// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); + } + } + }else + workspaceLogger.error("verifyNotifyAddItemToShare folder destination item is null"); + + } + +// private void checkNotifyAddItemToShare(final String itemId, final String destinationId) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{ +// +// new Thread(){ +// @Override +// public void run() { +// +// try{ +// +// Workspace workspace = getWorkspace(); +// GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); +// logger.trace("moveItem item: "+itemId+" destination: "+destinationId); +// +// WorkspaceItem sourceItem = workspace.getItem(itemId); +// +// if(sourceItem==null) +// return; +// +// String sourceSharedId = null; +// boolean sourceItemIsShared = sourceItem.isShared(); +// +// if(sourceItemIsShared) +// sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE +// +// +// System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId); +// +// +// WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination +// +// if(folderDestinationItem!=null){ +// +// //if folder destination is shared folder +// if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? +// +// //share condition is true if source shared folder is null or not equal to destination shared folder +// boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0); +// +// System.out.println("shareChangeCondition add item: "+ shareChangeCondition); +// +// //if shareChangeCondition is true.. notifies added item to sharing +// if(shareChangeCondition){ +// +// List listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder()); +// +// //DEBUG +// printContacts(listContacts); +// +// WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); +// +// NotificationsProducer np = getNotificationProducer(); +// +// np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); +// +//// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); +// } +// } +// }else +// workspaceLogger.error("verifyNotifyAddItemToShare folder destination item is null"); +// +// +// }catch (Exception e) { +// // TODO: handle exception +// } +// +// +// } +// }.start(); +// +// } + + + private void checkNotifyRemoveItemToShare(boolean sourceItemIsShared, WorkspaceItem sourceItem, String sourceSharedId, WorkspaceItem folderDestinationItem) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{ + + if(folderDestinationItem!=null){ + + String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():""; + + //share condition is true if source shared folder is not equal to destination shared folder + boolean shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0); + + System.out.println("shareChangeCondition remove item: "+ shareChangeCondition); + + //Notify Removed Item To Sharing? + //if source Item is shared and folder destination is not shared or shareChangeCondition is true.. notifies removed item to sharing + if(sourceItemIsShared && (!folderDestinationItem.isShared() || shareChangeCondition)){ + + //get contacts + List listContacts = getListUserSharedByFolderSharedId(sourceSharedId); + + //DEBUG + printContacts(listContacts); + + Workspace workspace = getWorkspace(); + + WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId); + + System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName()); + + NotificationsProducer np = getNotificationProducer(); + + np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder); + + } + + + }else + workspaceLogger.error("verifyNotifyRemoveItemToShare folder destination item is null"); + + } + + //DEBUG + private void printContacts(List listContacts){ + + System.out.println("PRINT CONTACTS: "); + for (InfoContactModel infoContactModel : listContacts) { + System.out.println("User: "+infoContactModel); + } + } @Override public Boolean removeItem(String itemId) throws Exception { - workspaceLogger.info("removeItem itemId: "+itemId); + workspaceLogger.trace("removeItem itemId: "+itemId); try { Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("removeItem item: "+itemId); + logger.trace("removeItem item: "+itemId); workspace.removeItem(itemId); return Boolean.TRUE; @@ -327,14 +567,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public Boolean renameItem(String itemId, String newName) throws Exception { - workspaceLogger.info("renameItem itemId: "+itemId+" newName: "+newName); + workspaceLogger.trace("renameItem itemId: "+itemId+" newName: "+newName); try { Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("renameItem itemId: "+itemId+" newName: "+newName); + logger.trace("renameItem itemId: "+itemId+" newName: "+newName); workspace.renameItem(itemId, newName); return true; @@ -349,15 +589,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public FolderModel createFolder(String nameFolder, String description, FileModel parent) throws Exception { - workspaceLogger.info("create folder"); + workspaceLogger.trace("create folder"); try { Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("create folder: " + nameFolder); + logger.trace("create folder: " + nameFolder); WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parent.getIdentifier()); + + + WorkspaceItem folderDestinationItem = workspace.getItem(parent.getIdentifier()); + + checkNotifyAddItemToShare(wsFolder, null, folderDestinationItem); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); @@ -375,13 +620,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT @Override public FileDetailsModel getDetailsFile(FileModel folder) throws Exception { - workspaceLogger.info("load file details"); + workspaceLogger.trace("load file details"); try { Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("load file details: " + folder.getName()); + logger.trace("load file details: " + folder.getName()); WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier()); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); @@ -407,7 +652,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("search itemId: "+itemIdentifier); + logger.trace("search itemId: "+itemIdentifier); WorkspaceItem item = workspace.getItem(itemIdentifier); //get item from workspace getListsChildrenByParents(listSubTree, item); @@ -431,7 +676,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get smart folder by category: "+category); + logger.trace("get smart folder by category: "+category); // listWorkspaceItems = workspace.getWorkspaceTree(workspace.getRoot()); //get item from workspace @@ -526,7 +771,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("create smart folder by name: "+name); + logger.trace("create smart folder by name: "+name); workspaceLogger.trace("name " + name); workspaceLogger.trace("query " + query); @@ -565,7 +810,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("remove smart folder by id: "+itemId); + logger.trace("remove smart folder by id: "+itemId); workspace.removeItem(itemId); //remove Smart Folder from workspace @@ -587,7 +832,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get all smart folder"); + logger.trace("get all smart folder"); // workspaceLogger.trace("get all smart folder"); // List listWorkspaceFolder = new ArrayList(); @@ -619,7 +864,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get smart folder by id: "+folderId); + logger.trace("get smart folder by id: "+folderId); // WorkspaceFolder wsFolder = workspace.getSmartFolder(folderId); //get Smart Folder from workspace @@ -649,7 +894,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get image by id: "+identifier); + logger.trace("get image by id: "+identifier); WorkspaceItem item = workspace.getItem(identifier); //get item from workspace @@ -678,7 +923,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get timeseries by id: "+identifier); + logger.trace("get timeseries by id: "+identifier); WorkspaceItem item = workspace.getItem(identifier); //get item from workspace @@ -702,7 +947,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("get url by id: "+identifier); + logger.trace("get url by id: "+identifier); WorkspaceItem item = workspace.getItem(identifier); //get item from workspace @@ -729,7 +974,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Workspace workspace = getWorkspace(); GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); - logger.info("create url in parent id: "+parentFileModel.getIdentifier()); + logger.trace("create url in parent id: "+parentFileModel.getIdentifier()); //DEBUG // workspaceLogger.trace("Name " + name); @@ -844,10 +1089,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS"); List listContactsModel = new ArrayList(); // //TEST USERS - listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri")); - listContactsModel.add(new InfoContactModel("Antonio.Test", "Antonio.Test", "Antonio Gioia")); - listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi")); + listContactsModel.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri")); + listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia")); + listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi")); + listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano")); listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER)); + listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa")); listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante")); return listContactsModel; @@ -1263,11 +1510,18 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { Workspace workspace = getWorkspace(); - + + WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE COPY + String sourceSharedId = sourceItem.getIdSharedFolder(); + GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); logger.info("copyItem by id: " + itemId); - WorkspaceItem item = workspace.copy(itemId, destinationFolderId); + WorkspaceItem item = workspace.copy(itemId, destinationFolderId); //copy item + + WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId); + + checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem); if(item!=null) return true; @@ -1355,6 +1609,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT WorkspaceSharedFolder sharedFolder = null; + List listSharedContact = null; + + boolean sourceFolderIsShared = folder.isShared(); + + if(sourceFolderIsShared){ //if source folder is already share... retrieve old list of sharing to notify + listSharedContact = getListUserSharedByFolderSharedId(folder.getIdentifier()); + } + if(listLogin.size()>0){ if(!isNewFolder) @@ -1368,7 +1630,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(created){ NotificationsProducer np = getNotificationProducer(); - np.notifyFolderSharing(listContacts, sharedFolder); + if(!sourceFolderIsShared) //if source folder is not already shared + np.notifyFolderSharing(listContacts, sharedFolder); + else + np.notifyAddedUserToSharing(listSharedContact, listContacts, sharedFolder); } return created; @@ -1391,7 +1656,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Error in shareFolder ", e); e.printStackTrace(); - String error = ConstantsExplorer.SERVER_ERROR+" creating shared folder. "+ e.getMessage(); + String error = ConstantsExplorer.SERVER_ERROR+" creating shared folder."; throw new Exception(error); } } @@ -1420,6 +1685,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } else{ workspaceLogger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER); + + //DEBUG System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER); } return new ArrayList(); @@ -1454,14 +1721,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(unShared){ NotificationsProducer np = getNotificationProducer(); List contacts = getListUserSharedByFolderSharedId(folderSharedId); + +// if(isTestMode()){ +// contacts = new ArrayList(); +// contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa")); +// } + printContacts(contacts); - if(isTestMode()){ - contacts = new ArrayList(); - contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa")); - } - - np.notifyFolderUnSharing(contacts, wsFolder); + np.notifyFolderUnSharing(contacts, unSharedFolder); } } @@ -1475,7 +1743,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e); - String error = ConstantsExplorer.SERVER_ERROR+" un share folder. "+ e.getMessage() +". " +ConstantsExplorer.TRY_AGAIN; + String error = ConstantsExplorer.SERVER_ERROR+" un share folder. Refresh folder and " +ConstantsExplorer.TRY_AGAIN; e.printStackTrace(); throw new Exception(error); } 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 a285268..5397511 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 @@ -9,8 +9,10 @@ import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.common.core.utils.logging.GCUBEClientLog; +import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem; +import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.portlets.user.workspace.client.model.InfoContactModel; import org.gcube.portlets.user.workspace.server.util.Util; @@ -21,7 +23,7 @@ import org.gcube.portlets.user.workspace.server.util.Util; */ public class NotificationsProducer { - protected GCUBEClientLog gcubeLogger = new GCUBEClientLog(NotificationsProducer.class); + protected GCUBELog gcubeLogger = new GCUBELog(NotificationsProducer.class); protected GCUBEScope scope; protected NotificationsManager notificationsMng; @@ -63,20 +65,18 @@ public class NotificationsProducer { @Override public void run() { - gcubeLogger.trace("Send notify folder sharing is running..."); + gcubeLogger.trace("Send notifies 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 - - gcubeLogger.trace("Send notify folder sharing for user "+infoContactModel.getId()); - + if(infoContactModel.getId().compareTo(userId)!=0){ + gcubeLogger.trace("Send notifies new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + //DEBUG - System.out.println("Send notify folder sharing for user "+infoContactModel.getId()); - - + System.out.println("Send notifies new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getId(), sharedFolder); if(!notify) @@ -88,19 +88,76 @@ public class NotificationsProducer { } } - gcubeLogger.trace("share notifications is completed"); + gcubeLogger.trace("notifies share folder is completed"); } }.start(); } + + /** + * Runs a new thread to notify the new contacts passed in input + * @param listSharedContact - list of contacts already shared + * @param listSharingContact - list of "new" contacts witch share + * @param sharedFolder - the shared folder + */ + public void notifyAddedUserToSharing(final List listSharedContact, final List listSharingContact, final WorkspaceSharedFolder sharedFolder) { + + new Thread() { + @Override + public void run() { + + try{ + + if(listSharedContact==null) + return; + + for (InfoContactModel infoContactModel : listSharingContact) { + + if(!listSharedContact.contains(infoContactModel)){ //if is new contact.. notifies share + + //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER + if(infoContactModel.getId().compareTo(userId)!=0){ + + for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS + + try{ + + gcubeLogger.trace("Send notifies added user "+ infoContactModel.getId() +" to share folder "+sharedFolder.getName() + " for user "+contact.getId()); + + //DEBUG + System.out.println("Send notifies added user "+ infoContactModel.getId() +" to share folder "+sharedFolder.getName() + " for user "+contact.getId()); + + boolean notify = notificationsMng.notifyFolderAddedUser(contact.getId(), sharedFolder, infoContactModel.getId()); + + if(!notify) + gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getId()); + + }catch (Exception e) { + gcubeLogger.error("An error occured in notifyFolderAddedUser ", e); + e.printStackTrace(); + } + } + } + } + } + }catch (Exception e) { + gcubeLogger.error("An error occured in notifyAddedUserToSharing ", e); + e.printStackTrace(); + } + } + + }.start(); + + } + /** * Runs a new thread to notify the contacts passed in input * @param listContacts - * @param sharedFolder + * @param unSharedFolder */ - public void notifyFolderUnSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + public void notifyFolderUnSharing(final List listContacts, final WorkspaceFolder unSharedFolder) { new Thread() { @@ -108,34 +165,35 @@ public class NotificationsProducer { public void run() { // printContacts(listContacts); - gcubeLogger.trace("Send notify folder un share is running..."); + gcubeLogger.trace("Send notifies 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){ - gcubeLogger.trace("Send notify folder un share user "+infoContactModel.getId()); + gcubeLogger.trace("User id: " +userId + " send notifies un shared folder "+unSharedFolder.getName()+" for user "+infoContactModel.getId()); //DEBUG -// System.out.println("Send notify folder un share user "+infoContactModel.getId()); + System.out.println("User id: " +userId + " send notifies un shared folder "+unSharedFolder.getName()+" for user "+infoContactModel.getId()); - boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), sharedFolder, userId); + boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getId(), unSharedFolder); if(!notify) - gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); + gcubeLogger.error("An error occured when notifies user: "+infoContactModel.getId()); } }catch (Exception e) { - gcubeLogger.error("An error occured in notifyFolderSharing ", e); + gcubeLogger.error("An error occured in notifyFolderUnSharing ", e); e.printStackTrace(); } } - gcubeLogger.trace("notify of un share notifications is completed"); + gcubeLogger.trace("notifies of un share notifications is completed"); } }.start(); + } @@ -143,33 +201,42 @@ public class NotificationsProducer { /** * Runs a new thread to notify the contacts passed in input * @param listContacts - * @param sharedFolder + * @param workspaceItem */ - public void notifyAddedItemToSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + public void notifyAddedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { - new Thread() { @Override public void run() { // printContacts(listContacts); - gcubeLogger.trace("Send notify added item in sharedfolder is running..."); + gcubeLogger.trace("Send notifies added item in sharedfolder is running..."); + + //DEBUG + System.out.println("Send notifies 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 + if(infoContactModel.getId().compareTo(userId)!=0){ - gcubeLogger.trace("Send notify added item in sharedfolder + "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + gcubeLogger.trace("Send notifies added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + //DEBUG + System.out.println("Send notifies added item "+workspaceItem.getName()+" in shared folder "+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); + boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getId(), workspaceItem, sharedFolder); - if(!notify) + + if(!notify){ gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); + //DEBUG + System.out.println("An error occured when notify user: "+infoContactModel.getId()); + } } }catch (Exception e) { gcubeLogger.error("An error occured in notifyAddedItemToSharing ", e); @@ -177,7 +244,10 @@ public class NotificationsProducer { } } - gcubeLogger.trace("notigy of added item in shared folder is completed"); + gcubeLogger.trace("notifies of added item in shared folder is completed"); + + //DEBUG + System.out.println("notifies of added item in shared folder is completed"); } }.start(); @@ -185,12 +255,15 @@ public class NotificationsProducer { + + + /** * Runs a new thread to notify the contacts passed in input * @param listContacts * @param sharedFolder */ - public void notifyRemovedItemToSharing(final List listContacts, final WorkspaceFolder sharedFolder) { + public void notifyRemovedItemToSharing(final List listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { new Thread() { @@ -198,23 +271,29 @@ public class NotificationsProducer { public void run() { // printContacts(listContacts); - gcubeLogger.trace("Send notify remove item in sharedfolder is running..."); + gcubeLogger.trace("Send notifies remove item in shared folder is running..."); + + System.out.println("Send notifies remove item in shared folder 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){ - gcubeLogger.trace("Send notify remove item in sharedfolder + "+sharedFolder.getName()+" for user "+infoContactModel.getId()); - + gcubeLogger.trace("Send notifies remove item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + //DEBUG -// System.out.println("Send notify folder un share user "+infoContactModel.getId()); + System.out.println("Send notifies remove item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()+" for user "+infoContactModel.getId()); + + boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getId(), workspaceItem, sharedFolder); - boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getId(), sharedFolder); - - if(!notify) + if(!notify){ gcubeLogger.error("An error occured when notify user: "+infoContactModel.getId()); + + //DEBUG + System.out.println("An error occured when notify user: "+infoContactModel.getId()); + } } }catch (Exception e) { gcubeLogger.error("An error occured in notifyRemovedItemToSharing ", e); @@ -222,10 +301,14 @@ public class NotificationsProducer { } } - gcubeLogger.trace("notify of removed item in shared folder is completed"); + gcubeLogger.trace("notifies of removed item in shared folder is completed"); + + //DEBUG + System.out.println("notifies of removed item in shared folder is completed"); } }.start(); + } //DEBUG diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java index 5b621fb..0398d17 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/Util.java @@ -45,9 +45,9 @@ public class Util { // public static final String TEST_USER = "federico.defaveri"; // public static final String TEST_USER = "massimiliano.assante"; // public static final String TEST_USER = "pasquale.pagano"; - public static final String TEST_USER = "francesco.mangiacrapa"; +// public static final String TEST_USER = "francesco.mangiacrapa"; // public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa"; -// public static final String TEST_USER = "test.user"; + public static final String TEST_USER = "test.user"; public static final String TEST_USER_FULL_NAME = "Test User"; public static GCUBEClientLog defaultLogger = new GCUBEClientLog("WorkspacePortlet"); @@ -70,6 +70,7 @@ public class Util { session.setScope(TEST_SCOPE); session.setUserAvatarId(TEST_USER + "Avatar"); session.setUserFullName(TEST_USER_FULL_NAME); + session.setUserEmailAddress("test.user@mail.test"); } withoutPortal = true;