it now calls storageHub to create the VRE FOlder upon new VRE Creations
This commit is contained in:
parent
45793f3068
commit
a583933be6
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/vre-deploy-4.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/vre-deploy-4.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/vre-deploy-4.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/vre-deploy-4.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -41,5 +41,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/vre-deploy-4.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/vre-deploy-4.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/Users/massi/workspace/vre-deploy-portlet/target/vre-deploy-4.2.0-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/workspace/vre-deploy-portlet/target/vre-deploy-4.3.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.admin</groupId>
|
||||
<artifactId>vre-deploy</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<version>4.3.0</version>
|
||||
<name>gCube VRE Deploy Wizard Portlet</name>
|
||||
<description>
|
||||
gCube VRE Deploy Wizard Portlet.
|
||||
|
@ -73,6 +73,10 @@
|
|||
<artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.admin.vredeployer.server;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
|
@ -36,15 +37,16 @@ import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
|||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
||||
import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.client.dsl.Util;
|
||||
import org.gcube.common.storagehub.client.dsl.VREFolderManager;
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
|
||||
|
@ -77,6 +79,7 @@ import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemExcep
|
|||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.gcube.vremanagement.vremodel.cl.stubs.types.FunctionalityItem;
|
||||
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHN;
|
||||
|
@ -127,7 +130,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
|
||||
protected static final String ORGANIZATION_DEFAULT_LOGO = "/org/gcube/portal/custom/communitymanager/resources/default_logo.png";
|
||||
protected static final String ORGANIZATION_DEFAULT_LOGO_URL = "http://ftp.d4science.org/apps/profiles/d4slogo.png";
|
||||
|
||||
public static final String AUTORISED_INFRA_ROLE = "Infrastructure-Manager";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -690,84 +693,45 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
* @throws GroupRetrievalFault
|
||||
* @throws UserManagementSystemException
|
||||
*/
|
||||
private void createVRESharedGroupFolder(org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated, String designer, String manager, String description) throws Exception {
|
||||
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set("/"+getRootOrganizationName());
|
||||
private void createVRESharedGroupFolder(UserManager uMan, org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated, String designer, String manager, String description) throws Exception {
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
UserManager um = new LiferayUserManager();
|
||||
|
||||
org.gcube.vomanagement.usermanagement.model.GCubeGroup group = vreCreated;
|
||||
long groupId = group.getGroupId();
|
||||
|
||||
String vreName = group.getGroupName();
|
||||
String vreScope = gm.getInfrastructureScope(groupId);
|
||||
|
||||
List<GCubeUser> users = um.listUsersByGroup(group.getGroupId());
|
||||
String vreDesignerUserName = designer;
|
||||
if (vreDesignerUserName != null) {
|
||||
Workspace ws = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(vreDesignerUserName)
|
||||
.getWorkspace();
|
||||
|
||||
GCubeGroup gGroup = createGroup(vreScope, users);
|
||||
String groupid = (gGroup == null) ? vreScope : gGroup.getName();
|
||||
WorkspaceSharedFolder wSharedFolder =createVREFolder(vreScope, vreName, groupid, ws);
|
||||
|
||||
List<String> groups = new ArrayList<String>();
|
||||
groups.add(gGroup.getName());
|
||||
wSharedFolder.setACL(groups, ACLType.WRITE_OWNER);
|
||||
|
||||
} else {
|
||||
log.error("NO VRE-MANAGER FOUND IN THIS VRE");
|
||||
String previousToken = SecurityTokenProvider.instance.get();
|
||||
//get the super user
|
||||
String infraContext = "/"+PortalContext.getConfiguration().getInfrastructureName();
|
||||
long groupId = gm.getGroupIdFromInfrastructureScope(infraContext);
|
||||
RoleManager rm = new LiferayRoleManager();
|
||||
long roleId = rm.getRoleId(AUTORISED_INFRA_ROLE, groupId);
|
||||
List<GCubeUser> users = uMan.listUsersByGroupAndRole(groupId, roleId);
|
||||
if (users.isEmpty()) {
|
||||
log.error("Cannot create the VRE Folder: there is no user having role {} on context {}", AUTORISED_INFRA_ROLE , infraContext);
|
||||
return;
|
||||
}
|
||||
ScopeProvider.instance.set(currScope);
|
||||
else {
|
||||
GCubeUser theAdmin = users.get(0);
|
||||
String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, theAdmin.getUsername());
|
||||
List<GCubeRole> theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), groupId);
|
||||
List<String> rolesString = new ArrayList<String>();
|
||||
for (GCubeRole gCubeRole : theAdminRoles) {
|
||||
rolesString.add(gCubeRole.getRoleName());
|
||||
}
|
||||
authorizationService().setTokenRoles(theAdminToken, rolesString);
|
||||
SecurityTokenProvider.instance.set(theAdminToken);
|
||||
String newVreContext = gm.getInfrastructureScope(vreCreated.getGroupId());
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
String vreFolderName = Util.getVREGroupFromContext(newVreContext);
|
||||
VREFolderManager vreFolderMaanger = shc.getVreFolderManager(vreFolderName);
|
||||
vreFolderMaanger.createVRE(AccessType.WRITE_OWNER, designer);
|
||||
vreFolderMaanger.setAdmin(designer);
|
||||
if (designer.compareTo(manager) != 0) {
|
||||
vreFolderMaanger.addUser(manager);
|
||||
vreFolderMaanger.setAdmin(manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the infrastructure name
|
||||
*/
|
||||
private static String getRootOrganizationName() {
|
||||
return PortalContext.getConfiguration().getInfrastructureName();
|
||||
log.info("Created the VRE Folder on storageHub: {} ", vreFolderName);
|
||||
|
||||
SecurityTokenProvider.instance.set(previousToken);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vreScope
|
||||
* @param vreName
|
||||
* @param groupId
|
||||
* @param ws
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static WorkspaceSharedFolder createVREFolder(String vreScope, String vreName, String groupId, Workspace ws) throws Exception {
|
||||
|
||||
WorkspaceSharedFolder folder = ws.createSharedFolder(vreScope, "Special Shared folder for VRE " + vreName, groupId, ws.getRoot().getId(), vreName, true);
|
||||
System.out.println(folder.getPath());
|
||||
return folder;
|
||||
|
||||
}
|
||||
/**
|
||||
* Create the group in HL and assign users to it
|
||||
* @param vreScope the scope of the vre as name
|
||||
* @param usersToAdd the listo of users to add
|
||||
* @throws InternalErrorException
|
||||
*/
|
||||
private static GCubeGroup createGroup(String vreScope, List<GCubeUser> usersToAdd) throws InternalErrorException {
|
||||
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager gm = HomeLibrary
|
||||
.getHomeManagerFactory().getUserManager();
|
||||
GCubeGroup group = gm.createGroup(vreScope);
|
||||
for (GCubeUser user : usersToAdd) {
|
||||
group.addMember(user.getUsername());
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the html representation of the report
|
||||
|
@ -971,8 +935,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
String currUser = session.getUsername();
|
||||
log.info("***Username of who triggered the creation is: " + currUser);
|
||||
|
||||
log.info("Trying to create VRE Group Folder through HomeLibrary ...");
|
||||
createVRESharedGroupFolder(vreCreated, designer, manager, description);
|
||||
log.info("Trying to create VRE Group Folder through Storage Hub ...");
|
||||
createVRESharedGroupFolder(uman, vreCreated, designer, manager, description);
|
||||
|
||||
log.info("--- createVRESharedGroupFolder OK, sending Message to designer.");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name=VRE Deployer
|
||||
name=deployer
|
||||
module-group-id=liferay
|
||||
module-incremental-version=1
|
||||
module-incremental-version=2
|
||||
tags=
|
||||
short-description=
|
||||
change-log=
|
||||
|
|
Loading…
Reference in New Issue