diff --git a/.classpath b/.classpath
index aab53a7..1fcb18d 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -41,5 +41,5 @@
-
+
diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
index 99782b8..555ee7c 100644
--- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs
+++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
@@ -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
diff --git a/pom.xml b/pom.xml
index da48a19..3dc51db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.portlets.admin
vre-deploy
war
- 4.3.0-SNAPSHOT
+ 4.3.0
gCube VRE Deploy Wizard Portlet
gCube VRE Deploy Wizard Portlet.
@@ -73,6 +73,10 @@
social-networking-library
provided
+
+ org.gcube.common
+ storagehub-client-library
+
org.gcube.common
home-library
diff --git a/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java b/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
index 7766f91..177c573 100644
--- a/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
@@ -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 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 groups = new ArrayList();
- 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 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);
- }
-
- /**
- * return the infrastructure name
- */
- private static String getRootOrganizationName() {
- return PortalContext.getConfiguration().getInfrastructureName();
- }
- /**
- *
- * @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 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());
+ else {
+ GCubeUser theAdmin = users.get(0);
+ String theAdminToken = PortalContext.getConfiguration().getCurrentUserToken(infraContext, theAdmin.getUsername());
+ List theAdminRoles = rm.listRolesByUserAndGroup(theAdmin.getUserId(), groupId);
+ List rolesString = new ArrayList();
+ 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);
+ }
+
+ log.info("Created the VRE Folder on storageHub: {} ", vreFolderName);
+
+ SecurityTokenProvider.instance.set(previousToken);
}
- 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.");
diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties
index 1115d6b..9a6609d 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=VRE Deployer
+name=deployer
module-group-id=liferay
-module-incremental-version=1
+module-incremental-version=2
tags=
short-description=
change-log=