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
This commit is contained in:
Costantino Perciante 2016-09-28 10:30:59 +00:00
parent ab7518009d
commit e2d786340c
4 changed files with 42 additions and 45 deletions

View File

@ -4,9 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="ckan-util-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/>
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>

View File

@ -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;

View File

@ -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<List<BeanUserInOrgRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgRole> 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<Boolean>() {
@ -137,6 +118,25 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
showEditInsertButtons(false);
break;
}
// RETRIEVE USER'S ORGANIZATIONS
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgRole> result) {
ckanOrganizationsPanel.setOrganizations(result);
}
@Override
public void onFailure(Throwable caught) {
// an error message will be displayed
ckanOrganizationsPanel.setOrganizations(null);
}
});
}
});
}

View File

@ -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<GCubeRole> 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<GCubeRole> 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<OrganizationBean> 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<CkanOrganization> 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<GCubeRole> 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;