|
|
@ -1,7 +1,6 @@
|
|
|
|
package org.gcube.portlets.user.questions.server;
|
|
|
|
package org.gcube.portlets.user.questions.server;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
@ -9,14 +8,12 @@ import java.util.Set;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
import org.gcube.application.framework.core.session.SessionManager;
|
|
|
|
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
|
|
|
|
|
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
|
|
|
import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl;
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.questions.client.QuestionsService;
|
|
|
|
import org.gcube.portlets.user.questions.client.QuestionsService;
|
|
|
|
import org.gcube.portlets.user.questions.shared.GroupDTO;
|
|
|
|
import org.gcube.portlets.user.questions.shared.GroupDTO;
|
|
|
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
|
|
|
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.LiferayGroupManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
@ -39,6 +36,7 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
public class QuestionsServiceImpl extends RemoteServiceServlet implements QuestionsService {
|
|
|
|
public class QuestionsServiceImpl extends RemoteServiceServlet implements QuestionsService {
|
|
|
|
private static final Logger _log = LoggerFactory.getLogger(QuestionsServiceImpl.class);
|
|
|
|
private static final Logger _log = LoggerFactory.getLogger(QuestionsServiceImpl.class);
|
|
|
|
private static final String TEST_USER = "test.user";
|
|
|
|
private static final String TEST_USER = "test.user";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* the current ASLSession
|
|
|
|
* the current ASLSession
|
|
|
|
* @return the session
|
|
|
|
* @return the session
|
|
|
@ -63,7 +61,7 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ArrayList<GroupDTO> getGroups() {
|
|
|
|
public ArrayList<GroupDTO> getGroups() {
|
|
|
|
ArrayList<GroupDTO> toReturn = new ArrayList<>();
|
|
|
|
ArrayList<GroupDTO> toReturn = new ArrayList<>();
|
|
|
|
ASLSession session = getASLSession();
|
|
|
|
ASLSession session = getASLSession();
|
|
|
|
if (session.getUsername().compareTo(TEST_USER) == 0) {
|
|
|
|
if (session.getUsername().compareTo(TEST_USER) == 0) {
|
|
|
@ -72,18 +70,37 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isWithinPortal()) {
|
|
|
|
if (isWithinPortal()) {
|
|
|
|
try {
|
|
|
|
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());
|
|
|
|
List<GCubeTeam> groups = new LiferayRoleManager().listTeamsByGroup(getCurrentGroupID());
|
|
|
|
for (GCubeTeam g : groups) {
|
|
|
|
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();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} 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++) {
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
toReturn.add(new GroupDTO(false, "Group " + i, "Desc", "URL"));
|
|
|
|
toReturn.add(new GroupDTO(false, "Group " + i, "Desc", "URL"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|