From 75782b29d0a9d34685dce9aaf41eb23d6dd1eb87 Mon Sep 17 00:00:00 2001 From: "costantino.perciante" Date: Fri, 6 May 2016 16:31:42 +0000 Subject: [PATCH] Removed the Leave Group option (that has been moved into the vre settings portlet a.k.a. Questions) git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@128517 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 5 - .settings/org.eclipse.wst.common.component | 6 - ....eclipse.wst.common.project.facet.core.xml | 1 - .../gcubeloggedin/client/LoggedinService.java | 4 - .../client/LoggedinServiceAsync.java | 4 - .../gcubeloggedin/client/ui/AboutView.java | 58 +--------- .../gcubeloggedin/client/ui/WarningAlert.java | 47 -------- .../client/ui/WarningAlert.ui.xml | 33 ------ .../server/LoggedinServiceImpl.java | 107 +----------------- .../server/portlet/LoggedinPortlet.java | 24 ---- 10 files changed, 3 insertions(+), 286 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.java delete mode 100644 src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.ui.xml diff --git a/.classpath b/.classpath index af02f2e..5b0cb7b 100644 --- a/.classpath +++ b/.classpath @@ -26,11 +26,6 @@ - - - - - diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 7397c4c..dcfb6eb 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -3,12 +3,6 @@ - - uses - - - uses - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index f76155c..3b9d922 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,5 @@ - 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 858ba17..dbdf8d0 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 @@ -10,9 +10,5 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; */ @RemoteServiceRelativePath("LoggedinServiceImpl") public interface LoggedinService extends RemoteService { - VObject getSelectedRE(String portalURL); - - 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 b26cb5d..2992d6f 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 @@ -8,9 +8,5 @@ import com.google.gwt.user.client.rpc.AsyncCallback; * The async counterpart of GreetingService. */ public interface LoggedinServiceAsync { - - void getSelectedRE(String portalURL, AsyncCallback callback); - - void removeUserFromVRE(AsyncCallback callback); } 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 61fb07d..4950aa0 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 @@ -2,25 +2,16 @@ package org.gcube.portlets.user.gcubeloggedin.client.ui; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync; import org.gcube.portlets.user.gcubeloggedin.shared.VObject; -import org.gcube.portlets.user.gcubeloggedin.shared.VREClient; -import org.gcube.portlets.widgets.sessionchecker.client.CheckSession; 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.Image; -import com.github.gwtbootstrap.client.ui.Paragraph; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; 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.Command; -import com.google.gwt.user.client.DOM; -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.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; @@ -40,20 +31,16 @@ public class AboutView extends Composite { public AboutView() { initWidget(uiBinder.createAndBindUi(this)); } - private WarningAlert wa; + private String vreDescription; @UiField Image vreImage; @UiField Heading vreName; @UiField HTML description; @UiField Button seeMore; - @UiField Button leaveButton; @UiField Hero mainPanel; - private LoggedinServiceAsync loggedinService; - public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) { initWidget(uiBinder.createAndBindUi(this)); - this.loggedinService = loggedinService; this.vreDescription = vobj.getDescription(); vreName.setText(vobj.getName()); vreImage.setUrl(vobj.getImageURL()); @@ -66,22 +53,6 @@ public class AboutView extends Composite { seeMore.setVisible(true); seeMore.setText(SEE_MORE); } - - if (vobj instanceof VREClient && !vobj.isMandatory()) { - leaveButton.setVisible(true); - wa = new WarningAlert("Are you sure you want to leave this group? " - + "By leaving this group you will no longer receive updates and lose the workspace folder related to the group.", this); - } - else { - //remove the login button - Scheduler.get().scheduleDeferred(new Command() { - public void execute () { - DOM.getElementById("removable-item-li").removeFromParent(); - } - }); - } - - } boolean open = false; @UiHandler("seeMore") @@ -98,33 +69,6 @@ public class AboutView extends Composite { } } - @UiHandler("leaveButton") - void onUnsubscribe(ClickEvent e) { - mainPanel.add(wa); - } - - - protected void abandonGroup() { - mainPanel.remove(wa); - final Widget loading = getLoadingHTML(); - mainPanel.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) { - mainPanel.remove(loading); - Window.alert("We're sorry we couldn't reach the server, try again later ... " + caught.getMessage()); - } - }); - } - /** * * @return 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 deleted file mode 100644 index 4b9702f..0000000 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.java +++ /dev/null @@ -1,47 +0,0 @@ -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 deleted file mode 100644 index d0905f2..0000000 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/WarningAlert.ui.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - .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 3ef9017..7a8f58c 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 @@ -7,8 +7,6 @@ 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.mailing.EmailNotification; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService; import org.gcube.portlets.user.gcubeloggedin.shared.VObject; @@ -16,8 +14,6 @@ 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; @@ -27,7 +23,6 @@ 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. @@ -54,20 +49,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi 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 */ @@ -139,49 +121,6 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi VREClient vre = new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isMandatory, isRequestBasedGroup); return vre; } - /** - *@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)); - sendUserUnregisteredNotification(username, getASLSession().getScope(), PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()), PortalContext.getConfiguration().getGatewayName()); - return "/"; - } 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 long 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 -1; - } - - protected static ArrayList getAdministratorsEmails(String scope) { LiferayUserManager userManager = new LiferayUserManager(); @@ -192,7 +131,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi _log.debug("Number of groups retrieved: " + allGroups.size()); for (int i = 0; i < allGroups.size(); i++) { long grId = allGroups.get(i).getGroupId(); - String groupScope = groupManager.getScope(grId); + String groupScope = groupManager.getInfrastructureScope(grId); _log.debug("Comparing: " + groupScope + " " + scope); if (groupScope.equals(scope)) { groupId = allGroups.get(i).getGroupId(); @@ -222,46 +161,4 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi } return adminEmailsList; } - - /** - * - * @param scope . - * @param optionalMessage . - */ - public void sendUserUnregisteredNotification(String username, String scope, String portalbasicurl, String gatewayName) { - ArrayList adminEmails = getAdministratorsEmails(scope); - UserManager um = new LiferayUserManager(); - GCubeUser currUser = null; - try { - currUser = um.getUserByUsername(username); - } catch (Exception e) { - - } - String name = currUser.getFirstName(); - String lastname = currUser.getLastName(); - - StringBuffer body = new StringBuffer(); - body.append("

Dear manager of "+ scope +",
this email message was automatically generated by " + portalbasicurl +" to inform you that "); - body.append("

"); - body.append("

"); - body.append(""+name + " " + lastname +" has left 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("

"); - - String[] allMails = new String[adminEmails.size()]; - - adminEmails.toArray(allMails); - - EmailNotification mailToAdmin = new EmailNotification(allMails , "Unregistration from VRE", body.toString(), getThreadLocalRequest()); - - mailToAdmin.sendEmail(); - } - - } diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java index feff5af..ea176a0 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/server/portlet/LoggedinPortlet.java @@ -3,8 +3,6 @@ package org.gcube.portlets.user.gcubeloggedin.server.portlet; import java.io.IOException; -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; import javax.portlet.PortletException; import javax.portlet.PortletRequestDispatcher; @@ -13,10 +11,6 @@ import javax.portlet.RenderResponse; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.model.Organization; - /** * LoggedinPortlet Portlet Class * @author massi @@ -33,22 +27,4 @@ public class LoggedinPortlet extends GenericPortlet { dispatcher.include(request, response); } - - /** - * - * @param currentGroup - * @return true id the organization is a VO - * @throws SystemException . - * @throws PortalException . - */ - private boolean isVO(Organization currentOrg) throws PortalException, SystemException { - return (currentOrg.getParentOrganization().getParentOrganization() == null); - } - - - public void processAction(ActionRequest request, ActionResponse response) - throws PortletException, IOException { - - } - }