From e2d786340cfc08710531294c5faec78b3e9a5d6d Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Wed, 28 Sep 2016 10:30:59 +0000 Subject: [PATCH] minor fixes due to updated widget and ckan util library git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@131960 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 3 -- .../client/view/CkanOrganizationsPanel.java | 1 - .../view/GCubeCkanDataCatalogPanel.java | 38 ++++++++-------- .../gcubeckandatacatalog/server/UserUtil.java | 45 ++++++++++--------- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 336593c..5fe3680 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java index 2ed3c03..5cc4b48 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/CkanOrganizationsPanel.java @@ -13,7 +13,6 @@ import com.github.gwtbootstrap.client.ui.base.UnorderedList; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.VerticalPanel; diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java index cf3569f..ea304b4 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/client/view/GCubeCkanDataCatalogPanel.java @@ -5,7 +5,6 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view; import java.util.List; -import java.util.Map; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCatalog; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources; @@ -78,24 +77,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate { ckanAccessPoint = ckan; instanceCkanFrame(ckan.buildURI()); GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading); - - // RETRIEVE USER'S ORGANIZATIONS - GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback>() { - - @Override - public void onSuccess(List result) { - - ckanOrganizationsPanel.setOrganizations(result); - } - - @Override - public void onFailure(Throwable caught) { - - // an error message will be displayed - ckanOrganizationsPanel.setOrganizations(null); - - } - }); // now perform the other requests GCubeCkanDataCatalog.service.outsidePortal(new AsyncCallback() { @@ -137,6 +118,25 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate { showEditInsertButtons(false); break; } + + // RETRIEVE USER'S ORGANIZATIONS + GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback>() { + + @Override + public void onSuccess(List result) { + + ckanOrganizationsPanel.setOrganizations(result); + } + + @Override + public void onFailure(Throwable caught) { + + // an error message will be displayed + ckanOrganizationsPanel.setOrganizations(null); + + } + }); + } }); } diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java index 7a1a685..60843cb 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/UserUtil.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; import org.gcube.datacatalogue.ckanutillibrary.CKanUtils; -import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization; +import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg; import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.vomanagement.usermanagement.GroupManager; @@ -122,22 +122,22 @@ public class UserUtil { List roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); // get highest role - RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); + RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); // if the role is member, continue - //if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER)) + //if(correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) //continue; - // admin or editor case + // be sure it is so checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); if(toReturn.equals(CkanRole.ADMIN)) continue; - else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesIntoOrganization.ADMIN)) + else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN)) toReturn = CkanRole.ADMIN; else // it was MEMBER - toReturn = mapRolesIntoOrganizationToCkanRole(correspondentRoleToCheck); + toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck); } @@ -156,21 +156,22 @@ public class UserUtil { List roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); // get highest role - RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); + RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); // if the role is member, continue - //if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER)) + //if(correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) //continue; + // be sure it is so checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); if(toReturn.equals(CkanRole.ADMIN)) continue; - else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesIntoOrganization.ADMIN)) + else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN)) toReturn = CkanRole.ADMIN; else - toReturn = mapRolesIntoOrganizationToCkanRole(correspondentRoleToCheck); + toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck); } }else if(groupManager.isVRE(currentGroupId)){ @@ -179,13 +180,13 @@ public class UserUtil { logger.debug("The current scope is the vre " + groupName); // get highest role - RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); - + RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); + // be sure it is so checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId, correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); - toReturn = mapRolesIntoOrganizationToCkanRole(correspondentRoleToCheck); + toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck); } }catch(Exception e){ @@ -212,7 +213,7 @@ public class UserUtil { */ private static void checkIfRoleIsSetInCkanInstance(String username, String gCubeGroupName, long groupId, - RolesIntoOrganization correspondentRoleToCheck, + RolesCkanGroupOrOrg correspondentRoleToCheck, GroupManager groupManager, GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List orgsInWhichAtLeastEditorRole) throws UserManagementSystemException, GroupRetrievalFault { @@ -221,9 +222,9 @@ public class UserUtil { // if there is an instance of ckan in this scope.. if(ckanUtils != null){ - boolean res = ckanUtils.checkRole(username, gCubeGroupName, correspondentRoleToCheck); + boolean res = ckanUtils.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck); - if(res && !correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER)){ + if(res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)){ // get the orgs of the user and retrieve its title and name List ckanOrgs = ckanUtils.getOrganizationsByUser(username); for (CkanOrganization ckanOrganization : ckanOrgs) { @@ -243,19 +244,19 @@ public class UserUtil { * @param roles * @return MEMBER/EDITOR/ADMIN role */ - private static RolesIntoOrganization getLiferayHighestRoleInOrg( + private static RolesCkanGroupOrOrg getLiferayHighestRoleInOrg( List roles) { // NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog for (GCubeRole gCubeRole : roles) { if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName())){ - return RolesIntoOrganization.ADMIN; + return RolesCkanGroupOrOrg.ADMIN; } if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){ - return RolesIntoOrganization.EDITOR; + return RolesCkanGroupOrOrg.EDITOR; } } - return RolesIntoOrganization.MEMBER; + return RolesCkanGroupOrOrg.MEMBER; } /** @@ -263,8 +264,8 @@ public class UserUtil { * @param correspondentRoleToCheck * @return */ - private static CkanRole mapRolesIntoOrganizationToCkanRole( - RolesIntoOrganization correspondentRoleToCheck) { + private static CkanRole mapRolesCkanGroupOrOrgToCkanRole( + RolesCkanGroupOrOrg correspondentRoleToCheck) { switch(correspondentRoleToCheck){ case ADMIN: return CkanRole.ADMIN;