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
master
Massimiliano Assante 8 years ago
parent b11406092d
commit 01b42ff1ee

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.questions.2-1-0" date="2016-10-03">
<Change>Removed leave group possibility</Change>
<Change>Displays VRE-Managers and Groups in the related VRE</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.questions.2-0-0" date="2016-06-29">
<Change>Added leave group possibility</Change>
</Changeset>

@ -83,6 +83,11 @@
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>

@ -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<GroupDTO> 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++;
}
}

@ -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<GroupDTO> getGroups() {
public ArrayList<GroupDTO> getGroups() {
ArrayList<GroupDTO> 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<GCubeTeam> 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"));
}

Loading…
Cancel
Save