ref 13226:StorageHub - Update workspace-sharing-widget to SH
https://support.d4science.org/issues/13226 Added notifications in case of share and unshare git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@179180 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9515eb1331
commit
9904999212
|
@ -12,7 +12,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
||||
|
@ -111,7 +110,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
return listContactsModel;
|
||||
}
|
||||
|
||||
|
||||
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||
|
||||
|
@ -448,11 +446,38 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("Folder is shared");
|
||||
if (folderItem instanceof SharedFolder) {
|
||||
logger.debug("Folder type: SharedFolder");
|
||||
SharedFolder sharedFolder = (SharedFolder) folderItem;
|
||||
Set<String> logins = new HashSet<>(listLogin);
|
||||
String currentUser = getMyLogin();
|
||||
|
||||
logger.debug("Current User: " + currentUser);
|
||||
if (logins.contains(currentUser)) {
|
||||
logins.remove(currentUser);
|
||||
}
|
||||
Metadata usersMetadata = sharedFolder.getUsers();
|
||||
if (usersMetadata != null) {
|
||||
Map<String, Object> usersMap = usersMetadata.getMap();
|
||||
if (usersMap != null) {
|
||||
Set<String> alreadySharedUsers = usersMap.keySet();
|
||||
logger.debug("Already shared logins: " + alreadySharedUsers);
|
||||
if (alreadySharedUsers.contains(currentUser)) {
|
||||
alreadySharedUsers.remove(currentUser);
|
||||
}
|
||||
logger.debug("Unshare the logins: " + alreadySharedUsers);
|
||||
if (!alreadySharedUsers.isEmpty()) {
|
||||
folderContainer.unshare(alreadySharedUsers);
|
||||
logger.debug("Unshare done");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Share logins: " + logins);
|
||||
folderContainer.share(logins, getAccessType(acl));
|
||||
logger.debug("Shared done");
|
||||
created = true;
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
np.notifyFolderSharing(listContacts, folderItem);
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
np.notifyFolderSharing(listContacts, folderItem);
|
||||
} else {
|
||||
logger.debug("The folder is already shared");
|
||||
throw new Exception("The folder selected is already shared!");
|
||||
|
@ -460,11 +485,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
} else {
|
||||
logger.debug("Folder is not shared");
|
||||
Set<String> logins = new HashSet<>(listLogin);
|
||||
logger.debug("Share logins: " + logins);
|
||||
folderContainer.share(logins, getAccessType(acl));
|
||||
logger.debug("Shared done");
|
||||
created = true;
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
np.notifyFolderSharing(listContacts, folderItem);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
logger.error("Invalid folder retrieved: [id=" + itemId + "]");
|
||||
|
@ -476,7 +503,6 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
return created;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -876,14 +902,14 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
SharedFolder sharedFolder = (SharedFolder) folderItem;
|
||||
folderContainer.unshare(sharedFolder.getUsers().getMap().keySet());
|
||||
unshared = true;
|
||||
ArrayList<InfoContactModel> listContacts=new ArrayList<>();
|
||||
for(String key:sharedFolder.getUsers().getMap().keySet()){
|
||||
InfoContactModel contact=new InfoContactModel(key,key, key, false);
|
||||
ArrayList<InfoContactModel> listContacts = new ArrayList<>();
|
||||
for (String key : sharedFolder.getUsers().getMap().keySet()) {
|
||||
InfoContactModel contact = new InfoContactModel(key, key, key, false);
|
||||
listContacts.add(contact);
|
||||
}
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
np.notifyFolderUnSharing(listContacts, folderItem);
|
||||
|
||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||
np.notifyFolderUnSharing(listContacts, folderItem);
|
||||
|
||||
} else {
|
||||
String msg = "The folder requested is not a root shared folder."
|
||||
+ "To unshare this folder you have to unshare the root shared folder!";
|
||||
|
|
Loading…
Reference in New Issue