|
|
|
@ -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
|
|
|
|
|