added chagelog and reviewed code for Site and VRE Folder creation
This commit is contained in:
parent
9c984fea4b
commit
cb7759fc6f
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
# Changelog for VRE Deploy Portlet
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
|
||||||
|
## [v4.3.1-SNAPSHOT] - 2021-02-02
|
||||||
|
|
||||||
|
Ported to git
|
||||||
|
|
||||||
|
modified to support the new IAM Keycloak based
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.0.0] - 2008-10-21
|
||||||
|
|
||||||
|
First release, for changes between 1.0 version and 4.2 see changelog xml in distro folder.
|
|
@ -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);
|
8
pom.xml
8
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.admin</groupId>
|
<groupId>org.gcube.portlets.admin</groupId>
|
||||||
<artifactId>vre-deploy</artifactId>
|
<artifactId>vre-deploy</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>4.3.0</version>
|
<version>4.3.1-SNAPSHOT</version>
|
||||||
<name>gCube VRE Deploy Wizard Portlet</name>
|
<name>gCube VRE Deploy Wizard Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
gCube VRE Deploy Wizard Portlet.
|
gCube VRE Deploy Wizard Portlet.
|
||||||
|
@ -82,6 +82,12 @@
|
||||||
<artifactId>home-library</artifactId>
|
<artifactId>home-library</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portal</groupId>
|
||||||
|
<artifactId>oidc-library-portal</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.gcube.portal.custom.communitymanager.ThemesIdManager;
|
||||||
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
||||||
import org.gcube.portal.custom.communitymanager.impl.GCubeSiteManagerImpl;
|
import org.gcube.portal.custom.communitymanager.impl.GCubeSiteManagerImpl;
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
|
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
||||||
import org.gcube.portlets.admin.vredeployer.client.VredeployerService;
|
import org.gcube.portlets.admin.vredeployer.client.VredeployerService;
|
||||||
import org.gcube.portlets.admin.vredeployer.client.model.VREFunctionalityModel;
|
import org.gcube.portlets.admin.vredeployer.client.model.VREFunctionalityModel;
|
||||||
import org.gcube.portlets.admin.vredeployer.shared.ResourceCategory;
|
import org.gcube.portlets.admin.vredeployer.shared.ResourceCategory;
|
||||||
|
@ -79,7 +80,9 @@ import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemExcep
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
||||||
import org.gcube.vremanagement.vremodel.cl.stubs.types.FunctionalityItem;
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.FunctionalityItem;
|
||||||
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHN;
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHN;
|
||||||
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHNsPerFunctionality;
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHNsPerFunctionality;
|
||||||
|
@ -359,11 +362,11 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String func : funCategories.keySet()) {
|
for (String func : funCategories.keySet()) {
|
||||||
System.out.println("-"+func);
|
log.debug("-"+func);
|
||||||
for(ResourceCategory category : funCategories.get(func)) {
|
for(ResourceCategory category : funCategories.get(func)) {
|
||||||
System.out.println("--"+category.getName());
|
log.debug("--"+category.getName());
|
||||||
for(ResourceCategoryItem rc: category.getItems()) {
|
for(ResourceCategoryItem rc: category.getItems()) {
|
||||||
System.out.println("----"+rc.getName() + " : " + rc.isSelected());
|
log.debug("----"+rc.getName() + " : " + rc.isSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,7 +397,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
List<RunningInstanceMessage> services = toWorkWith.foundServices();
|
List<RunningInstanceMessage> services = toWorkWith.foundServices();
|
||||||
if (services != null) {
|
if (services != null) {
|
||||||
for (RunningInstanceMessage se : services) {
|
for (RunningInstanceMessage se : services) {
|
||||||
System.out.println(se.serviceName() + " - " + se.serviceClass());
|
log.debug(se.serviceName() + " - " + se.serviceClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +556,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
|
|
||||||
log.info("ADDING user designer and manager, found designer: " + designer + " found manager: "+manager);
|
log.info("ADDING user designer and manager, found designer: " + designer + " found manager: "+manager);
|
||||||
|
|
||||||
long vreCreatedId = createCommunityAndLayoutAndHLFolder(vreName, description);
|
long vreCreatedId = createCommunityAndLayoutAndVREFolder(vreName, description, designer, manager);
|
||||||
|
|
||||||
log.info("--- createCommunityAndLayout COMPLETED, vreCreatedId="+vreCreatedId);
|
log.info("--- createCommunityAndLayout COMPLETED, vreCreatedId="+vreCreatedId);
|
||||||
String vreScope = "";
|
String vreScope = "";
|
||||||
|
@ -696,29 +699,30 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
String previousToken = SecurityTokenProvider.instance.get();
|
String previousToken = SecurityTokenProvider.instance.get();
|
||||||
//get the super user
|
//get the super user
|
||||||
|
log.info("Getting super user with role {}", GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||||
|
//get the super user
|
||||||
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
||||||
// long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
long rootgroupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||||
// RoleManager rm = new LiferayRoleManager();
|
User theAdmin = LiferayUserManager.getRandomUserWithRole(rootgroupId, GatewayRolesNames.INFRASTRUCTURE_MANAGER);
|
||||||
// long roleId = rm.getRoleId(HookConstants.AUTORISED_INFRA_ROLE, rootgroupId);
|
if (theAdmin == null) {
|
||||||
// List<GCubeUser> users = uMan.listUsersByGroupAndRole(rootgroupId, roleId);
|
log.error("Cannot create VRE Folder for this new VRE, There is no user having role {} on context: " + GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||||
// if (users.isEmpty()) {
|
}
|
||||||
// _log.error("Cannot add the user as VRE Folder admin: there is no user having role {} on context: {}", HookConstants.AUTORISED_INFRA_ROLE, infraContext);
|
String adminUsername = theAdmin.getScreenName();
|
||||||
// return false;
|
log.info("Got the super user: {}",adminUsername);
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
//GCubeUser theAdmin = users.get(0);
|
|
||||||
String adminUsername = "lucio.lelii";
|
|
||||||
log.info("Got the super user: " +adminUsername);
|
|
||||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, adminUsername);
|
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, adminUsername);
|
||||||
List<String> rolesString = new ArrayList<String>();
|
List<String> rolesString = new ArrayList<String>();
|
||||||
// List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
List<GCubeRole> theAdminRoles = new LiferayRoleManager().listRolesByUserAndGroup(theAdmin.getUserId(), rootgroupId);
|
||||||
// for (GCubeRole gCubeRole : theAdminRoles) {
|
for (GCubeRole gCubeRole : theAdminRoles) {
|
||||||
// rolesString.add(gCubeRole.getRoleName());
|
rolesString.add(gCubeRole.getRoleName());
|
||||||
// }
|
}
|
||||||
rolesString.add("Infrastructure-Manager");
|
rolesString.add(GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
|
||||||
log.info("authorizationService().setTokenRoles done");
|
log.info("legacy authorizationService().setTokenRoles done");
|
||||||
authorizationService().setTokenRoles(theAdminToken, rolesString);
|
authorizationService().setTokenRoles(theAdminToken, rolesString);
|
||||||
SecurityTokenProvider.instance.set(theAdminToken);
|
SecurityTokenProvider.instance.set(theAdminToken);
|
||||||
|
|
||||||
|
OIDCUmaUtil.provideConfiguredPortalClientUMATokenInThreadLocal("/" + PortalContext.getConfiguration().getInfrastructureName());
|
||||||
|
System.out.println("\n\n***** new authorizationService PortalClient UMA-Token In ThreadLocal done **** ");
|
||||||
|
|
||||||
String newVreContext = gm.getInfrastructureScope(vreCreated.getGroupId());
|
String newVreContext = gm.getInfrastructureScope(vreCreated.getGroupId());
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
String vreFolderName = Util.getVREGroupFromContext(newVreContext);
|
String vreFolderName = Util.getVREGroupFromContext(newVreContext);
|
||||||
|
@ -791,11 +795,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
//*** Overall deploy status report part
|
//*** Overall deploy status report part
|
||||||
toReturn.setGlobalStatus(convStatus(toConvert.getStatus()));
|
toReturn.setGlobalStatus(convStatus(toConvert.getStatus()));
|
||||||
|
|
||||||
|
log.trace("***** GHNonCloudReport Not Selected ******");
|
||||||
//*** Cloud deploy report part
|
|
||||||
GHNonCloudReport cDeploy = toConvert.getCloudDeployingReport();
|
|
||||||
|
|
||||||
System.out.println("***** GHNonCloudReport Not Selected ******");
|
|
||||||
ClientCloudReport cdp = new ClientCloudReport();
|
ClientCloudReport cdp = new ClientCloudReport();
|
||||||
cdp.setStatus(DeployStatus.SKIP);
|
cdp.setStatus(DeployStatus.SKIP);
|
||||||
toReturn.setCloudReport(cdp);
|
toReturn.setCloudReport(cdp);
|
||||||
|
@ -880,7 +880,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
/**
|
/**
|
||||||
* Creates the community and its layout in Liferay
|
* Creates the community and its layout in Liferay
|
||||||
*/
|
*/
|
||||||
private long createCommunityAndLayoutAndHLFolder(String vreName, String description) {
|
private long createCommunityAndLayoutAndVREFolder(String vreName, String description, String designer, String manager) {
|
||||||
|
|
||||||
if (vreExists(vreName)) {
|
if (vreExists(vreName)) {
|
||||||
log.warn("VRE Exists already");
|
log.warn("VRE Exists already");
|
||||||
|
@ -901,11 +901,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
|
|
||||||
String desc = (session.getAttribute(DESCRIPTION) == null) ? "No Description found": session.getAttribute(DESCRIPTION).toString(); //desc
|
String desc = (session.getAttribute(DESCRIPTION) == null) ? "No Description found": session.getAttribute(DESCRIPTION).toString(); //desc
|
||||||
|
|
||||||
|
log.info("Designer assigned: " + designer);
|
||||||
String designer = (String) session.getAttribute(DESIGNER);
|
log.info("Manager assigned : " + manager);
|
||||||
log.info("Designer found Name : " + designer);
|
|
||||||
String manager = (String) session.getAttribute(MANAGER);
|
|
||||||
log.info("Manager found Name : " + manager);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -919,8 +916,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
|
|
||||||
long groupId = vreCreated.getGroupId();
|
long groupId = vreCreated.getGroupId();
|
||||||
Group lrGroup = GroupLocalServiceUtil.getGroup(groupId);
|
Group lrGroup = GroupLocalServiceUtil.getGroup(groupId);
|
||||||
GCubeUser userBean = new LiferayUserManager().getUserByUsername(session.getUsername());
|
GCubeUser currentVREManagerUserBean = new LiferayUserManager().getUserByUsername(session.getUsername());
|
||||||
User lrUser = UserLocalServiceUtil.getUser(userBean.getUserId());
|
User lrUser = UserLocalServiceUtil.getUser(currentVREManagerUserBean.getUserId());
|
||||||
|
|
||||||
SiteManagerUtil.createLayout(lrGroup, lrUser, siteLayout);
|
SiteManagerUtil.createLayout(lrGroup, lrUser, siteLayout);
|
||||||
|
|
||||||
|
@ -931,17 +928,17 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
|
|
||||||
log.info("Assigned theme with id: " + themid + " to groupid: " + groupId);
|
log.info("Assigned theme with id: " + themid + " to groupid: " + groupId);
|
||||||
|
|
||||||
//the method above create a VRE and assign the manager Role to the person that triggers the creation
|
//the method above creates a VRE and assign the manager Role to the person that triggers the creation
|
||||||
//however the VRE-Designer and the VRE-Manager persons of the VRE could be different and need to be created too
|
//however the VRE-Designer and the VRE-Manager persons of the VRE could be different and need to be created too
|
||||||
UserManager uman = new LiferayUserManager();
|
UserManager uman = new LiferayUserManager();
|
||||||
//if the manager is not the one who triggered the creation
|
//if the manager is not the one who triggered the creation
|
||||||
String currUser = session.getUsername();
|
String currUser = currentVREManagerUserBean.getUsername();
|
||||||
log.info("***Username of who triggered the creation is: " + currUser);
|
log.info("***Username of who triggered the creation is: " + currUser);
|
||||||
|
|
||||||
log.info("Trying to create VRE Group Folder through Storage Hub ...");
|
log.info("Trying to create VRE Group Folder through Storage Hub ...");
|
||||||
createVRESharedGroupFolder(uman, vreCreated, designer, manager, description);
|
createVRESharedGroupFolder(uman, vreCreated, designer, manager, description);
|
||||||
|
|
||||||
log.info("--- createVRESharedGroupFolder OK, sending Message to designer.");
|
log.info("--- createVRESharedGroupFolder OK, now assigning the designer and manager to the Site (VRE)");
|
||||||
|
|
||||||
RoleManager rm = new LiferayRoleManager();
|
RoleManager rm = new LiferayRoleManager();
|
||||||
|
|
||||||
|
@ -949,23 +946,24 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
//add the role VRE-Manager
|
//add the role VRE-Manager
|
||||||
long userId = uman.getUserId(manager);
|
long userId = uman.getUserId(manager);
|
||||||
uman.assignUserToGroup(groupId, userId);
|
uman.assignUserToGroup(groupId, userId);
|
||||||
log.info("Added manager " + manager + " to group " + vreName + " with Success");
|
log.info("\n\n*** Added selected VRE-Manager " + manager + " to group " + vreName + " with Success");
|
||||||
|
|
||||||
log.info("Assigning Role: VRE-Manager");
|
log.info("\n\n*** Now trying assigning Site Role VRE-Manager to " + manager);
|
||||||
long roleId = rm.getRoleIdByName(VRE_MANAGER);
|
long roleId = rm.getRoleIdByName(VRE_MANAGER);
|
||||||
rm.assignRoleToUser(userId, groupId, roleId);
|
rm.assignRoleToUser(userId, groupId, roleId);
|
||||||
log.info("Admin Role VRE-Manager Associated to user " + manager + " .... returning ...");
|
log.info("Site Role VRE-Manager associated to user " + manager + " with Success");
|
||||||
|
|
||||||
}
|
}
|
||||||
//if the designer is different
|
//if the designer is different
|
||||||
if (designer.compareTo(manager) != 0) {
|
if (designer.compareTo(manager) != 0) {
|
||||||
|
log.info("\n\n*** the VRE-Designer is not equal to the VRE-Manager, need to add " + designer + " to this Site (VRE)");
|
||||||
//add the role VRE-Designer
|
//add the role VRE-Designer
|
||||||
long userId = uman.getUserId(designer);
|
long userId = uman.getUserId(designer);
|
||||||
uman.assignUserToGroup(groupId, userId);
|
uman.assignUserToGroup(groupId, userId);
|
||||||
log.info("Added designer " + designer + " to group " + vreName + " with Success");
|
log.info("Added designer " + designer + " to group " + vreName + " with Success");
|
||||||
|
log.info("\n\n*** Now trying assigning Site Role VRE-Designer to " + designer);
|
||||||
long roleId = rm.getRoleIdByName(VRE_DESIGNER);
|
long roleId = rm.getRoleIdByName(VRE_DESIGNER);
|
||||||
rm.assignRoleToUser(userId, groupId, roleId);
|
rm.assignRoleToUser(userId, groupId, roleId);
|
||||||
log.info("Admin Role VRE-Designer Associated to user " + designer + " .... returning ...");
|
log.info("Site Role VRE-Designer associated to user " + designer + " .... returning ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
return groupId;
|
return groupId;
|
||||||
|
|
Loading…
Reference in New Issue