added leave group option

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@99899 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 10 years ago
parent 622cabde9a
commit 85dcf48b51

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/gcube-loggedin-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/gcube-loggedin-2.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -19,16 +19,17 @@
<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="com.google.gwt.eclipse.core.GWT_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"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/gcube-loggedin-2.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/gcube-loggedin-2.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -1,5 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/gcube-loggedin/target/gcube-loggedin-2.3.0-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/gcube-loggedin/target/gcube-loggedin-2.4.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -1,9 +1,8 @@
#Wed Apr 10 17:44:47 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

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="${module}">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="session-checker-0.2.5-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="gcube-loggedin"/>
</wb-module>

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

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-loggedin</artifactId>
<packaging>war</packaging>
<version>2.3.0-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>
<name>gCube Loggedin Portlet</name>
<description>
@ -48,19 +48,10 @@
</dependencies>
</dependencyManagement>
<dependencies>
<!-- This dependency is needed and is need on TOP to use GWT UI BInder
without old Xerces version of gCore complaining -->
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
@ -77,11 +68,31 @@
<artifactId>gcube-widgets</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>session-checker</artifactId>
<version>[0.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
@ -151,8 +162,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 -->

@ -14,5 +14,7 @@ public interface LoggedinService extends RemoteService {
VObject getSelectedRE();
String getDefaultCommunityURL();
String removeUserFromVRE();
}

@ -14,4 +14,7 @@ public interface LoggedinServiceAsync {
void getDefaultCommunityURL(AsyncCallback<String> callback);
void removeUserFromVRE(AsyncCallback<String> callback);
}

@ -5,5 +5,7 @@ import com.google.gwt.core.client.GWT;
public class UIConstants {
public static final String LOADING_IMAGE = GWT.getModuleBaseURL() + "../images/loading-bar.gif";
public static final String LOADINGE = GWT.getModuleBaseURL() + "../images/loading.gif";
}

@ -1,7 +1,9 @@
package org.gcube.portlets.user.gcubeloggedin.client.ui;
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
import org.gcube.portlets.user.gcubeloggedin.client.UIConstants;
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
@ -10,6 +12,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
@ -28,33 +31,79 @@ public class AboutView extends Composite {
public AboutView() {
initWidget(uiBinder.createAndBindUi(this));
}
private WarningAlert wa;
@UiField HTMLPanel htmlPanel;
@UiField HTML description;
@UiField Button backButton;
@UiField Button leaveButton;
@UiField
Button button;
@UiField
HTMLPanel htmlPanel;
@UiField
HTML description;
private LoggedinServiceAsync loggedinService;
public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) {
initWidget(uiBinder.createAndBindUi(this));
this.loggedinService = loggedinService;
description.setHTML("<img class=\"imageVRE\" src=\"" + vobj.getImageURL() + "\" />" + vobj.getDescription());
leaveButton.getElement().getStyle().setBackgroundColor("#F2DEDE");
leaveButton.getElement().getStyle().setBorderColor("#EBCCD1");
leaveButton.getElement().getStyle().setColor("#A94440");
wa = new WarningAlert("Are you sure you want to leave this group? "
+ "By leaving this group you will no longer receive updates and loose the workspace folder related to the group.", this);
}
@UiHandler("button")
@UiHandler("backButton")
void onClick(ClickEvent e) {
loggedinService.getDefaultCommunityURL(new AsyncCallback<String>() {
public void onFailure(Throwable arg0) {
Window.alert("We're sorry we couldn't reach the server, try again later ... " + arg0.getMessage());
}
public void onSuccess(String url) {
Window.open(url, "_self", "");
}
}
public void onFailure(Throwable arg0) {
Window.alert("We're sorry we couldn't reach the server, try again later ... " + arg0.getMessage());
}
});
}
@UiHandler("leaveButton")
void onUnsubscribe(ClickEvent e) {
htmlPanel.add(wa);
}
protected void abandonGroup() {
htmlPanel.remove(wa);
final HTML loading = getLoadingHTML();
htmlPanel.add(loading);
loggedinService.removeUserFromVRE(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
if (result != null)
Location.assign(result);
else
CheckSession.showLogoutDialog();
}
@Override
public void onFailure(Throwable caught) {
htmlPanel.remove(loading);
Window.alert("We're sorry we couldn't reach the server, try again later ... " + caught.getMessage());
}
});
}
/**
*
* @return
*/
private HTML getLoadingHTML() {
return new HTML(
"<center><table border='0'>"+
"<tr>"+
"<td>"+
"<img src='" + UIConstants.LOADING_IMAGE + "'>"+
"</td></tr>"+
"</table></center>") ;
}
}

