diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a1f7af7 --- /dev/null +++ b/CHANGELOG.md @@ -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). diff --git a/FUNDING.md b/FUNDING.md new file mode 100644 index 0000000..6fa9eac --- /dev/null +++ b/FUNDING.md @@ -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); \ No newline at end of file diff --git a/README.md b/README.md index 5568cb2..acb3f85 100644 --- a/README.md +++ b/README.md @@ -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); - \ No newline at end of file +The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md) diff --git a/changelog.xml b/changelog.xml index e28d753..d2ba949 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,4 +1,8 @@ + + Updated the set administrator method for VRE folders [ticket: #19952] + Updated to Git and Jenkins diff --git a/pom.xml b/pom.xml index f7f6b03..590b69c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.widgets workspace-sharing-widget jar - 1.10.1-SNAPSHOT + 1.11.0-SNAPSHOT gCube Workspace Sharing Widget Workspace Sharing Widget is a widget that allows the sharing of items present in the D4Science Workspace. diff --git a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java index cbc98a3..dfb6396 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/server/WorkspaceSharingServiceImpl.java @@ -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 alreadyAdministrators = new HashSet<>(); - - List 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 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 aclUpdateUsers = new HashSet<>(listContactLogins); - aclUpdateUsers.removeAll(shareUsers); - for (String user : aclUpdateUsers) { - if (currentUser.compareTo(user) != 0) { - folderContainer = folderContainer.changeAcls(user, AccessType.ADMINISTRATOR); - } - } + addAministratorsToShareFolder(listContactLogins, folderContainer, currentUser); } - - - - 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"); - } - } - logger.debug("Administrators Updated"); return true; @@ -907,6 +852,117 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements } + private void addAministratorsToVREFolder(List listContactLogins, VREFolderManager vreFolderManager, + FolderContainer folderContainer, String currentUser) throws Exception, StorageHubException { + + // Already Aministrators + List alreadyAdministrators = vreFolderManager.getAdmins(); + + logger.debug("VREfolder add new Administrators"); + HashSet 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 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 listContactLogins, FolderContainer folderContainer, + String currentUser) throws Exception, StorageHubException { + Set alreadyAdministrators = new HashSet<>(); + + List 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 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 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 retrieveAdminContactsFromACLs(FolderContainer folderContainer) throws Exception { if (folderContainer == null) { logger.debug("FolderContainer is null"); @@ -1260,7 +1316,13 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements List acls = retrieveUserACLsFromFolderContainer(rootSharedFolderContainer); List listEACL = new ArrayList(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(),