From 7e21e3407b0ec9f0d788a3218c9c8fd415307d87 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Thu, 21 Jul 2016 20:29:13 +0000 Subject: [PATCH] fix for the root organization git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@130668 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ckandatapublisherwidget/server/utils/Utils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/Utils.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/Utils.java index df72d39..ce08cfc 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/Utils.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/Utils.java @@ -15,6 +15,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.datacatalogue.ckanutillibrary.CKanUtils; +import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsImpl; import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization; import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader; import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType; @@ -248,7 +249,7 @@ public class Utils { // get the orgs of the user List ckanOrgs = ckanUtils.getOrganizationsByUser(username); for (CkanOrganization ckanOrganization : ckanOrgs) { - if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){ + if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase()) || ckanOrganization.getName().equals(CKanUtilsImpl.PRODUCTION_CKAN_ORGNAME_ROOT)){ orgs.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName())); break; } @@ -283,6 +284,10 @@ public class Utils { logger.debug("Organization name is " + organizationName); + // TODO check for the root + if(organizationName.equals(CKanUtilsImpl.PRODUCTION_CKAN_ORGNAME_ROOT)) + return CKanUtilsImpl.PRODUCTION_SCOPE_ROOT; + GroupManager gm = new LiferayGroupManager(); List groups = gm.listGroups(); for (GCubeGroup gCubeGroup : groups) { @@ -300,6 +305,11 @@ public class Utils { public static String getOrganizationNameFromScope(String scope) throws Exception { if(scope != null){ + + // TODO check for the root + if(scope.equals(CKanUtilsImpl.PRODUCTION_SCOPE_ROOT)) + return CKanUtilsImpl.PRODUCTION_CKAN_ORGNAME_ROOT; + GroupManager gm = new LiferayGroupManager(); return gm.getGroup(gm.getGroupIdFromInfrastructureScope(scope)).getGroupName().toLowerCase(); }