Fixed Get Info for shared Folder
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@179398 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
67314d7859
commit
0531be2c31
|
@ -972,16 +972,68 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
if (folderItem instanceof SharedFolder) {
|
if (folderItem instanceof SharedFolder) {
|
||||||
logger.debug("Folder type: SharedFolder");
|
logger.debug("Folder type: SharedFolder");
|
||||||
SharedFolder sharedFolder = (SharedFolder) folderItem;
|
SharedFolder sharedFolder = (SharedFolder) folderItem;
|
||||||
folderContainer.unshare(sharedFolder.getUsers().getMap().keySet());
|
List<ACL> listACL = folderContainer.getAcls();
|
||||||
unshared = true;
|
logger.debug("List of ACL: " + listACL);
|
||||||
|
String currentUser = getMyLogin();
|
||||||
|
logger.debug("Current User: " + currentUser);
|
||||||
|
if (listACL != null) {
|
||||||
|
ACL userACL = null;
|
||||||
|
for (ACL acl : listACL) {
|
||||||
|
if (currentUser.compareTo(acl.getPricipal()) == 0) {
|
||||||
|
userACL = acl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userACL != null) {
|
||||||
|
List<AccessType> listOfAccessType = userACL.getAccessTypes();
|
||||||
|
if (listOfAccessType != null && !listOfAccessType.isEmpty()) {
|
||||||
|
boolean isAdmin = false;
|
||||||
|
for (AccessType accessType : listOfAccessType) {
|
||||||
|
if (accessType.compareTo(AccessType.ADMINISTRATOR) == 0) {
|
||||||
|
isAdmin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> users;
|
||||||
|
if (isAdmin) {
|
||||||
|
users = sharedFolder.getUsers().getMap().keySet();
|
||||||
|
folderContainer.unshare(users);
|
||||||
|
logger.info("Unshared folded for users: " + users);
|
||||||
ArrayList<InfoContactModel> listContacts = new ArrayList<>();
|
ArrayList<InfoContactModel> listContacts = new ArrayList<>();
|
||||||
for (String key : sharedFolder.getUsers().getMap().keySet()) {
|
for (String key : users) {
|
||||||
InfoContactModel contact = new InfoContactModel(key, key, key, false);
|
InfoContactModel contact = new InfoContactModel(key, key, key, false);
|
||||||
listContacts.add(contact);
|
listContacts.add(contact);
|
||||||
}
|
}
|
||||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
NotificationsProducer np = getNotificationProducer(
|
||||||
|
this.getThreadLocalRequest());
|
||||||
np.notifyFolderUnSharing(listContacts, folderItem);
|
np.notifyFolderUnSharing(listContacts, folderItem);
|
||||||
|
} else {
|
||||||
|
users = new HashSet<String>();
|
||||||
|
users.add(currentUser);
|
||||||
|
folderContainer.unshare(users);
|
||||||
|
logger.info("Unshared folded for users: " + users);
|
||||||
|
|
||||||
|
}
|
||||||
|
unshared = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String msg = "Invalid AccessType permission on this folder for the user.";
|
||||||
|
logger.error(msg);
|
||||||
|
throw new Exception(msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "Invalid permission on this folder for the user.";
|
||||||
|
logger.error(msg);
|
||||||
|
throw new Exception(msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "Invalid ACL list for this forlder: null.";
|
||||||
|
logger.error(msg);
|
||||||
|
throw new Exception(msg);
|
||||||
|
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String msg = "The folder requested is not a root shared folder."
|
String msg = "The folder requested is not a root shared folder."
|
||||||
+ "To unshare this folder you have to unshare the root shared folder!";
|
+ "To unshare this folder you have to unshare the root shared folder!";
|
||||||
|
|
Loading…
Reference in New Issue