package org.gcube.portlets.user.gcubeloggedin.server; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.common.portal.CustomAttributeKeys; import org.gcube.common.portal.PortalContext; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; import org.gcube.portlets.user.gcubeloggedin.shared.VObject; import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient; import org.gcube.portlets.user.gcubeloggedin.shared.VREClient; import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.gcube.vomanagement.usermanagement.model.GCubeRole; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.service.UserLocalServiceUtil; /** * The server side implementation of the RPC service. */ @SuppressWarnings("serial") public class LoggedinServiceImpl extends RemoteServiceServlet implements LoggedinService { private static final Logger _log = LoggerFactory.getLogger(LoggedinServiceImpl.class); /** * the current ASLSession * @return . */ private ASLSession getASLSession() { String sessionID = this.getThreadLocalRequest().getSession().getId(); String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); if (user == null) { _log.warn("LOGGEDIN PORTLET: USER IS NULL \n\n SESSION ID READ: " +sessionID ); user = "test.user"; _log.warn("session ID= *" + sessionID + "* user= *" + user + "*" ); } return SessionManager.getInstance().getASLSession(sessionID, user); } /** * * @return true if you're running into the portal, false if in development */ private boolean isWithinPortal() { try { UserLocalServiceUtil.getService(); return true; } catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) { _log.trace("Development Mode ON"); return false; } } /** * return the current selected VRE */ public VObject getSelectedRE(String portalURL) { ASLSession aslSession = getASLSession(); String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL); if (friendlyURL == null) {//the URL is not a portal URL, we are in devmode. return new VREClient("Test VRE Name", "", "" + "Fishery and Aquaculture Resources Management (FARM) Virtual Organisation The FARM Virtual Organisation is the dynamic group of individuals and/or institutions defined around a set of sharing rules in which resource providers and consumers specify clearly and carefully just what is shared, who is allowed to share, and the conditions under which sharing occurs to serve the needs of the Fisheries and Aquaculture Resources Management. " + " This VO is conceived to support various application scenarios arising in the FARM Community including the production of Fisheries and Aquaculture Country Profiles, " + "the management of catch statistics including harmonisation, the dynamic generation of biodiversity maps and species distribution maps." + " This Virtual Organisation currently consists of:
Dear manager of "+ scope +",
this email message was automatically generated by " + portalbasicurl +" to inform you that ");
body.append("
");
body.append(""+name + " " + lastname +" has left to the following environment: ");
body.append("
");
body.append("" + scope+"");
body.append("
");
body.append("
");
body.append("Username: " + username);
body.append("
");
body.append("e-mail: " + currUser.getEmail());
body.append("
"); body.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain"+ " information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. " + "If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message."); body.append("
"); String[] allMails = new String[adminEmails.size()]; adminEmails.toArray(allMails); EmailNotification mailToAdmin = new EmailNotification("no-reply@d4science.org", allMails , "[" + gatewayName + "] - unregistration from VRE", body.toString()); mailToAdmin.sendEmail(); } }