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:
Massimiliano Assante 2016-03-28 18:32:00 +00:00
parent f9e0fbbb95
commit 9c246a1168
2 changed files with 26 additions and 52 deletions

15
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<version>1.9.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>gCube Widgets Library</name>
<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.
@ -24,10 +24,9 @@
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.5.1</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<liferay.version>6.2.5</liferay.version>
<!-- Don't let your Mac use a crazy non-standard encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -55,9 +54,15 @@
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -8,16 +8,13 @@ import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.portal.PortalContext;
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.LoggerFactory;
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")
public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeService {
@ -32,14 +29,15 @@ public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeServi
return true;
else {
try {
List<Group> groups = GroupLocalServiceUtil.getGroups(0, GroupLocalServiceUtil.getGroupsCount());
for (Group g : groups) {
if (g.isOrganization() || g.isCommunity())
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
setScope(g);
return true;
}
GroupManager gm = new LiferayGroupManager();
List<GCubeGroup> groups = gm.listGroups();
for (GCubeGroup g : groups) {
_log.trace("Comparing " + g.getFriendlyURL() + " with: " +friendlyURL);
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
setScope(g);
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
@ -48,43 +46,14 @@ public class ScopeServiceImpl extends RemoteServiceServlet implements ScopeServi
return false;
}
private void setScope(Group currentGroup) throws Exception {
String scopeToSet = buildScope(currentGroup);
private void setScope(GCubeGroup currentGroup) throws Exception {
GroupManager gm = new LiferayGroupManager();
String scopeToSet = gm.getInfrastructureScope(currentGroup.getGroupId());
_log.debug("Client scopeToSet " + 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() {
return PortalContext.getConfiguration().getInfrastructureName();