removed ASL Session, ported to gCube Client Context
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@134139 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4734c5a829
commit
732dd59f96
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -39,5 +39,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/gcube-loggedin-3.1.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/gcube-loggedin-3.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
<dependent-module archiveName="gcube-widgets-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<dependent-module archiveName="session-checker-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
|
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||||
|
|
19
pom.xml
19
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-loggedin</artifactId>
|
<artifactId>gcube-loggedin</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>3.1.0-SNAPSHOT</version>
|
<version>3.2.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>gCube Environment Home Portlet</name>
|
<name>gCube Environment Home Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
|
@ -76,12 +76,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.gwtbootstrap</groupId>
|
<groupId>com.github.gwtbootstrap</groupId>
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
|
@ -92,16 +87,6 @@
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
|
||||||
<artifactId>session-checker</artifactId>
|
|
||||||
<version>[1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
|
||||||
<artifactId>aslcore</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
<artifactId>usermanagement-core</artifactId>
|
<artifactId>usermanagement-core</artifactId>
|
||||||
|
|
|
@ -22,6 +22,8 @@ public class GCubeLoggedin implements EntryPoint {
|
||||||
* This is the entry point method.
|
* This is the entry point method.
|
||||||
*/
|
*/
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
|
|
||||||
|
|
||||||
main_panel.setWidth("100%");
|
main_panel.setWidth("100%");
|
||||||
main_panel.add(AboutView.getLoadingHTML());
|
main_panel.add(AboutView.getLoadingHTML());
|
||||||
// Associate the new panel with the HTML host page.
|
// Associate the new panel with the HTML host page.
|
||||||
|
|
|
@ -4,11 +4,9 @@ import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
||||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Heading;
|
|
||||||
import com.github.gwtbootstrap.client.ui.Hero;
|
import com.github.gwtbootstrap.client.ui.Hero;
|
||||||
import com.github.gwtbootstrap.client.ui.Image;
|
import com.github.gwtbootstrap.client.ui.Image;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
@ -54,11 +52,8 @@ public class AboutView extends Composite {
|
||||||
public AboutView() {
|
public AboutView() {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String vreDescription;
|
private String vreDescription;
|
||||||
@UiField Image vreImage;
|
@UiField Image vreImage;
|
||||||
@UiField Heading vreName;
|
|
||||||
@UiField HTML description;
|
@UiField HTML description;
|
||||||
@UiField Button seeMore;
|
@UiField Button seeMore;
|
||||||
@UiField Button editButton;
|
@UiField Button editButton;
|
||||||
|
@ -68,7 +63,6 @@ public class AboutView extends Composite {
|
||||||
public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) {
|
public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
this.vreDescription = vobj.getDescription();
|
this.vreDescription = vobj.getDescription();
|
||||||
vreName.setText(vobj.getName());
|
|
||||||
vreImage.setUrl(vobj.getImageURL());
|
vreImage.setUrl(vobj.getImageURL());
|
||||||
String desc = vreDescription = vobj.getDescription();
|
String desc = vreDescription = vobj.getDescription();
|
||||||
if (desc.length() > MAX_CHAR_DESC) {
|
if (desc.length() > MAX_CHAR_DESC) {
|
||||||
|
@ -192,9 +186,7 @@ public class AboutView extends Composite {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
if (result != null)
|
if (result != null)
|
||||||
Location.assign(result);
|
Location.assign(result);
|
||||||
else
|
|
||||||
CheckSession.showLogoutDialog();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<b:Image ui:field="vreImage" />
|
<b:Image ui:field="vreImage" />
|
||||||
<!-- The Caption is optional -->
|
<!-- The Caption is optional -->
|
||||||
<b:Caption>
|
<b:Caption>
|
||||||
<b:Heading size="3" ui:field="vreName">Thumbnail label</b:Heading>
|
|
||||||
<g:HTML ui:field="description">
|
<g:HTML ui:field="description">
|
||||||
</g:HTML>
|
</g:HTML>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.portlets.user.gcubeloggedin.client.ui;
|
||||||
|
|
||||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Icon;
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
|
@ -15,7 +14,6 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
import com.google.gwt.user.client.Window.Location;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
@ -68,16 +66,7 @@ public class EditDescriptionModal extends Composite {
|
||||||
text2Edit.setText("");
|
text2Edit.setText("");
|
||||||
text2Edit.setVisible(false);
|
text2Edit.setVisible(false);
|
||||||
loadingContainer.setVisible(true);
|
loadingContainer.setVisible(true);
|
||||||
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
|
doSave(vreDescription);
|
||||||
@Override
|
|
||||||
public void onSuccess(Boolean result) {
|
|
||||||
doSave(vreDescription);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSave(String toSave) {
|
private void doSave(String toSave) {
|
||||||
|
|
|
@ -5,19 +5,17 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.portal.mailing.EmailNotification;
|
import org.gcube.common.portal.mailing.EmailNotification;
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
|
||||||
import org.gcube.portlets.user.gcubeloggedin.shared.VREClient;
|
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.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
@ -37,34 +35,22 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
public class LoggedinServiceImpl extends RemoteServiceServlet implements LoggedinService {
|
public class LoggedinServiceImpl extends RemoteServiceServlet implements LoggedinService {
|
||||||
|
|
||||||
private static final Logger _log = LoggerFactory.getLogger(LoggedinServiceImpl.class);
|
private static final Logger _log = LoggerFactory.getLogger(LoggedinServiceImpl.class);
|
||||||
private static final String VRE_MANAGER_ROLE = "VRE-Manager";
|
private PortalContext context = PortalContext.getConfiguration();
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 the current selected VRE
|
* return the current selected VRE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public VObject getSelectedRE(String portalURL) {
|
public VObject getSelectedRE(String portalURL) {
|
||||||
ASLSession aslSession = getASLSession();
|
long currGroupId = context.getCurrentGroupId(getThreadLocalRequest());
|
||||||
String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL);
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
GCubeGroup currGroup = null;
|
||||||
|
try {
|
||||||
|
currGroup = gm.getGroup(currGroupId);
|
||||||
|
} catch (UserManagementSystemException | GroupRetrievalFault e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
String friendlyURL = currGroup.getFriendlyURL();
|
||||||
|
_log.debug("curr group: " + currGroup.getGroupName() + " friendlyURL = " + friendlyURL);
|
||||||
if (friendlyURL == null) {//the URL is not a portal URL, we are in devmode.
|
if (friendlyURL == null) {//the URL is not a portal URL, we are in devmode.
|
||||||
return new VREClient("Test VRE Name", "", "" +
|
return new VREClient("Test VRE Name", "", "" +
|
||||||
"Fishery and Aquaculture Resources Management (FARM) Virtual Organisation</b> The FARM Virtual Organisation is the <b><i>dynamic group of individuals</i></b> and/or <b><i>institutions</i></b> defined around a set of <b><i>sharing rules</i></b> in which <b><i>resource providers</i></b> and <b><i>consumers</i></b> 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 <b><i>Fisheries and Aquaculture Resources Management</i></b>. "
|
"Fishery and Aquaculture Resources Management (FARM) Virtual Organisation</b> The FARM Virtual Organisation is the <b><i>dynamic group of individuals</i></b> and/or <b><i>institutions</i></b> defined around a set of <b><i>sharing rules</i></b> in which <b><i>resource providers</i></b> and <b><i>consumers</i></b> 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 <b><i>Fisheries and Aquaculture Resources Management</i></b>. "
|
||||||
|
@ -79,39 +65,15 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
, "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true, true);
|
, "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true, true);
|
||||||
}
|
}
|
||||||
_log.trace("getting Selected Research Environment");
|
_log.trace("getting Selected Research Environment");
|
||||||
GroupManager gm = new LiferayGroupManager();
|
|
||||||
GCubeGroup currSite = null;
|
|
||||||
try {
|
|
||||||
List<GCubeGroup> groups = gm.listGroups();
|
|
||||||
for (GCubeGroup g : groups) {
|
|
||||||
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
|
||||||
long groupId = g.getGroupId();
|
|
||||||
String scopeToSet = gm.getInfrastructureScope(groupId);
|
|
||||||
getASLSession().setScope(scopeToSet);
|
|
||||||
_log.info("GOT Selected Research Environment: " + scopeToSet);
|
|
||||||
currSite = g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set the current ORG bean in session
|
|
||||||
*/
|
|
||||||
aslSession.setAttribute(ScopeHelper.CURR_ORG, currSite);
|
|
||||||
|
|
||||||
aslSession.setGroupModelInfos(currSite.getGroupName(), currSite.getGroupId());
|
|
||||||
|
|
||||||
_log.trace("CURRENT ORG SET IN SESSION: " + currSite.getGroupName());
|
|
||||||
|
|
||||||
|
|
||||||
String name = currSite.getGroupName();
|
|
||||||
String logoURL = gm.getGroupLogoURL(currSite.getLogoId());
|
String name = currGroup.getGroupName();
|
||||||
|
String logoURL = gm.getGroupLogoURL(currGroup.getLogoId());
|
||||||
String desc = "";
|
String desc = "";
|
||||||
//set the description for the vre
|
//set the description for the vre
|
||||||
if (currSite.getDescription() != null)
|
if (currGroup.getDescription() != null)
|
||||||
desc = currSite.getDescription();
|
desc = currGroup.getDescription();
|
||||||
return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, false, false, isCurrUserVREManager());
|
return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, false, false, isCurrUserVREManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,15 +82,14 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isCurrUserVREManager() {
|
private boolean isCurrUserVREManager() {
|
||||||
ASLSession session = getASLSession();
|
|
||||||
long userId;
|
long userId;
|
||||||
try {
|
try {
|
||||||
userId = new LiferayUserManager().getUserId(session.getUsername());
|
userId = context.getCurrentUser(getThreadLocalRequest()).getUserId();
|
||||||
long groupId = new LiferayGroupManager().getGroupIdFromInfrastructureScope(session.getScope());
|
long groupId = context.getCurrentGroupId(getThreadLocalRequest());
|
||||||
RoleManager rm = new LiferayRoleManager();
|
RoleManager rm = new LiferayRoleManager();
|
||||||
long roleId = rm.getRoleIdByName(VRE_MANAGER_ROLE);
|
long roleId = rm.getRoleIdByName(GCubeRole.VRE_MANAGER_LABEL);
|
||||||
boolean toReturn = rm.hasRole(userId, groupId, roleId);
|
boolean toReturn = rm.hasRole(userId, groupId, roleId);
|
||||||
_log.debug("User " + session.getUsername() + " is " + VRE_MANAGER_ROLE + " for " + session.getScope() + "? -> " + toReturn);
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -179,11 +140,9 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String saveVREDescription(String toSave) {
|
public String saveVREDescription(String toSave) {
|
||||||
try {
|
try {
|
||||||
String scope = getASLSession().getScope();
|
long groupId = context.getCurrentGroupId(getThreadLocalRequest());
|
||||||
GroupManager gm = new LiferayGroupManager();
|
return new LiferayGroupManager().updateGroupDescription(groupId, toSave);
|
||||||
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
|
|
||||||
return gm.updateGroupDescription(groupId, toSave);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -193,30 +152,22 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
public boolean isLeaveButtonAvailable(String portalURL) {
|
public boolean isLeaveButtonAvailable(String portalURL) {
|
||||||
|
|
||||||
if(isWithinPortal()){
|
if(isWithinPortal()){
|
||||||
String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL);
|
long currGroupId = context.getCurrentGroupId(getThreadLocalRequest());
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
GCubeGroup currSite = null;
|
GCubeGroup currGroup = null;
|
||||||
try {
|
try {
|
||||||
List<GCubeGroup> groups = gm.listGroups();
|
currGroup = gm.getGroup(currGroupId);
|
||||||
for (GCubeGroup g : groups) {
|
} catch (UserManagementSystemException | GroupRetrievalFault e1) {
|
||||||
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
e1.printStackTrace();
|
||||||
long groupId = g.getGroupId();
|
|
||||||
String scopeToSet = gm.getInfrastructureScope(groupId);
|
|
||||||
getASLSession().setScope(scopeToSet);
|
|
||||||
_log.info("GOT Selected Research Environment: " + scopeToSet);
|
|
||||||
currSite = g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean isMandatory = false;
|
Boolean isMandatory = false;
|
||||||
try{
|
try{
|
||||||
isMandatory = (Boolean) gm.readCustomAttr(currSite.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName());
|
isMandatory = (Boolean) gm.readCustomAttr(currGroup.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
_log.error("Unable to evaluate if the leave button can be added for the current group " + currSite.getGroupName(), e);
|
_log.error("Unable to evaluate if the leave button can be added for the current group " + currGroup.getGroupName(), e);
|
||||||
}
|
}
|
||||||
_log.debug("Is Leave button available in vre " + currSite.getGroupName() + " ? " + isMandatory);
|
_log.debug("Is Leave button available in vre " + currGroup.getGroupName() + " ? " + isMandatory);
|
||||||
return !isMandatory;
|
return !isMandatory;
|
||||||
}else return true;
|
}else return true;
|
||||||
}
|
}
|
||||||
|
@ -225,14 +176,15 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String removeUserFromVRE() {
|
public String removeUserFromVRE() {
|
||||||
String username = getASLSession().getUsername();
|
String username = context.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
|
String scope = context.getCurrentScope(getThreadLocalRequest());
|
||||||
if (username.compareTo("test.user") == 0)
|
if (username.compareTo("test.user") == 0)
|
||||||
return null;
|
return null;
|
||||||
_log.debug("Going to remove user from the current Group: " + getCurrentGroupID() + ". Username is: " + username);
|
_log.debug("Going to remove user from the current Group: " + getCurrentGroupID() + ". Username is: " + username);
|
||||||
UserManager userM = new LiferayUserManager();
|
UserManager userM = new LiferayUserManager();
|
||||||
try {
|
try {
|
||||||
userM.dismissUserFromGroup(getCurrentGroupID(), userM.getUserId(username));
|
userM.dismissUserFromGroup(getCurrentGroupID(), userM.getUserId(username));
|
||||||
sendUserUnregisteredNotification(username, getASLSession().getScope(),
|
sendUserUnregisteredNotification(username, scope,
|
||||||
PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()),
|
PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()),
|
||||||
PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest()));
|
PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest()));
|
||||||
|
|
||||||
|
@ -249,16 +201,8 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws CurrentGroupRetrievalException
|
* @throws CurrentGroupRetrievalException
|
||||||
*/
|
*/
|
||||||
private long getCurrentGroupID(){
|
private long getCurrentGroupID() {
|
||||||
GroupManager groupM = new LiferayGroupManager();
|
return context.getCurrentGroupId(getThreadLocalRequest());
|
||||||
ASLSession session = getASLSession();
|
|
||||||
_log.debug("The current group NAME is --> " + session.getGroupName());
|
|
||||||
try {
|
|
||||||
return groupM.getGroupId(session.getGroupName());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -9,8 +9,6 @@ import javax.portlet.PortletRequestDispatcher;
|
||||||
import javax.portlet.RenderRequest;
|
import javax.portlet.RenderRequest;
|
||||||
import javax.portlet.RenderResponse;
|
import javax.portlet.RenderResponse;
|
||||||
|
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LoggedinPortlet Portlet Class
|
* LoggedinPortlet Portlet Class
|
||||||
* @author massi
|
* @author massi
|
||||||
|
@ -20,9 +18,6 @@ public class LoggedinPortlet extends GenericPortlet {
|
||||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||||
|
|
||||||
response.setContentType("text/html");
|
response.setContentType("text/html");
|
||||||
|
|
||||||
ScopeHelper.setContext(request);
|
|
||||||
|
|
||||||
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LoggedinPortlet_view.jsp");
|
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LoggedinPortlet_view.jsp");
|
||||||
dispatcher.include(request, response);
|
dispatcher.include(request, response);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> -->
|
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> -->
|
||||||
|
|
||||||
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
||||||
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
|
||||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||||
<!-- Specify the app entry point class. -->
|
<!-- Specify the app entry point class. -->
|
||||||
<entry-point
|
<entry-point
|
||||||
|
|
|
@ -15,16 +15,6 @@
|
||||||
<url-pattern>/gcubeloggedin/LoggedinServiceImpl</url-pattern>
|
<url-pattern>/gcubeloggedin/LoggedinServiceImpl</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>scopeService</servlet-name>
|
|
||||||
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>scopeService</servlet-name>
|
|
||||||
<url-pattern>/gcubeloggedin/scopeService</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
|
|
||||||
<!-- Default page to serve -->
|
<!-- Default page to serve -->
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>GCubeLoggedin.html</welcome-file>
|
<welcome-file>GCubeLoggedin.html</welcome-file>
|
||||||
|
|
Loading…
Reference in New Issue