From 4665e7c14dc56a480eae44c5577b9a3473e3295a Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 17 Nov 2020 12:26:02 +0100 Subject: [PATCH] Removed Home Library dependency integated support to send events to the Orchestrator service --- CHANGELOG.md | 28 +++++++ FUNDING.md | 26 +++++++ distro/changelog.xml | 2 +- pom.xml | 2 +- .../GCubeHookSiteRoleLocalService.java | 77 ++++++++----------- .../WEB-INF/liferay-plugin-package.properties | 2 +- 6 files changed, 87 insertions(+), 50 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 FUNDING.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c510991 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,28 @@ + +# Changelog for VREFolder Liferay Hook + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [v6.7.0] - 2020-11-17 + +Ported to git + +Removed Home Library dependency, integrated support to send events to the Orchestrator service and Keycloak + +## [v6.6.0] - 2018-03-02 + +Feature #6094 User export to LDAP on create account and join/leave VRE + +## [v6.5.0] - 2017-05-23 + +Feature #8242 Enhance VRE Folder hook to also create Share LaTeX user on user add to VRE + +## [v6.4.0] - 2017-02-23 + +Feature #6680, added hook to keep in sync VRE Managers and Workspace VRE Folder Managers + +## [v6.3.0] - 2016-03-16 + +First release after switch to new liferay version (6.2.6) 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/distro/changelog.xml b/distro/changelog.xml index f7d0220..625368a 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,6 +1,6 @@ - Feature #17556, Modify liferay TomcatValve and Hook to set roles on Authorization + Feature #17556, new role assigned event intercepted to set roles on the Legacy Authorization Feature #6094 User export to LDAP on create account and join/leave VRE diff --git a/pom.xml b/pom.xml index 7e01cb7..b64aa85 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portal.plugins VREFolder-hook VREFolder-hook Hook - 6.7.0-SNAPSHOT + 6.7.0 war VREFolder-hook handles the user adding/removal from the related Home Library VRE Folder diff --git a/src/main/java/org/gcube/portal/plugins/GCubeHookSiteRoleLocalService.java b/src/main/java/org/gcube/portal/plugins/GCubeHookSiteRoleLocalService.java index 6972e3d..1b25782 100644 --- a/src/main/java/org/gcube/portal/plugins/GCubeHookSiteRoleLocalService.java +++ b/src/main/java/org/gcube/portal/plugins/GCubeHookSiteRoleLocalService.java @@ -23,15 +23,12 @@ import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.model.Role; import com.liferay.portal.model.User; import com.liferay.portal.model.UserGroupRole; import com.liferay.portal.service.RoleLocalServiceUtil; import com.liferay.portal.service.UserGroupRoleLocalService; import com.liferay.portal.service.UserGroupRoleLocalServiceWrapper; -import com.liferay.portal.service.UserLocalServiceUtil; public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrapper { /** @@ -56,63 +53,49 @@ public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrap return toReturn; } - @Override - public java.util.List addUserGroupRoles(long userId, long groupId, - long[] roleIds) throws com.liferay.portal.kernel.exception.SystemException { - List toReturn = super.addUserGroupRoles(userId, groupId, roleIds); - try { - String context = gm.getInfrastructureScope(groupId); - String username = UserLocalServiceUtil.getUser(userId).getScreenName(); - /* Check this part CAREFULLY as when the user is just created it fails*/ - String userToken = authorizationService().resolveTokenByUserAndContext(username, context); - List userRoles = getUserRoles(roleIds); - authorizationService().setTokenRoles(userToken, userRoles); - _log.debug("Check if addUserGroupRoles is done in a VRE"); - if (gm.isVRE(groupId)) { - _log.debug("addUserGroupRoles performed in a VRE, groupId=" + groupId); - boolean vreManagerRolePresent = false; - for (int i = 0; i < roleIds.length; i++) { - Role role = RoleLocalServiceUtil.getRole(roleIds[i]); - if (role.getName().compareTo(GCubeRole.VRE_MANAGER_LABEL) == 0) { - _log.info("User is being promoted (or was) as VREFolder Administrator, userId=" + userId - + " on Site groupId=" + groupId); - vreManagerRolePresent = true; - break; - } - } - setVREFolderAdministrator(userId, groupId, vreManagerRolePresent); - } else { - _log.debug("addUserGroupRoles NOT done in a VRE, groupId=" + groupId); - } - } catch (Exception e) { - e.printStackTrace(); - } - return toReturn; - } + public java.util.List addUserGroupRoles( + long userId, long groupId, long[] roleIds) + throws com.liferay.portal.kernel.exception.SystemException { + List toReturn = super.addUserGroupRoles(userId, groupId, roleIds); + try { + _log.debug("Check if addUserGroupRoles is done in a VRE"); + if (gm.isVRE(groupId)) { + _log.debug("addUserGroupRoles performed in a VRE, groupId=" + groupId); + boolean vreManagerRolePresent = false; + for (int i = 0; i < roleIds.length; i++) { + Role role = RoleLocalServiceUtil.getRole(roleIds[i]); + if (role.getName().compareTo(GCubeRole.VRE_MANAGER_LABEL) == 0) { + _log.info("User is being promoted (or was) as VREFolder Administrator, userId=" + userId + " on Site groupId="+groupId); + vreManagerRolePresent = true; + break; + } + } + setVREFolderAdministrator(userId, groupId, vreManagerRolePresent); + } else { + _log.debug("addUserGroupRoles NOT done in a VRE, groupId=" + groupId); + } + } + catch (Exception e) { + e.printStackTrace(); + } + return toReturn; + } - private List getUserRoles(long[] roleIds) throws PortalException, SystemException { - List toReturn = new ArrayList<>(); - for (int i = 0; i < roleIds.length; i++) { - Role role = RoleLocalServiceUtil.getRole(roleIds[i]); - toReturn.add(role.getName()); - } - return toReturn; - } private boolean setVREFolderAdministrator(long userId, long groupId, boolean enable) throws Exception { String context = gm.getInfrastructureScope(groupId); ScopeProvider.instance.set(context); String vreFolderTitle = Util.getVREGroupFromContext(context); _log.info("The vreFolderTitle on which the VREFolder role is being {} is {}", enable, vreFolderTitle); - _log.info("Before StorageHubClient shc = new StorageHubClient();"); + _log.debug("Before StorageHubClient shc = new StorageHubClient();"); StorageHubClient shc = new StorageHubClient(); - _log.info("Before shc.getVreFolderManager(vreFolderTitle);"); + _log.debug("Before shc.getVreFolderManager(vreFolderTitle);"); VREFolderManager vreFolderManager = shc.getVreFolderManager(vreFolderTitle); String previousToken = SecurityTokenProvider.instance.get(); //get the super user - _log.info("//get the super user"); + _log.debug("//get the super user"); String infraContext = "/" + PortalContext.getConfiguration().getInfrastructureName(); long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext); diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties index 4bdcc2a..7d26e09 100644 --- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -1,6 +1,6 @@ name=VREFolder-hook module-group-id=liferay -module-incremental-version=6 +module-incremental-version=7 tags= short-description= change-log=