set the VRE Designer as administrator of the VRE FOlder in workspace and not the VRE Manager, update the VRE layotu with the calendar and updates the generic resource applicationprofile of the calendar with the new scope
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-deploy@92530 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ac8ec7d72a
commit
c94c6ead61
|
@ -1,30 +0,0 @@
|
|||
package org.gcube.portlets.admin.vredeployer.server;
|
||||
|
||||
import org.gcube.application.framework.accesslogger.model.AccessLogEntry;
|
||||
|
||||
/**
|
||||
* Represents an access log entry for creating a new Template
|
||||
*/
|
||||
public class CreatedVRELogEntry extends AccessLogEntry{
|
||||
|
||||
private String name;
|
||||
private String id;
|
||||
private String designer;
|
||||
private String manager;
|
||||
|
||||
public CreatedVRELogEntry(String name, String id, String designer, String manager) {
|
||||
super("Deploy_VRE");
|
||||
this.name = replaceReservedChars(name);
|
||||
this.id = replaceReservedChars(id);
|
||||
this.designer = replaceReservedChars(designer);
|
||||
this.manager = replaceReservedChars(manager);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogMessage() {
|
||||
String message = "Name = " + name + "|ID = " + id + "|DESIGNER = " + designer+ "|MANAGER = " + manager;
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.portlets.admin.vredeployer.server;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -28,7 +31,6 @@ 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;
|
||||
|
@ -41,7 +43,10 @@ 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.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.portal.custom.communitymanager.PortletsIdManager;
|
||||
import org.gcube.portal.custom.communitymanager.ThemesIdManager;
|
||||
|
@ -77,6 +82,8 @@ import org.gcube.portlets.admin.vredeployer.shared.deployreport.ClientResourceMa
|
|||
import org.gcube.portlets.admin.vredeployer.shared.deployreport.ClientResourcesDeployReport;
|
||||
import org.gcube.portlets.admin.vredeployer.shared.deployreport.ClientServiceReport;
|
||||
import org.gcube.portlets.admin.vredeployer.shared.deployreport.DeployStatus;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
|
@ -106,6 +113,8 @@ import org.gcube.vremanagement.vremodeler.utils.reports.Status;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -643,19 +652,19 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
//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();
|
||||
// }
|
||||
//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;
|
||||
}
|
||||
|
@ -713,10 +722,19 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
Organization vreCreated = createCommunityAndLayout(name);
|
||||
if (vreCreated != null) {
|
||||
try {
|
||||
log.info("--- CREATED LAYOUTS AND COMMUNITY --- OK, creating VRE Group Folder");
|
||||
|
||||
log.info("--- CREATED LAYOUTS AND COMMUNITY OK, updating Calendar Application Profile.");
|
||||
String vreScope = getScopeByOrganizationId(""+vreCreated.getOrganizationId());
|
||||
String vreUrl = "/group/"+vreCreated.getName().toLowerCase()+"/calendar";
|
||||
updateCalendarApplicationProfile(vreScope, vreUrl);
|
||||
|
||||
log.info("--- 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);
|
||||
|
@ -724,18 +742,18 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession().getUsername());
|
||||
ArrayList<String> toSend = new ArrayList<String>();
|
||||
toSend.add(designer);
|
||||
String subject = "VRE Definition approved and deployed";
|
||||
String body = "Dear "+userDesigner.getFirstname()+", \n\n" + userManager.getFullname() + " has approved the deployment of the Virtual Research Environment you requested: " + name +".";
|
||||
body+=".\n\nThis VRE has been deployed successfully and is already available for you on this portal. Please, check your Virtual Research Environments list.";
|
||||
String subject = "Definition approved and deployed";
|
||||
String body = "Dear "+userDesigner.getFirstname()+", \n\n" + userManager.getFullname() + " has approved the deployment of the group you requested: " + name +".";
|
||||
body+=".\n\nThis group has been deployed successfully and is already available for you on this portal. Please, check your list.";
|
||||
workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), toSend);
|
||||
NotificationsManager nnm = new ApplicationNotificationsManager(getASLSession());
|
||||
if (nnm.notifyMessageReceived(designer, subject))
|
||||
log.trace("Sending VRE Definition create notification: " + subject + " OK");
|
||||
log.trace("Sending Definition create notification: " + subject + " OK");
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
log.info("--- Trying to share a news for this VRE");
|
||||
shareCreatedVRENews(designer, manager, name, description);
|
||||
//shareCreatedVRENews(designer, manager, name, description);
|
||||
|
||||
|
||||
|
||||
|
@ -753,6 +771,49 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
|
||||
log.debug("---Sending Report, globalState --- " + report.getStatus() );
|
||||
return convertServiceDeployReport(report);
|
||||
}
|
||||
|
||||
private void updateCalendarApplicationProfile(String vreScope, String vreURL) {
|
||||
String appId = "org.gcube.portal.calendarwrapper.GCubeCalendarHandler";
|
||||
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
|
||||
ScopeProvider.instance.set("/"+scopeToQuery);
|
||||
|
||||
|
||||
SimpleQuery query = queryFor(GenericResource.class);
|
||||
query.addCondition("$resource/Profile/SecondaryType/text() eq 'ApplicationProfile'");
|
||||
query.addCondition("$resource/Profile/Body/AppId/text() eq '" + appId + "'");
|
||||
|
||||
DiscoveryClient<GenericResource> client = clientFor(GenericResource.class);
|
||||
//
|
||||
List<GenericResource> list = client.submit(query);
|
||||
if (list == null || list.isEmpty()) {
|
||||
log.error("Cannot retrieve the IS profile for resource: ");
|
||||
return;
|
||||
}
|
||||
GenericResource gr = list.get(0);
|
||||
log.debug("updating " + gr.profile().name());
|
||||
|
||||
String endpoint = "<EndPoint><Scope>"+vreScope+"</Scope><URL>"+vreURL+"</URL></EndPoint>";
|
||||
Node fragmentNode;
|
||||
try {
|
||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Element elem = gr.profile().body();
|
||||
System.out.println("QUI ");
|
||||
fragmentNode = docBuilder.parse(new InputSource(new StringReader(endpoint))).getDocumentElement();
|
||||
fragmentNode = elem.getOwnerDocument().importNode(fragmentNode, true);
|
||||
elem.appendChild(fragmentNode);
|
||||
} catch (Exception e) {
|
||||
//in case no xml is entered, just text
|
||||
log.error("errore");
|
||||
}
|
||||
RegistryPublisher rp=RegistryPublisherFactory.create();
|
||||
rp.update(gr);
|
||||
ScopeProvider.instance.set(currScope);
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* this method is in charge of reflecting the VRE deployed in a gCube Portal context in the HomeLibrary JackRabbit Repository.
|
||||
|
@ -779,12 +840,12 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
String vreScope = gm.getScope(groupId);
|
||||
|
||||
List<UserModel> users = um.listUsersByGroup(group.getGroupId());
|
||||
String vreManagerUserName = manager;
|
||||
if (vreManagerUserName != null) {
|
||||
String vreDesignerUserName = designer;
|
||||
if (vreDesignerUserName != null) {
|
||||
Workspace ws = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(vreManagerUserName)
|
||||
.getHome(vreDesignerUserName)
|
||||
.getWorkspace();
|
||||
|
||||
GCubeGroup gGroup = createGroup(vreScope, users);
|
||||
|
@ -1130,11 +1191,14 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
//the method above create 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
|
||||
UserManager uman = new LiferayUserManager();
|
||||
|
||||
Role created = null;
|
||||
|
||||
//if the manager is not the one who triggered the creation
|
||||
if (manager.compareTo(getASLSession().getUsername()) != 0) {
|
||||
//add the role VRE-Manager
|
||||
long uid = Long.parseLong(uman.getUserId(manager));
|
||||
Role created = createRole("VRE-Manager", vreName, uid);
|
||||
created = createRole("VRE-Manager", vreName, uid);
|
||||
log.debug("Admin Role "+ created.getName() + " Created Successfully");
|
||||
|
||||
Organization toReturn = OrganizationLocalServiceUtil.getOrganization(groupModelid);
|
||||
|
@ -1154,8 +1218,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
if (designer.compareTo(manager) != 0) {
|
||||
//add the role VRE-Designer
|
||||
long uid = Long.parseLong(uman.getUserId(designer));
|
||||
Role created = createRole("VRE-Designer", vreName, uid);
|
||||
log.debug("Admin Role "+ created.getName() + " Created Successfully");
|
||||
|
||||
log.debug("Admin Role "+ created.getName() + " Read Successfully");
|
||||
|
||||
Organization toReturn = OrganizationLocalServiceUtil.getOrganization(groupModelid);
|
||||
Group vreCreated = toReturn.getGroup();
|
||||
|
@ -1423,17 +1487,20 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
GCUBESiteLayout siteLayout = null;
|
||||
String email = OrganizationManagerImpl.validateUser(getASLSession().getUsername()).getEmailAddress();
|
||||
siteLayout = new GCUBESiteLayout(OrganizationManagerImpl.getCompany(), voName, email);
|
||||
siteLayout.addTab(new GCUBELayoutTab("Home", GCUBELayoutType.ONE_COL,
|
||||
siteLayout.addTab(new GCUBELayoutTab(voName, GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("gCube Loggedin", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_LOGGEDIN))));
|
||||
|
||||
//create tab Users and Roles with 2 subtabs
|
||||
GCUBELayoutTab usersAndRoles = new GCUBELayoutTab("Administration", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Navigation", PortletsIdManager.getLRPortletId(PortletsIdManager.LR_NAVIGATION)));
|
||||
GCUBELayoutTab usersTab = new GCUBELayoutTab("Manage Users", GCUBELayoutType.ONE_COL,
|
||||
GCUBELayoutTab usersTab = new GCUBELayoutTab("Manage User and Requests", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Users", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_USERS_MANAGE)));
|
||||
GCUBELayoutTab rolesTab = new GCUBELayoutTab("Manage Roles", GCUBELayoutType.ONE_COL,
|
||||
GCUBELayoutTab usersAddTab = new GCUBELayoutTab("Add new Users", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Users", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_ADD_USERS_MANAGE)));
|
||||
GCUBELayoutTab rolesTab = new GCUBELayoutTab("Add new Roles", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Roles", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_ROLES_MANAGE)));
|
||||
usersAndRoles.addSubTab(usersTab);
|
||||
usersAndRoles.addSubTab(usersAddTab);
|
||||
usersAndRoles.addSubTab(rolesTab);
|
||||
//add the tab
|
||||
siteLayout.addTab(usersAndRoles);
|
||||
|
@ -1441,8 +1508,8 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|||
siteLayout.addTab(new GCUBELayoutTab("Resources Management", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Resources Management", PortletsIdManager.getLRPortletId(PortletsIdManager.RESOURCES_MANAGEMENT))));
|
||||
else
|
||||
siteLayout.addTab(new GCUBELayoutTab("Workspace", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Workspace", PortletsIdManager.getLRPortletId(PortletsIdManager.WORKSPACE))));
|
||||
siteLayout.addTab(new GCUBELayoutTab("Calendar", GCUBELayoutType.ONE_COL,
|
||||
new GCUBEPortlet("Calendar", PortletsIdManager.getLRPortletId(PortletsIdManager.LR_CALENDAR))));
|
||||
return siteLayout;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue