|
|
|
@ -59,10 +59,12 @@ import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.VirtualGroupNotExistingException;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -85,7 +87,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
private static final String REFRESH_TIME = "REFRESH_TIME";
|
|
|
|
|
|
|
|
|
|
private static final String SESSION_ADMIN_ATTR = "SESSION_ADMIN_ATTR";
|
|
|
|
|
|
|
|
|
|
public static final String NF_ORGANIZATIONUSERS_CACHE = "NF_ORGANIZATIONUSERS_CACHE";
|
|
|
|
|
public static final String LAST_RETRIEVED_TIME = "NF_LAST_RETRIEVED_TIME";
|
|
|
|
|
|
|
|
|
|
private String APP_ID;
|
|
|
|
|
|
|
|
|
@ -893,12 +896,41 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public ArrayList<ItemBean> getOrganizationUsers() {
|
|
|
|
|
ArrayList<ItemBean> portalBeans = new ArrayList<ItemBean>();
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
|
|
|
|
|
String currentScope = pContext.getCurrentScope(getThreadLocalRequest());
|
|
|
|
|
ArrayList<ItemBean> toReturn = Utils.getDisplayableItemBeans(currentScope, userName, isWithinPortal());
|
|
|
|
|
_log.trace("Returning " + toReturn.size() + " users for scope " + currentScope);
|
|
|
|
|
return toReturn;
|
|
|
|
|
GCubeUser currentUser = pContext.getCurrentUser(getThreadLocalRequest());
|
|
|
|
|
String userName = currentUser.getUsername();
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
long currentGroupId = pContext.getCurrentGroupId(getThreadLocalRequest());
|
|
|
|
|
Set<GCubeUser> users = new HashSet<>();
|
|
|
|
|
List<GCubeTeam> teams = new ArrayList<>(); //TODO: teams should be added also in root Mode
|
|
|
|
|
try {
|
|
|
|
|
if (gm.isRootVO(currentGroupId)) {
|
|
|
|
|
Set<GCubeGroup> userGroups = gm.listGroupsByUserAndSite(currentUser.getUserId(), getThreadLocalRequest().getServerName());
|
|
|
|
|
for (GCubeGroup userGroup : userGroups) {
|
|
|
|
|
if (gm.isVRE(userGroup.getGroupId())) {
|
|
|
|
|
users.addAll(um.listUsersByGroup(userGroup.getGroupId()));
|
|
|
|
|
_log.debug("getOrganizationUsers added users of group " + userGroup.getGroupId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else { //is a VRE
|
|
|
|
|
users.addAll(um.listUsersByGroup(currentGroupId));
|
|
|
|
|
teams = new LiferayRoleManager().listTeamsByGroup(currentGroupId);
|
|
|
|
|
}
|
|
|
|
|
} catch (UserManagementSystemException | GroupRetrievalFault | UserRetrievalFault | VirtualGroupNotExistingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
for (GCubeUser user : users) {
|
|
|
|
|
if (user.getUsername().compareTo("test.user") != 0 && user.getUsername().compareTo(userName) != 0) { //skip test.user & current user
|
|
|
|
|
portalBeans.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (GCubeTeam gCubeTeam : teams) {
|
|
|
|
|
portalBeans.add(new ItemBean(gCubeTeam.getTeamId()+"", gCubeTeam.getTeamName()));
|
|
|
|
|
}
|
|
|
|
|
_log.trace("Returning " + portalBeans.size() + " users for scope groupid = " + currentGroupId);
|
|
|
|
|
return portalBeans;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|