the list of the Sites now depends on the portal (virtualhost)

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/liferay62-plugins/social-dockbar-hook@144285 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2017-02-24 16:32:50 +00:00
parent a590257bb1
commit e24e5ee745
4 changed files with 39 additions and 21 deletions

View File

@ -11,13 +11,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -1,6 +1,6 @@
name=social-dockbar-hook
module-group-id=liferay
module-incremental-version=3
module-incremental-version=4
tags=
short-description=
change-log=

View File

@ -175,6 +175,7 @@ if (themeDisplay.isSignedIn()) {
});
</script>
<!-- When desktop -->
<div id="custom-dockbar-view-container">
<div class="collapse nav-collapse">
<ul class="nav nav-add-controls">
<li class="dockbar-item"><a class=""
@ -241,5 +242,6 @@ if (themeDisplay.isSignedIn()) {
</span>
</c:otherwise>
</c:choose>
</div>
<!-- End When phone or tablet -->
<% } %>

View File

@ -16,6 +16,10 @@
<%@page import="java.util.ArrayList"%>
<%@ include file="/html/taglib/init.jsp"%>
<%@ page import="org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager" %>
<%@ page import="org.gcube.vomanagement.usermanagement.model.VirtualGroup" %>
<%@ page import="org.gcube.vomanagement.usermanagement.util.ManagementUtils" %>
<%@ page import="java.util.Collections" %>
<%
String[] classNames = (String[]) request
@ -31,31 +35,49 @@
if (max <= 0) {
max = PropsValues.MY_SITES_MAX_ELEMENTS;
}
/* EDIT For Custom Go To Panel */
Set<Group> customSiteGroups = new HashSet<Group>();
List<Group> mySiteGroups = new ArrayList<Group>();
boolean isAdmin = false, isSiteAdmin = false;
//get the list of VREs available on this virtual host (customSiteGroups)
String serverName = request.getServerName();
LiferayGroupManager gm = new LiferayGroupManager();
List<VirtualGroup> currSiteVirtualGroups = gm.getVirtualGroups(ManagementUtils.getSiteGroupIdFromServletRequest(serverName));
for (Group userGroup : user.getMySiteGroups(classNames, includeControlPanel, max)) {
if (userGroup.getChildren(true).isEmpty() && userGroup.getParentGroup() != null && (userGroup.getFriendlyURL().compareTo("/data-e-infrastructure-gateway") != 0) ) {
for (VirtualGroup currSiteVGroup : currSiteVirtualGroups) {
List<VirtualGroup> vGroups = gm.getVirtualGroups(userGroup.getGroupId());
for (VirtualGroup virtualGroup : vGroups) {
if (virtualGroup.getName().compareTo(currSiteVGroup.getName()) == 0) {
customSiteGroups.add(userGroup);
}
}
}
}
}
//if the user is administrator we add the VOs and Root VO
for (Role role : user.getRoles()) {
if ("Administrator".equals(role.getName())) {
isAdmin = true;
mySiteGroups = user.getMySiteGroups(classNames,
includeControlPanel, max);
for (Group site: user.getMySiteGroups(classNames, includeControlPanel, max)) {
//if is not a VRE
if (! site.getChildren(true).isEmpty() && (site.getFriendlyURL().compareTo("/data-e-infrastructure-gateway") != 0) )
customSiteGroups.add(site);
}
break;
}
}
//copy the set into the expected list
mySiteGroups.addAll(customSiteGroups);
Collections.sort(mySiteGroups);
if (! isAdmin) {
try {
for (Group group : user.getMySiteGroups(classNames, includeControlPanel, max)) {
if (group.getChildren(true).isEmpty() && (group.getFriendlyURL().compareTo("/data-e-infrastructure-gateway") != 0) ) {
mySiteGroups.add(group);
}
}
} catch (SystemException e1) {
e1.printStackTrace();
}
}
/*End Edit */
%>
<c:if test="<%=!mySiteGroups.isEmpty()%>">