@ -1,8 +1,10 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel ui:field="htmlPanel" styleName="framed">
<g:HTML ui:field="description" styleName="description"></g:HTML>
<g:Button ui:field="button">Change Environment</g:Button>
<g:HTML ui:field="description" styleName="description"></g:HTML>
<g:Button ui:field="backButton">Back</g:Button>
<g:Button ui:field="leaveButton">Leave Group</g:Button>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,47 @@
package org.gcube.portlets.user.gcubeloggedin.client.ui;
import org.gcube.portlets.user.gcubewidgets.client.elements.*;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class WarningAlert extends Composite {
private static WarningAlertUiBinder uiBinder = GWT
.create(WarningAlertUiBinder.class);
interface WarningAlertUiBinder extends UiBinder<Widget, WarningAlert> {
}
@UiField Element errorMessage;
@UiField Span cancelHandler;
@UiField Span confirmHandler;
private AboutView owner;
public WarningAlert(String message, AboutView owner) {
initWidget(uiBinder.createAndBindUi(this));
errorMessage.setInnerText(message);
this.owner = owner;
cancelHandler.setHTML(" Cancel");
confirmHandler.setHTML(" Confirm Leave");
}
@UiHandler("cancelHandler")
void onCloseClick(ClickEvent e) {
this.removeFromParent();
}
@UiHandler("confirmHandler")
void onConfirmClick(ClickEvent e) {
owner.abandonGroup();
}
}

@ -0,0 +1,33 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:m="urn:import:org.gcube.portlets.user.gcubewidgets.client.elements">
<ui:style>
.alert {
border: 1px solid #FAEBCC;
border-radius: 4px;
margin: 20px;
padding: 15px;
background-color: #FCF8D4;
color: #8A6D3F;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 14px;
}
.profile-link {
font-weight: bold;
}
.profile-link:hover {
cursor: pointer;
cursor: hand;
text-decoration: underline;
}
</ui:style>
<g:HTMLPanel styleName="{style.alert}">
<div ui:field="errorMessage"></div>
<m:Span ui:field="confirmHandler" styleName="{style.profile-link}"></m:Span>
<span> or </span>
<m:Span ui:field="cancelHandler" styleName="{style.profile-link}"></m:Span>
</g:HTMLPanel>
</ui:UiBinder>

@ -10,12 +10,22 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
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.vomanagement.usermanagement.GroupManager;
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.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -156,4 +166,58 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
_log.trace("\n getPortalBasicUrl: " +toReturn + "queryString: " + request.getQueryString());
return toReturn;
}
/**
*@return the redirect url if everything goes ok, null otherwise
*/
@Override
public String removeUserFromVRE() {
String username = getASLSession().getUsername();
if (username.compareTo("test.user") == 0)
return null;
_log.debug("Going to remove user from the current Group: " + getCurrentGroupID() + ". Username is: " + username);
UserManager userM = new LiferayUserManager();
try {
userM.dismissUserFromGroup(getCurrentGroupID(), userM.getUserId(username));
removeUserFromHLGroup(username, getASLSession().getScope());
return getPortalBasicUrl();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* Get the current group ID
*
* @return the current group ID or null if an exception is thrown
* @throws Exception
*/
private String getCurrentGroupID(){
ASLSession session = getASLSession();
_log.debug("The current group NAME is --> " + session.getGroupName());
try {
try {
GroupManager groupM = new LiferayGroupManager();
return groupM.getGroupId(session.getGroupName());
} catch (UserManagementSystemException e) {
throw new Exception(e.getMessage(), e.getCause());
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private void removeUserFromHLGroup(String username, String group) {
try {
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager um = HomeLibrary.getHomeManagerFactory().getUserManager();
um.removeUserFromGroup(group, username, getASLSession().getUsername());
} catch (InternalErrorException e) {
_log.error("Failed to get the usermanager from HL. Could not add remove user from the HL group");
} catch (ItemNotFoundException e1) {
}
}
}

@ -7,9 +7,9 @@
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- Other module inherits -->
<!-- set-property name="user.agent" value="gecko" / -->
<set-property name="user.agent" value="gecko1_8,safari" />
<!-- Specify the app entry point class. -->

@ -4,21 +4,18 @@
}
table {
border-collapse: separate !important;
border-spacing: 0;
border-collapse: separate !important;
border-spacing: 0;
}
.framed {
margin: 0 0 10px;
padding: 10px;
margin: 0px 5px;
background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom;
background: #FFF;
border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
border: 1px solid #DBDBDB;
}
@ -28,35 +25,13 @@ table {
margin-right: 5px;
}
/** Example rules used by the template application (remove for your app) */
h1 {
font-size: 2em;
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
text-align: center;
.leaveButton {
border: 1px solid #EBCCD1;
border-radius: 4px;
margin: 20px;
padding: 15px;
background-color: #F2DEDE;
color: #A94440;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 14px;
}
.description {
line-height: 18px;
font-family: Tahoma,Helvetica,Arial,sans-serif;
font-size: 10pt;
color: rgb(51, 51, 51);
text-align: justify;
}
/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
width: 400px;
}
.dialogVPanel {
margin: 5px;
}
.serverResponseLabelError {
color: red;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Loading…
Cancel
Save