fetching of users list to mention in comments loaded on demand
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@141288 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d00643fc38
commit
3606f4347b
|
@ -3,6 +3,7 @@
|
|||
date="2016-12-02">
|
||||
<Change>removed asl session</Change>
|
||||
<Change>Increased general performance and bugfixes</Change>
|
||||
<Change>fetching of users list to mention in comments loaded on demand</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.news-feed.2-1-0"
|
||||
date="2016-10-29">
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.HashSet;
|
|||
import org.gcube.portlets.user.gcubewidgets.client.elements.Div;
|
||||
import org.gcube.portlets.user.newsfeed.client.NewsService;
|
||||
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
|
||||
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
|
||||
import org.gcube.portlets.widgets.pickitem.client.dialog.PickItemsDialog;
|
||||
import org.gcube.portlets.widgets.pickitem.client.events.PickedItemEvent;
|
||||
import org.gcube.portlets.widgets.pickitem.client.events.PickedItemEventHandler;
|
||||
|
@ -17,6 +16,8 @@ import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
|
|||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.event.dom.client.FocusEvent;
|
||||
import com.google.gwt.event.dom.client.FocusHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
|
@ -38,7 +39,7 @@ public class SuperPosedTextArea extends TextArea {
|
|||
|
||||
private final HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
private PickItemsDialog pickUserDlg;
|
||||
private PickItemsDialog pickUserDlg = null;
|
||||
private Div highlighterDIV;
|
||||
public final static int ARROW_UP = 38;
|
||||
public final static int ARROW_DOWN = 40;
|
||||
|
@ -59,18 +60,6 @@ public class SuperPosedTextArea extends TextArea {
|
|||
this.highlighterDIV = highlighterDIV;
|
||||
//needed to give unique identifiers to the Area (for the jQuery plugin)
|
||||
areaId = "postTextArea"+Random.nextInt();
|
||||
|
||||
newsService.getOrganizationUsers(new AsyncCallback<ArrayList<ItemBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ItemBean> users) {
|
||||
pickUserDlg = new PickItemsDialog('@', users, eventBus, 460);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
getElement().setAttribute("id", areaId);
|
||||
bind();
|
||||
Timer t = new Timer() {
|
||||
|
@ -84,7 +73,23 @@ public class SuperPosedTextArea extends TextArea {
|
|||
this.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
pickUserDlg.onKeyPress(getCursorPos(), event.getUnicodeCharCode(), getAbsoluteLeft(), getAbsoluteTop()+getOffsetHeight(), getText());
|
||||
if (pickUserDlg != null)
|
||||
pickUserDlg.onKeyPress(getCursorPos(), event.getUnicodeCharCode(), getAbsoluteLeft(), getAbsoluteTop()+getOffsetHeight(), getText());
|
||||
}
|
||||
});
|
||||
this.addFocusHandler(new FocusHandler() {
|
||||
@Override
|
||||
public void onFocus(FocusEvent event) {
|
||||
newsService.getOrganizationUsers(new AsyncCallback<ArrayList<ItemBean>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ItemBean> users) {
|
||||
pickUserDlg = new PickItemsDialog('@', users, eventBus, 460);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue