ported to liferay 6.2
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-widgets@126333 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f9e0fbbb95
commit
9c246a1168
15
pom.xml
15
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
<version>1.9.1-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<name>gCube Widgets Library</name>
|
<name>gCube Widgets Library</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Widgets Library News Widget is a GWT Widget that can be used to uniform the Look and Feel for gCube Portlets using plain GWT.It also provides some out of the box widget to use.
|
gCube Widgets Library News Widget is a GWT Widget that can be used to uniform the Look and Feel for gCube Portlets using plain GWT.It also provides some out of the box widget to use.
|
||||||
|
@ -24,10 +24,9 @@
|
||||||
<!-- Convenience property to set the GWT version -->
|
<!-- Convenience property to set the GWT version -->
|
||||||
<gwtVersion>2.5.1</gwtVersion>
|
<gwtVersion>2.5.1</gwtVersion>
|
||||||
<distroDirectory>distro</distroDirectory>
|
<distroDirectory>distro</distroDirectory>
|
||||||
<!-- GWT needs at least java 1.6 -->
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
<maven.compiler.source>1.6</maven.compiler.source>
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
<maven.compiler.target>1.6</maven.compiler.target>
|
<liferay.version>6.2.5</liferay.version>
|
||||||
|
|
||||||
<!-- Don't let your Mac use a crazy non-standard encoding -->
|
<!-- Don't let your Mac use a crazy non-standard encoding -->
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
@ -55,9 +54,15 @@
|
||||||
<artifactId>aslcore</artifactId>
|
<artifactId>aslcore</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.dvos</groupId>
|
||||||
|
<artifactId>usermanagement-core</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.liferay.portal</groupId>
|
<groupId>com.liferay.portal</groupId>
|
||||||
<artifactId>portal-service</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
|
<version>${liferay.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -8,16 +8,13 @@ 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.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeService;
|
import org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeService;
|
||||||
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
|
||||||
import com.liferay.portal.model.Group;
|
|
||||||
import com.liferay.portal.model.Organization;
|
|
||||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
|
||||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeService {
|
public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeService {
|
||||||
|
@ -32,14 +29,15 @@ public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeServi
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
List<Group> groups = GroupLocalServiceUtil.getGroups(0, GroupLocalServiceUtil.getGroupsCount());
|
GroupManager gm = new LiferayGroupManager();
|
||||||
for (Group g : groups) {
|
List<GCubeGroup> groups = gm.listGroups();
|
||||||
if (g.isOrganization() || g.isCommunity())
|
for (GCubeGroup g : groups) {
|
||||||
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
_log.trace("Comparing " + g.getFriendlyURL() + " with: " +friendlyURL);
|
||||||
setScope(g);
|
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
||||||
return true;
|
setScope(g);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -48,43 +46,14 @@ public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeServi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScope(Group currentGroup) throws Exception {
|
private void setScope(GCubeGroup currentGroup) throws Exception {
|
||||||
String scopeToSet = buildScope(currentGroup);
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
String scopeToSet = gm.getInfrastructureScope(currentGroup.getGroupId());
|
||||||
|
_log.debug("Client scopeToSet " + scopeToSet);
|
||||||
getASLSession().setScope(scopeToSet);
|
getASLSession().setScope(scopeToSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildScope(Group currentGroup) throws Exception {
|
|
||||||
String scopeToSet = "";
|
|
||||||
Organization curOrg = null;
|
|
||||||
// the group MUST BE an Organization
|
|
||||||
if (currentGroup.isOrganization()) {
|
|
||||||
long organizationId = currentGroup.getClassPK();
|
|
||||||
curOrg = OrganizationLocalServiceUtil.getOrganization(organizationId);
|
|
||||||
|
|
||||||
if (curOrg.isRoot()) {
|
|
||||||
scopeToSet = "/"+curOrg.getName();
|
|
||||||
} else if (isVO(curOrg)) {
|
|
||||||
scopeToSet = "/"+curOrg.getParentOrganization().getName()+"/"+curOrg.getName();
|
|
||||||
} else { //is a VRE
|
|
||||||
Organization vo = curOrg.getParentOrganization();
|
|
||||||
scopeToSet = "/"+vo.getParentOrganization().getName()+"/"+vo.getName()+"/"+curOrg.getName();
|
|
||||||
}
|
|
||||||
} else { //
|
|
||||||
scopeToSet = "PORTAL";
|
|
||||||
_log.info("Not an organization, scopeToSet set to PORTAL");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curOrg == null) {
|
|
||||||
String rootVO = getRootConfigFromGCore();
|
|
||||||
_log.info("CONTEXT INITIALIZED CORRECTLY From Client, setting rootvo as scope: " + rootVO);
|
|
||||||
scopeToSet = "/"+rootVO;
|
|
||||||
}
|
|
||||||
return scopeToSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isVO(Organization currentOrg) throws PortalException, SystemException {
|
|
||||||
return (currentOrg.getParentOrganization().getParentOrganization() == null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getRootConfigFromGCore() {
|
public static String getRootConfigFromGCore() {
|
||||||
return PortalContext.getConfiguration().getInfrastructureName();
|
return PortalContext.getConfiguration().getInfrastructureName();
|
||||||
|
|
Loading…
Reference in New Issue