ref 13226:StorageHub - Update workspace-sharing-widget to SH
https://support.d4science.org/issues/13226 Fixed share folder with multiple users git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@179300 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a869b7aa14
commit
22fcb1a056
|
@ -492,7 +492,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
logger.debug("Folder is not shared");
|
logger.debug("Folder is not shared");
|
||||||
Set<String> logins = new HashSet<>(listLogin);
|
Set<String> logins = new HashSet<>(listLogin);
|
||||||
logger.debug("Share logins: " + logins);
|
logger.debug("Share logins: " + logins);
|
||||||
folderContainer=folderContainer.share(logins, getAccessType(acl));
|
folderContainer = folderContainer.share(logins, getAccessType(acl));
|
||||||
logger.debug("Shared done");
|
logger.debug("Shared done");
|
||||||
created = true;
|
created = true;
|
||||||
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
NotificationsProducer np = getNotificationProducer(this.getThreadLocalRequest());
|
||||||
|
@ -717,9 +717,15 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<InfoContactModel> retrieveAdminContactsFromACLs(FolderContainer folderContainer) throws Exception {
|
private List<InfoContactModel> retrieveAdminContactsFromACLs(FolderContainer folderContainer) throws Exception {
|
||||||
|
if (folderContainer == null) {
|
||||||
|
logger.debug("FolderContainer is null");
|
||||||
|
return new ArrayList<InfoContactModel>();
|
||||||
|
} else {
|
||||||
|
logger.debug("Retrieve Admins for: " + folderContainer.get());
|
||||||
|
List<String> admins = new ArrayList<>();
|
||||||
|
|
||||||
List<ACL> acls = folderContainer.getAcls();
|
List<ACL> acls = folderContainer.getAcls();
|
||||||
logger.debug("Retrieved acls: " + acls);
|
logger.debug("Retrieved acls: " + acls);
|
||||||
List<String> admins = new ArrayList<>();
|
|
||||||
for (ACL acl : acls) {
|
for (ACL acl : acls) {
|
||||||
boolean isAdmin = false;
|
boolean isAdmin = false;
|
||||||
for (AccessType accesstype : acl.getAccessTypes()) {
|
for (AccessType accesstype : acl.getAccessTypes()) {
|
||||||
|
@ -736,6 +742,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
||||||
return builder.buildGxtInfoContactsFromPortalLogins(admins);
|
return builder.buildGxtInfoContactsFromPortalLogins(admins);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * DEBUG.
|
// * DEBUG.
|
||||||
|
@ -1088,18 +1095,24 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
|
||||||
|
|
||||||
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(info);
|
List<InfoContactModel> listContactsModel = builder.buildGXTListContactsModelFromUserModel(info);
|
||||||
|
boolean ownerFound = false;
|
||||||
for (InfoContactModel icm : listContactsModel) {
|
for (InfoContactModel icm : listContactsModel) {
|
||||||
if (icm.getLogin().compareTo(folderItem.getOwner()) == 0) {
|
if (icm.getLogin().compareTo(folderItem.getOwner()) == 0) {
|
||||||
logger.debug("Retrieved: " + icm);
|
logger.debug("Owner Retrieved: " + icm);
|
||||||
owner = icm;
|
owner = icm;
|
||||||
|
ownerFound = true;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!ownerFound) {
|
||||||
logger.debug("Owner not found from user model!");
|
logger.debug("Owner not found from user model!");
|
||||||
owner = new InfoContactModel(folderItem.getOwner(), folderItem.getOwner(), folderItem.getOwner(),
|
owner = new InfoContactModel(folderItem.getOwner(), folderItem.getOwner(),
|
||||||
false);
|
folderItem.getOwner(), false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Owner not found from item");
|
logger.debug("Owner not found from item");
|
||||||
owner = new InfoContactModel();
|
owner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String username = info.getUsername();
|
String username = info.getUsername();
|
||||||
|
@ -1108,22 +1121,20 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
return new AllowAccess(itemId, true, "The folder is already public. Access granted to " + username,
|
return new AllowAccess(itemId, true, "The folder is already public. Access granted to " + username,
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
logger.info("owner of: " + folderItem.getName() + " is: " + owner);
|
logger.info("The owner of: " + folderItem.getName() + " is: " + owner);
|
||||||
logger.info("current context user: " + username);
|
logger.info("The current context user: " + username);
|
||||||
if (owner.getLogin().compareToIgnoreCase(username) == 0) {
|
if (owner != null && owner.getLogin().compareToIgnoreCase(username) == 0) {
|
||||||
logger.info("Access to Folder Link " + folderItem.getName() + " granted, " + username
|
logger.info("Access to Folder Link " + folderItem.getName() + " granted, " + username
|
||||||
+ " is the owner of: " + itemId);
|
+ " is the owner of: " + itemId);
|
||||||
return new AllowAccess(itemId, true,
|
return new AllowAccess(itemId, true,
|
||||||
info.getUserFullName() + " is the owner of: " + folderItem.getName(), null);
|
info.getUserFullName() + " is the owner of: " + folderItem.getName(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<InfoContactModel> admins = null;
|
List<InfoContactModel> admins = null;
|
||||||
|
|
||||||
if (folderItem.isShared()) {
|
if (folderItem.isShared()) {
|
||||||
if (folderItem instanceof SharedFolder) {
|
if (folderItem instanceof SharedFolder) {
|
||||||
admins = retrieveAdminContactsFromACLs(folderContainer);
|
admins = retrieveAdminContactsFromACLs(folderContainer);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FolderContainer rootSharedFolderContainer = folderContainer.getRootSharedFolder();
|
FolderContainer rootSharedFolderContainer = folderContainer.getRootSharedFolder();
|
||||||
FolderItem rootSharedFolder = rootSharedFolderContainer.get();
|
FolderItem rootSharedFolder = rootSharedFolderContainer.get();
|
||||||
|
@ -1142,6 +1153,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
"The item requested is not a valid shared folder : [itemId=" + itemId + "]");
|
"The item requested is not a valid shared folder : [itemId=" + itemId + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (admins != null) {
|
||||||
for (InfoContactModel infoContactModel : admins) {
|
for (InfoContactModel infoContactModel : admins) {
|
||||||
if (infoContactModel.getLogin().compareToIgnoreCase(username) == 0) {
|
if (infoContactModel.getLogin().compareToIgnoreCase(username) == 0) {
|
||||||
logger.info("Access to Folder Link " + logger.getName() + " granted, " + username
|
logger.info("Access to Folder Link " + logger.getName() + " granted, " + username
|
||||||
|
@ -1150,6 +1162,11 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
info.getUserFullName() + " is the admin of: " + folderItem.getName(), null);
|
info.getUserFullName() + " is the admin of: " + folderItem.getName(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return new AllowAccess(itemId, false,
|
||||||
|
"You have not permission to get Folder Link, you must be owner or administrator to the folder", "Permission not found");
|
||||||
|
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return new AllowAccess(itemId, false,
|
return new AllowAccess(itemId, false,
|
||||||
"You have not permission to get Folder Link, you must be owner or administrator to the folder",
|
"You have not permission to get Folder Link, you must be owner or administrator to the folder",
|
||||||
|
@ -1163,9 +1180,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
||||||
return new AllowAccess(itemId, false, "The item is not a folder", null);
|
return new AllowAccess(itemId, false, "The item is not a folder", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (
|
} catch (Exception e) {
|
||||||
|
|
||||||
Exception e) {
|
|
||||||
logger.error("Error in server FormattedGcubeItemProperties: " + e.getLocalizedMessage(), e);
|
logger.error("Error in server FormattedGcubeItemProperties: " + e.getLocalizedMessage(), e);
|
||||||
String error = "Error when reading access policy to Folder Link: " + itemId + ", Refresh and try again";
|
String error = "Error when reading access policy to Folder Link: " + itemId + ", Refresh and try again";
|
||||||
throw new Exception(error, e);
|
throw new Exception(error, e);
|
||||||
|
|
Loading…
Reference in New Issue