From 01b42ff1ee3399e4a0a99c1dd8ff67a7fd2b6f73 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 3 Oct 2016 15:48:58 +0000 Subject: [PATCH] Displays VRE-Managers and Groups in the related VRE git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/questions@132489 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 4 ++ pom.xml | 5 +++ .../user/questions/client/GroupsPanel.java | 33 +++++++++-------- .../server/QuestionsServiceImpl.java | 37 ++++++++++++++----- 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index b1dcce6..c599812 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + Removed leave group possibility + Displays VRE-Managers and Groups in the related VRE + Added leave group possibility diff --git a/pom.xml b/pom.xml index 3d5c98f..8130c8d 100644 --- a/pom.xml +++ b/pom.xml @@ -83,6 +83,11 @@ org.gcube.common.portal portal-manager + + org.gcube.portal + social-networking-library + provided + org.gcube.dvos usermanagement-core diff --git a/src/main/java/org/gcube/portlets/user/questions/client/GroupsPanel.java b/src/main/java/org/gcube/portlets/user/questions/client/GroupsPanel.java index 34ba1ea..a5bef1e 100644 --- a/src/main/java/org/gcube/portlets/user/questions/client/GroupsPanel.java +++ b/src/main/java/org/gcube/portlets/user/questions/client/GroupsPanel.java @@ -2,15 +2,19 @@ package org.gcube.portlets.user.questions.client; import java.util.ArrayList; +import org.gcube.common.portal.GCubePortalConstants; +import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portlets.user.questions.client.resources.Images; import org.gcube.portlets.user.questions.shared.GroupDTO; import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.constants.BaseIconType; +import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.constants.ButtonType; -import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.resources.ButtonSize; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +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; @@ -19,7 +23,7 @@ import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.VerticalPanel; -public class GroupsPanel extends Composite { +public class GroupsPanel extends Composite { private final QuestionsServiceAsync service = GWT.create(QuestionsService.class); @@ -28,10 +32,6 @@ public class GroupsPanel extends Composite { private VerticalPanel mainPanel = new VerticalPanel(); - - // list of managers - private ArrayList groups; - public GroupsPanel() { super(); initWidget(mainPanel); @@ -42,10 +42,6 @@ public class GroupsPanel extends Composite { Images images = GWT.create(Images.class); loadingImage = new Image(images.membersLoader().getSafeUri()); - - - - // show loaders for the panels showLoader(mainPanel); @@ -56,17 +52,22 @@ public class GroupsPanel extends Composite { mainPanel.clear(); mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); + int i = 0; for (GroupDTO g : groups) { + if (i == 1) + mainPanel.add(new Paragraph("Groups in this VRE:")); Button toAdd = new Button(g.getGroupName()); - + toAdd.setType(ButtonType.LINK); - toAdd.setSize(ButtonSize.LARGE); + toAdd.setSize(ButtonSize.DEFAULT); + toAdd.setHref(g.getViewGroupURL()); mainPanel.add(toAdd); + if (g.isManager()) { - toAdd.setCustomIconStyle("fa fa-user-md"); + toAdd.setSize(ButtonSize.LARGE); } - else - toAdd.setCustomIconStyle("fa fa-users"); + toAdd.setCustomIconStyle("fa fa-users"); + i++; } } diff --git a/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java b/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java index d33de0e..72c22ed 100644 --- a/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/questions/server/QuestionsServiceImpl.java @@ -1,7 +1,6 @@ package org.gcube.portlets.user.questions.server; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -9,14 +8,12 @@ import java.util.Set; import org.apache.commons.codec.binary.Base64; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; - -import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl; +import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portlets.user.questions.client.QuestionsService; import org.gcube.portlets.user.questions.shared.GroupDTO; import org.gcube.vomanagement.usermanagement.GroupManager; -import org.gcube.vomanagement.usermanagement.UserManager; -import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; @@ -39,6 +36,7 @@ import com.liferay.portal.service.UserLocalServiceUtil; public class QuestionsServiceImpl extends RemoteServiceServlet implements QuestionsService { private static final Logger _log = LoggerFactory.getLogger(QuestionsServiceImpl.class); private static final String TEST_USER = "test.user"; + /** * the current ASLSession * @return the session @@ -63,7 +61,7 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi } @Override - public ArrayList getGroups() { + public ArrayList getGroups() { ArrayList toReturn = new ArrayList<>(); ASLSession session = getASLSession(); if (session.getUsername().compareTo(TEST_USER) == 0) { @@ -72,18 +70,37 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi } if (isWithinPortal()) { try { - toReturn.add(new GroupDTO(true, "VRE Managers", "No Desc", "")); + + long vreGroupId = session.getGroupId(); + String vreFriendlyURL = new LiferayGroupManager().getGroup(vreGroupId).getFriendlyURL(); + StringBuffer pageToRedirectURL= new StringBuffer(GCubePortalConstants.PREFIX_GROUP_URL) + .append(vreFriendlyURL) + .append(GCubePortalConstants.GROUP_MEMBERS_FRIENDLY_URL) + .append("?") + .append(new String(Base64.encodeBase64(GCubeSocialNetworking.GROUP_MEMBERS_OID.getBytes()))) + .append("="); + //add the View Managers redirect (and -1 as groupID) + String managerRedirectURL = new String(pageToRedirectURL); + managerRedirectURL += new String(Base64.encodeBase64(("-100").getBytes())); + + toReturn.add(new GroupDTO(true, "View Managers", "No Desc", managerRedirectURL)); List groups = new LiferayRoleManager().listTeamsByGroup(getCurrentGroupID()); for (GCubeTeam g : groups) { - toReturn.add(new GroupDTO(false, g.getTeamName(),g.getDescription(), g.getTeamId()+"")); + String encodedTeamId = new String(Base64.encodeBase64((""+g.getTeamId()).getBytes())); + String teamRedirectURL = pageToRedirectURL+encodedTeamId; + toReturn.add(new GroupDTO( + false, + g.getTeamName(), + g.getDescription(), + teamRedirectURL)); } - } catch (GroupRetrievalFault e) { + } catch (Exception e) { e.printStackTrace(); } } else { - toReturn.add(new GroupDTO(true, "VRE Managers ", "Desc", "URL")); + toReturn.add(new GroupDTO(true, "View Managers ", "Desc", "URL")); for (int i = 0; i < 5; i++) { toReturn.add(new GroupDTO(false, "Group " + i, "Desc", "URL")); }