ref 19952: Workspace - server error in update VRE Administrators

Updated the set administrator method for VRE folders
master
Giancarlo Panichi 4 years ago
parent 4e3b4238ab
commit b8022f614a

@ -0,0 +1,142 @@
# Changelog
## [v1.11.0-SNAPSHOT] - 2020-10-13
### Features
- Updated the set administrator method for VRE folders [#19952]
## [v1.10.1] - 2019-12-19
### Features
- Updated to Git and Jenkins
## [v1.10.0] - 2019-07-30
### Features
- Added support for users in different Gateway [#17080]
- Updated the list of shared classes with the tree widget
## [v1.9.0] - 2019-06-05
### Features
- Updated to StorageHub [#13226]
## [v1.8.2] - 2017-02-24
### Features
- Stylesheet fix [#3236]
## [v1.8.1] - 2016-11-25
### Features
- Removed ASL Session dependency
## [v1.7.0] - 2016-05-31
### Features
- Migration to Liferay 6.2 [#4128]
## [v1.6.0] - 2016-04-14
### Features
- Enhancement in order to display short VREs name [#3277]
## [v1.5.1] - 2016-01-04
### Features
- Removed portal-framework dependecy from Etics
## [v1.5.0] - 2015-09-28
### Features
- Added code to retrieve (only) the users belonging to the organization read from (asl) session group [#401]
## [v1.4.0] - 2015-06-04
### Features
- Porting to HL 2.0 [#211]
## [v1.3.0] - 2015-04-15
### Features
- Added Edit Permission for Contacts
## [v1.2.0] - 2014-24-01
### Features
- Added method get administrator by folder id
- Added class SimpleMultiDragWorkspaceContact to realize "Edit Administrators"
## [v1.1.0] - 2014-06-27
### Features
- Integrated sharing to groups [#2897]
- Sharing Panel usability improved [#2798]
## [v1.0.2] - 2014-06-04
### Features
- Updated pom to support new portal configuration
## [v1.0.1] - 2014-04-03
### Features
- Commented the methods of Notification Producer
## [v1.0.0] - 2014-04-03
### Features
- First release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

@ -23,6 +23,7 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/workspace-sharing-wid
* **Francesco Managiacrapa** ([ORCID](https://orcid.org/0000-0002-6528-664X)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
## License
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
@ -34,12 +35,4 @@ open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- DILIGENT (grant no. 004260);
- the Seventh Framework Programme for research, technological development and demonstration
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
- the H2020 research and innovation programme
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-11-0"
date="2020-10-13">
<change>Updated the set administrator method for VRE folders [ticket: #19952]</change>
</Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-10-1"
date="2019-12-19">
<change>Updated to Git and Jenkins</change>

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-sharing-widget</artifactId>
<packaging>jar</packaging>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0-SNAPSHOT</version>
<name>gCube Workspace Sharing Widget</name>
<description>
Workspace Sharing Widget is a widget that allows the sharing of items present in the D4Science Workspace.

@ -18,6 +18,7 @@ import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.OpenResolver;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.client.dsl.VREFolderManager;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.acls.AccessType;
@ -821,69 +822,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
String currentUser = getMyLogin();
logger.debug("Current User: " + currentUser);
Set<String> alreadyAdministrators = new HashSet<>();
List<ACL> acls = folderContainer.getAcls();
for (ACL acl : acls) {
if (acl.getPricipal().compareTo(currentUser) != 0) {
for (AccessType accessType : acl.getAccessTypes()) {
if (AccessType.ADMINISTRATOR.compareTo(accessType) == 0) {
alreadyAdministrators.add(acl.getPricipal());
}
}
}
}
logger.debug("Share with new Administrators");
HashSet<String> shareUsers = new HashSet<>();
boolean alreadyShared;
for (String user : listContactLogins) {
if (currentUser.compareTo(user) != 0) {
alreadyShared = false;
for (ACL acl : acls) {
if (user.compareTo(acl.getPricipal()) == 0) {
alreadyShared = true;
break;
}
}
if (!alreadyShared) {
shareUsers.add(user);
}
}
}
logger.debug("Update ACL for add Administrators");
if (shareUsers.isEmpty()) {
for (String user : listContactLogins) {
if (currentUser.compareTo(user) != 0) {
folderContainer = folderContainer.changeAcls(user, AccessType.ADMINISTRATOR);
}
}
SharedFolder sharedFolder = ((SharedFolder) folderItem);
if (sharedFolder.isVreFolder()) {
VREFolderManager vreFolderManager = shc.getVreFolderManager(folderItem.getTitle());
addAministratorsToVREFolder(listContactLogins, vreFolderManager, folderContainer, currentUser);
} else {
folderContainer = folderContainer.share(shareUsers, AccessType.ADMINISTRATOR);
HashSet<String> aclUpdateUsers = new HashSet<>(listContactLogins);
aclUpdateUsers.removeAll(shareUsers);
for (String user : aclUpdateUsers) {
if (currentUser.compareTo(user) != 0) {
folderContainer = folderContainer.changeAcls(user, AccessType.ADMINISTRATOR);
}
}
}
logger.debug("Update Administrators done");
if (!alreadyAdministrators.isEmpty()) {
alreadyAdministrators.removeAll(listContactLogins);
if (!alreadyAdministrators.isEmpty()) {
logger.debug("Update to WriteOwner the users: " + alreadyAdministrators);
for (String user : alreadyAdministrators) {
folderContainer = folderContainer.changeAcls(user, AccessType.WRITE_OWNER);
}
logger.debug("Update to WriteOwner done");
}
addAministratorsToShareFolder(listContactLogins, folderContainer, currentUser);
}
logger.debug("Administrators Updated");
return true;
@ -907,6 +852,117 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
}
private void addAministratorsToVREFolder(List<String> listContactLogins, VREFolderManager vreFolderManager,
FolderContainer folderContainer, String currentUser) throws Exception, StorageHubException {
// Already Aministrators
List<String> alreadyAdministrators = vreFolderManager.getAdmins();
logger.debug("VREfolder add new Administrators");
HashSet<String> novelAdministrators = new HashSet<>();
boolean senior;
for (String user : listContactLogins) {
if (currentUser.compareTo(user) != 0) {
senior = false;
for (String seniorAdmin : alreadyAdministrators) {
if (user.compareTo(seniorAdmin) == 0) {
senior = true;
break;
}
}
if (!senior) {
novelAdministrators.add(user);
}
}
}
if(!novelAdministrators.isEmpty()){
for(String novel:novelAdministrators){
vreFolderManager.addUser(novel);
}
}
logger.debug("VREfolder removes administrators that are no longer valid");
HashSet<String> toRemoveAdministrators = new HashSet<>();
alreadyAdministrators.removeAll(listContactLogins);
toRemoveAdministrators.addAll(alreadyAdministrators);
if(!toRemoveAdministrators.isEmpty()){
for(String toRemoveAdmin:toRemoveAdministrators){
if(currentUser.compareTo(toRemoveAdmin)!=0){
vreFolderManager.removeAdmin(toRemoveAdmin);
}
}
}
}
private void addAministratorsToShareFolder(List<String> listContactLogins, FolderContainer folderContainer,
String currentUser) throws Exception, StorageHubException {
Set<String> alreadyAdministrators = new HashSet<>();
List<ACL> acls = folderContainer.getAcls();
for (ACL acl : acls) {
if (acl.getPricipal().compareTo(currentUser) != 0) {
for (AccessType accessType : acl.getAccessTypes()) {
if (AccessType.ADMINISTRATOR.compareTo(accessType) == 0) {
alreadyAdministrators.add(acl.getPricipal());
}
}
}
}
logger.debug("Share with new Administrators");
HashSet<String> shareUsers = new HashSet<>();
boolean alreadyShared;
for (String user : listContactLogins) {
if (currentUser.compareTo(user) != 0) {
alreadyShared = false;
for (ACL acl : acls) {
if (user.compareTo(acl.getPricipal()) == 0) {
alreadyShared = true;
break;
}
}
if (!alreadyShared) {
shareUsers.add(user);
}
}
}
logger.debug("Update ACL for add Administrators");
if (shareUsers.isEmpty()) {
for (String user : listContactLogins) {
if (currentUser.compareTo(user) != 0) {
folderContainer = folderContainer.changeAcls(user, AccessType.ADMINISTRATOR);
}
}
} else {
folderContainer = folderContainer.share(shareUsers, AccessType.ADMINISTRATOR);
HashSet<String> aclUpdateUsers = new HashSet<>(listContactLogins);
aclUpdateUsers.removeAll(shareUsers);
for (String user : aclUpdateUsers) {
if (currentUser.compareTo(user) != 0) {
folderContainer = folderContainer.changeAcls(user, AccessType.ADMINISTRATOR);
}
}
}
logger.debug("Update Administrators done");
if (!alreadyAdministrators.isEmpty()) {
alreadyAdministrators.removeAll(listContactLogins);
if (!alreadyAdministrators.isEmpty()) {
logger.debug("Update to WriteOwner the users: " + alreadyAdministrators);
for (String user : alreadyAdministrators) {
folderContainer = folderContainer.changeAcls(user, AccessType.WRITE_OWNER);
}
logger.debug("Update to WriteOwner done");
}
}
}
private List<InfoContactModel> retrieveAdminContactsFromACLs(FolderContainer folderContainer) throws Exception {
if (folderContainer == null) {
logger.debug("FolderContainer is null");
@ -1260,7 +1316,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
List<WorkspaceACL> acls = retrieveUserACLsFromFolderContainer(rootSharedFolderContainer);
List<ExtendedWorkspaceACL> listEACL = new ArrayList<ExtendedWorkspaceACL>(acls.size());
for (WorkspaceACL workspaceACL : acls) {
boolean isBaseSharedFolder = false; //is false because the root shared folder is always instance of SharedFolder
boolean isBaseSharedFolder = false; // is false
// because the
// root shared
// folder is
// always
// instance of
// SharedFolder
ExtendedWorkspaceACL eac = new ExtendedWorkspaceACL(workspaceACL.getId(),
workspaceACL.getAclType(), workspaceACL.getLabel(), workspaceACL.getDefaultValue(),
workspaceACL.getUserType(), workspaceACL.getDescription(), folderItem.getOwner(),

Loading…
Cancel
Save