publish on data catalogue is only allowed to admins and sysadmins

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@130559 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-19 15:56:50 +00:00
parent f2c95d4cdd
commit 8181d4ce19
4 changed files with 25 additions and 25 deletions

View File

@ -696,10 +696,10 @@ public interface GWTWorkspaceService extends RemoteService{
/** /**
* Allows the user to public onto the data catalogue if he has at least * Allows the user to public onto the data catalogue if he has at least
* the role editor somewhere. * the role admin somewhere.
* @return true if he can publish, false otherwise * @return true if he can publish, false otherwise
*/ */
boolean hasUserRoleAdminOrEditor(); boolean hasUserRoleAdminOrSysadmin();
/** /**
* Retrieve the username of the user into the session * Retrieve the username of the user into the session

View File

@ -685,10 +685,10 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Allows the user to public onto the data catalogue if he has at least * Allows the user to public onto the data catalogue if he has at least
* the role editor somewhere. * the role admin somewhere.
* @return true if he can publish, false otherwise * @return true if he can publish, false otherwise
*/ */
void hasUserRoleAdminOrEditor(AsyncCallback<Boolean> callback); void hasUserRoleAdminOrSysadmin(AsyncCallback<Boolean> callback);
/** /**
* Retrieve the username of the user into the session * Retrieve the username of the user into the session

View File

@ -2695,7 +2695,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
String email = username+"@isti.cnr.it"; String email = username+"@isti.cnr.it";
String firstName = "Testing"; String firstName = "Testing";
String lastName = "User"; String lastName = "User";
boolean catalogueEditor = false; boolean publishRights = false;
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) { if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
try { try {
@ -2706,7 +2706,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
email = user.getEmail(); email = user.getEmail();
// check if he has catalogue role // check if he has catalogue role
catalogueEditor = hasUserRoleAdminOrEditor(); publishRights = hasUserRoleAdminOrSysadmin();
}catch (UserManagementSystemException e) { }catch (UserManagementSystemException e) {
workspaceLogger.error("UserManagementSystemException for username: "+username); workspaceLogger.error("UserManagementSystemException for username: "+username);
} }
@ -2715,7 +2715,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
} }
return new UserBean(username, firstName, lastName, email, catalogueEditor); return new UserBean(username, firstName, lastName, email, publishRights);
} }
/** /**
@ -3430,7 +3430,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
@Override @Override
public boolean hasUserRoleAdminOrEditor() { public boolean hasUserRoleAdminOrSysadmin() {
HttpSession httpSession = this.getThreadLocalRequest().getSession(); HttpSession httpSession = this.getThreadLocalRequest().getSession();
ASLSession asl = WsUtil.getAslSession(httpSession); ASLSession asl = WsUtil.getAslSession(httpSession);
String username = asl.getUsername(); String username = asl.getUsername();
@ -3509,11 +3509,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
correspondentRoleToCheck = RolesIntoOrganization.ADMIN; correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
toReturn = true; toReturn = true;
break; break;
}else if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
toReturn = true;
break;
} }
// }else if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){
// correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
// toReturn = true;
// break;
// }
} }
// if the role is member, continue // if the role is member, continue

View File

@ -220,9 +220,8 @@ public class UserUtil {
}else{ }else{
// We need to retrieve orgs in which the user has the roles ADMIN or EDITOR // We need to retrieve orgs in which the user has the roles ADMIN
List<RolesIntoOrganization> rolesToMatch = new ArrayList<RolesIntoOrganization>(); List<RolesIntoOrganization> rolesToMatch = new ArrayList<RolesIntoOrganization>();
rolesToMatch.add(RolesIntoOrganization.EDITOR);
rolesToMatch.add(RolesIntoOrganization.ADMIN); rolesToMatch.add(RolesIntoOrganization.ADMIN);
Map<String, List<RolesIntoOrganization>> orgsAndRoles = ckanUtils.getGroupsAndRolesByUser(username, rolesToMatch); Map<String, List<RolesIntoOrganization>> orgsAndRoles = ckanUtils.getGroupsAndRolesByUser(username, rolesToMatch);
@ -234,7 +233,7 @@ public class UserUtil {
Map.Entry<String, List<RolesIntoOrganization>> entry = (Map.Entry<String, List<RolesIntoOrganization>>) iterator Map.Entry<String, List<RolesIntoOrganization>> entry = (Map.Entry<String, List<RolesIntoOrganization>>) iterator
.next(); .next();
orgsName.add(entry.getKey()); orgsName.add(entry.getKey());
logger.debug("The user has a role ADMIN/EDITOR into org " + entry.getKey()); logger.debug("The user has a role ADMIN into org " + entry.getKey());
} }
} }
session.setAttribute(ckanOrganizationsPublishKey, orgsName); session.setAttribute(ckanOrganizationsPublishKey, orgsName);