added VRE Special Folder Creation

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-deploy@91597 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 10 years ago
parent be725e2872
commit bdfc9174d9

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/vre-deploy-3.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/vre-deploy-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -20,16 +20,16 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/vre-deploy-3.0.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/vre-deploy-3.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -1,5 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/vre-deploy/target/vre-deploy-3.0.0-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/vre-deploy/target/vre-deploy-3.1.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -1,9 +1,8 @@
#Tue Jun 25 15:18:53 CEST 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.7

@ -3,5 +3,5 @@
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.6"/>
<installed facet="java" version="1.7"/>
</faceted-project>

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>vre-deploy</artifactId>
<packaging>war</packaging>
<version>3.0.0-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<name>gCube VRE Deploy Wizard Portlet</name>
<description>
gCube VRE Deploy Wizard Portlet.
@ -27,8 +27,8 @@
<gwtVersion>2.5.1</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -182,8 +182,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- SA Plugin -->

@ -28,13 +28,20 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.application.framework.vremanagement.vremanagement.impl.VREGeneratorEvo;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
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.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.communitymanager.PortletsIdManager;
import org.gcube.portal.custom.communitymanager.ThemesIdManager;
@ -73,6 +80,7 @@ import org.gcube.portlets.admin.vredeployer.shared.deployreport.DeployStatus;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
@ -635,18 +643,19 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
e.printStackTrace();
return false;
}
// AccessLogger log = AccessLogger.getAccessLogger();
// CreatedVRELogEntry logEntry;
// try {
// logEntry = new CreatedVRELogEntry(
// vreGenerator.getVREModel().name(),
// vreGenerator.getVREepr(),
// vreGenerator.getVREModel().designer(),
// vreGenerator.getVREModel().manager());
// log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
// } catch (RemoteException e) {
// e.printStackTrace();
// }
//TODO: re enable in the future it gives exception
// AccessLogger log = AccessLogger.getAccessLogger();
// CreatedVRELogEntry logEntry;
// try {
// logEntry = new CreatedVRELogEntry(
// vreGenerator.getVREModel().name(),
// vreGenerator.getVREepr(),
// vreGenerator.getVREModel().designer(),
// vreGenerator.getVREModel().manager());
// log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
// } catch (RemoteException e) {
// e.printStackTrace();
// }
return true;
}
@ -701,10 +710,13 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
}
String designer = (String) getASLSession().getAttribute(DESIGNER);
String manager = (String) getASLSession().getAttribute(MANAGER);
if (createCommunityAndLayout(name)) {
log.info("--- CREATED LAYOUTS AND COMMUNITY --- OK, sending Message to designer.");
Organization vreCreated = createCommunityAndLayout(name);
if (vreCreated != null) {
try {
log.info("--- CREATED LAYOUTS AND COMMUNITY --- OK, creating VRE Group Folder");
createVRESharedGroupFolder(vreCreated, designer, manager, description);
log.info("--- createVRESharedGroupFolder OK, sending Message to designer.");
UserManager um = new LiferayUserManager();
UserModel userDesigner = um.getUserByScreenName(designer);
UserModel userManager = um.getUserByScreenName(manager);
@ -725,6 +737,9 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
log.info("--- Trying to share a news for this VRE");
shareCreatedVRENews(designer, manager, name, description);
} else
log.error("--- DANGER DANGER DANGER!!!!! -> CREATED LAYOUTS AND COMMUNITY WITH ERRORS");
@ -739,12 +754,95 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
log.debug("---Sending Report, globalState --- " + report.getStatus() );
return convertServiceDeployReport(report);
}
/**
* this method is in charge of reflecting the VRE deployed in a gCube Portal context in the HomeLibrary JackRabbit Repository.
It also creates shared folders for these groups and assign VRE-Managers as Administrators of such foldes
* @param vreName
* @param vreScope
* @param designer the username of the designer
* @param manager the username of the manager
* @param description
* @throws GroupRetrievalFault
* @throws UserManagementSystemException
*/
private void createVRESharedGroupFolder(Organization vreCreated, String designer, String manager, String description) throws Exception {
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set("/"+getRootOrganizationName());
GroupManager gm = new LiferayGroupManager();
UserManager um = new LiferayUserManager();
GroupModel group = gm.getGroup(""+vreCreated.getOrganizationId());
String groupId = group.getGroupId();
String vreName = group.getGroupName();
String vreScope = gm.getScope(groupId);
List<UserModel> users = um.listUsersByGroup(group.getGroupId());
String vreManagerUserName = manager;
if (vreManagerUserName != null) {
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(vreManagerUserName)
.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");
}
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<UserModel> usersToAdd) throws InternalErrorException {
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager gm = HomeLibrary
.getHomeManagerFactory().getUserManager();
GCubeGroup group = gm.createGroup(vreScope);
for (UserModel user : usersToAdd) {
group.addMember(user.getScreenName());
}
return group;
}
/**
*
* @param designer
* @param manager
* @param name
* @param designer the username of the designer
* @param manager the username of the manager
* @param name the vre name
*/
private void shareCreatedVRENews(String designer, String manager, String name, String description) {
@ -784,7 +882,11 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
}
}
}
/**
*
* @param vreid the organizatio id in Liferay API
* @return
*/
private String getScopeByOrganizationId(String vreid) {
GroupManager gm = new LiferayGroupManager();
try {
@ -824,7 +926,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
try {
GroupManager gm = new LiferayGroupManager();
currUser = OrganizationsUtil.validateUser(username);
for (Organization org : currUser.getOrganizations())
if (gm.isVRE(org.getOrganizationId()+"")) {
GroupModel toAdd = gm.getGroup(""+org.getOrganizationId());
@ -1002,11 +1104,11 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
/**
* Creates the community and its layout in Liferay
*/
private boolean createCommunityAndLayout(String vreName) {
private Organization createCommunityAndLayout(String vreName) {
if (vreExists(vreName)) {
System.out.println("VRE Exists already");
return false;
return null;
}
@ -1035,7 +1137,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
Role created = createRole("VRE-Manager", vreName, uid);
log.debug("Admin Role "+ created.getName() + " Created Successfully");
Group vreCreated = OrganizationLocalServiceUtil.getOrganization(groupModelid).getGroup();
Organization toReturn = OrganizationLocalServiceUtil.getOrganization(groupModelid);
Group vreCreated = toReturn.getGroup();
uman.assignUserToGroup(""+vreCreated.getClassPK(), ""+uid);
log.debug("Added user " + manager + " to group " + vreCreated.getName() + " with Success");
@ -1043,7 +1146,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
log.debug("Assigning Role: VRE-Manager");
RoleManager rm = new LiferayRoleManager();
rm.assignRoleToUser(""+vreCreated.getClassPK(), ""+created.getRoleId(), ""+uid);
log.debug("Admin Role VRE-Manager Associated to user " + designer + " .... returning ...");
log.debug("Admin Role VRE-Manager Associated to user " + designer + " .... returning ...");
return toReturn;
}
//if the designer is different
@ -1053,7 +1157,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
Role created = createRole("VRE-Designer", vreName, uid);
log.debug("Admin Role "+ created.getName() + " Created Successfully");
Group vreCreated = OrganizationLocalServiceUtil.getOrganization(groupModelid).getGroup();
Organization toReturn = OrganizationLocalServiceUtil.getOrganization(groupModelid);
Group vreCreated = toReturn.getGroup();
uman.assignUserToGroup(""+vreCreated.getClassPK(), ""+uid);
log.debug("Added user " + designer + " to group " + vreCreated.getName() + " with Success");
@ -1062,14 +1167,14 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
RoleManager rm = new LiferayRoleManager();
rm.assignRoleToUser(""+vreCreated.getClassPK(), ""+created.getRoleId(), ""+uid);
log.debug("Admin Role VRE-Designer Associated to user " + designer + " .... returning ...");
return toReturn;
}
} catch (Exception e) {
e.printStackTrace();
return false;
return null;
}
return true;
return null;
}
/**
* Create a Regular Manager Role for the community

Loading…
Cancel
Save