diff --git a/.classpath b/.classpath index 9e79e11..1100482 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -19,16 +19,17 @@ - - - - - - + + + + + + + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index 9df02cd..9b49b11 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -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 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 36c3062..443e085 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 9d20a86..8b60e94 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,9 +1,11 @@ - - + + + uses + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 7895606..4045d87 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -3,5 +3,5 @@ - + diff --git a/pom.xml b/pom.xml index e89239f..9b4d23b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user gcube-loggedin war - 2.3.0-SNAPSHOT + 2.4.0-SNAPSHOT gCube Loggedin Portlet @@ -48,19 +48,10 @@ - - - - xerces - xercesImpl - 2.9.1 - provided - com.google.gwt gwt-user - provided + provided com.google.gwt @@ -77,11 +68,31 @@ gcube-widgets provided + + org.gcube.portlets.widgets + session-checker + [0.2.0-SNAPSHOT, 2.0.0-SNAPSHOT) + org.gcube.applicationsupportlayer aslcore provided + + org.gcube.dvos + usermanagement-core + provided + + + org.gcube.common + home-library-jcr + provided + + + org.gcube.common + home-library + provided + com.liferay.portal portal-service @@ -151,8 +162,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java index 3f33b03..796a8d9 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java @@ -14,5 +14,7 @@ public interface LoggedinService extends RemoteService { VObject getSelectedRE(); String getDefaultCommunityURL(); + + String removeUserFromVRE(); } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java index 8e9daff..3d3006f 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java @@ -14,4 +14,7 @@ public interface LoggedinServiceAsync { void getDefaultCommunityURL(AsyncCallback callback); + + + void removeUserFromVRE(AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java index 710c586..438707e 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/UIConstants.java @@ -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"; } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java index a575fd6..13b377a 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java @@ -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("" + 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() { - 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() { + @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( + "
"+ + ""+ + ""+ + "
"+ + ""+ + "
") ; + } } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml index 8ade0bd..2b55a08 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml @@ -1,8 +1,10 @@ + - - Change Environment + + Back + Leave Group \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.java new file mode 100644 index 0000000..4b9702f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.java @@ -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 { + } + + @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(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.ui.xml b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.ui.xml new file mode 100644 index 0000000..d0905f2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.ui.xml @@ -0,0 +1,33 @@ + + + + .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; + } + + +
+ + or + +
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java index 4aefeb7..f13f3a0 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/LoggedinServiceImpl.java @@ -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) { + + } + } + } diff --git a/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml b/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml index b76ab5a..733b601 100644 --- a/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/gcubeloggedin/GCubeLoggedin.gwt.xml @@ -7,9 +7,9 @@ - + - + diff --git a/src/main/webapp/GCubeLoggedin.css b/src/main/webapp/GCubeLoggedin.css index c9b7b05..9c790d6 100644 --- a/src/main/webapp/GCubeLoggedin.css +++ b/src/main/webapp/GCubeLoggedin.css @@ -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; -} - - - diff --git a/src/main/webapp/images/loading.gif b/src/main/webapp/images/loading.gif new file mode 100644 index 0000000..8ed30cb Binary files /dev/null and b/src/main/webapp/images/loading.gif differ