From 9c246a1168f0cf66b9023c4b7abb612074576f9c Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 28 Mar 2016 18:32:00 +0000 Subject: [PATCH] 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 --- pom.xml | 15 +++-- .../gcubewidgets/server/ScopeServiceImpl.java | 63 +++++-------------- 2 files changed, 26 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index 4d0afff..169f9d7 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.portlets.user gcube-widgets - 1.9.1-SNAPSHOT + 2.0.0-SNAPSHOT gCube Widgets Library 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 @@ 2.5.1 distro - - 1.6 - 1.6 - + 1.7 + 1.7 + 6.2.5 UTF-8 UTF-8 @@ -55,9 +54,15 @@ aslcore provided + + org.gcube.dvos + usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + com.liferay.portal portal-service + ${liferay.version} provided diff --git a/src/main/java/org/gcube/portlets/user/gcubewidgets/server/ScopeServiceImpl.java b/src/main/java/org/gcube/portlets/user/gcubewidgets/server/ScopeServiceImpl.java index 9956182..42374df 100644 --- a/src/main/java/org/gcube/portlets/user/gcubewidgets/server/ScopeServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/gcubewidgets/server/ScopeServiceImpl.java @@ -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 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 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();