diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java index 59a3f60..4d1674c 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java @@ -615,10 +615,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C /** * The method tries to retrieve the scope related to the organization using the map first, - * if no match is found, it retrieves such information by using liferay. - * - * @param orgName the org name - * @return the scope from org name + * if no match is found, it retrieves such information by using liferay */ private String getScopeFromOrgName(String orgName){ @@ -629,11 +626,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C String toReturn = null; if(isWithinPortal()){ - if(mapOrganizationScope.containsKey(orgName)) + if(mapOrganizationScope.containsKey(orgName)) { toReturn = mapOrganizationScope.get(orgName); - else{ + }else{ try{ String evaluatedScope = GenericUtils.retrieveScopeFromOrganizationName(orgName); + //see #20801 + if(evaluatedScope==null || evaluatedScope.isEmpty()) { + logger.warn("Scope detected for OrganizationName: "+orgName+" is null or empty, skipping filling 'mapOrganizationScope' and returning null"); + return toReturn; + } mapOrganizationScope.put(orgName, evaluatedScope); toReturn = evaluatedScope; }catch(Exception e){ diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/GenericUtils.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/GenericUtils.java index 4f80440..9e8cb19 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/GenericUtils.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/GenericUtils.java @@ -52,13 +52,18 @@ public class GenericUtils { GroupManager gm = new LiferayGroupManager(); List groups = gm.listGroups(); for (GCubeGroup gCubeGroup : groups) { - if(gCubeGroup.getGroupName().equalsIgnoreCase(organizationName)) - return gm.getInfrastructureScope(gCubeGroup.getGroupId()); + if(gCubeGroup.getGroupName().equalsIgnoreCase(organizationName)) { + String theScope = gm.getInfrastructureScope(gCubeGroup.getGroupId()); + logger.info("For organizationName: " + organizationName+" by using "+LiferayGroupManager.class.getSimpleName()+ " got the scope: "+theScope +", returning it"); + return theScope; + } } - + + logger.info("No scope detected for organizationName: " + organizationName +" by using "+LiferayGroupManager.class.getSimpleName()); return null; } + /** * First check to retrieve the token, else create it. *