Added notification Folder Unshare

Added Session Checker

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@100262 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-09-29 16:11:33 +00:00
parent 44c32e14f4
commit f0e6b002f8
3 changed files with 26 additions and 30 deletions

View File

@ -2151,6 +2151,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new SessionExpiredException();
workspaceLogger.trace("unSharedFolderByFolderSharedId "+ folderSharedId);
try {
Workspace workspace = getWorkspace();
@ -2162,39 +2163,35 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
// WorkspaceFolder unSharedFolder = wsFolder.unShare();
// unShared = unSharedFolder==null?false:true;
//TEMPORARY SOLUTION
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
String sharedFolderName = wsFolder.getName();
//RETURN A NEW FOLDER
wsFolder.unShare();
workspaceLogger.trace("no error incoming on unsharing");
unShared = true;
// System.out.println("unShared is "+unShared);
// if(newFolder!=null)
// unShared = true;
workspaceLogger.trace("unShared is "+ unShared);
/* INTERNAL POLICY, UN SHARE NOT SHOULD PRODUCE NOTIFICATIONS
if(unShared){
NotificationsProducer np = getNotificationProducer();
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
// if(isTestMode()){
// contacts = new ArrayList<InfoContactModel>();
// contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
// }
workspaceLogger.trace("UNSHARE WITH: ");
printContacts(contacts);
np.notifyFolderUnSharing(contacts, unSharedFolder);
NotificationsProducer np = getNotificationProducer();
List<InfoContactModel> purgeMyContact = new ArrayList<InfoContactModel>(contacts.size()-1);
String myLogin = getMyLogin();
workspaceLogger.trace("Preparing list of contacts to send un share notification");
for (InfoContactModel infoContactModel : contacts) {
if(infoContactModel.getLogin().compareToIgnoreCase(getMyLogin())==0)
workspaceLogger.trace("skipping my login "+myLogin);
else
purgeMyContact.add(infoContactModel);
}
workspaceLogger.trace("UNSHARE WITH: ");
printContacts(purgeMyContact);
*/
np.notifyFolderUnSharing(purgeMyContact, folderSharedId, sharedFolderName);
}
else
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
workspaceLogger.info("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
} catch (InternalErrorException e) {
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);

View File

@ -299,7 +299,7 @@ public class NotificationsProducer {
* @param listContacts
* @param unSharedFolder
*/
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder unSharedFolder) {
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final String unShareFolderId, final String unSharedFolderName) {
new Thread() {
@ -315,12 +315,13 @@ public class NotificationsProducer {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" unshare folder "+unSharedFolderName);
//DEBUG
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder);
// boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder);
boolean notify = notificationsMng.notifyFolderUnsharing(infoContactModel.getLogin(), unShareFolderId, unSharedFolderName);
if(!notify)
logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
}

View File

@ -163,8 +163,6 @@ public class UriResolverReaderRR {
public static String getPublicLinkForFolderItemId(String itemId){
try{
ScopeProvider.instance.set(DEFAULT_SCOPE);