minor changes due to modified underneath widget and library
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@132000 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9f804215bd
commit
3f113a4ea8
|
@ -44,8 +44,8 @@ import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader;
|
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.CkanUtilsFactory;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes;
|
import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods;
|
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods;
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
|
@ -3452,14 +3452,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
* @param scope if it is null it is evaluated from the session
|
* @param scope if it is null it is evaluated from the session
|
||||||
* @return the ckan utils obj
|
* @return the ckan utils obj
|
||||||
*/
|
*/
|
||||||
public CKanUtils getCkanUtilsObj(String scope){
|
public DataCatalogue getCatalogue(String scope){
|
||||||
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession asl = WsUtil.getAslSession(httpSession);
|
ASLSession asl = WsUtil.getAslSession(httpSession);
|
||||||
CKanUtils instance = null;
|
DataCatalogue instance = null;
|
||||||
try{
|
try{
|
||||||
String scopeInWhichDiscover = scope != null && !scope.isEmpty() ? scope : asl.getScope();
|
String scopeInWhichDiscover = scope != null && !scope.isEmpty() ? scope : asl.getScope();
|
||||||
workspaceLogger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
workspaceLogger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
||||||
instance = CkanUtilsFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
workspaceLogger.error("Unable to retrieve ckan utils", e);
|
workspaceLogger.error("Unable to retrieve ckan utils", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
|
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl;
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||||
|
@ -206,7 +206,7 @@ public class UserUtil {
|
||||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
|
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
|
||||||
|
|
||||||
// get highest role
|
// get highest role
|
||||||
RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||||
|
|
||||||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, correspondentRoleToCheck, workspaceInstance,
|
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, correspondentRoleToCheck, workspaceInstance,
|
||||||
groupManager, gCubeGroup.getGroupId(), orgsInWhichAtLeastEditorRole);
|
groupManager, gCubeGroup.getGroupId(), orgsInWhichAtLeastEditorRole);
|
||||||
|
@ -227,7 +227,7 @@ public class UserUtil {
|
||||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
|
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
|
||||||
|
|
||||||
// get highest role
|
// get highest role
|
||||||
RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||||
|
|
||||||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, correspondentRoleToCheck, workspaceInstance,
|
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, correspondentRoleToCheck, workspaceInstance,
|
||||||
groupManager, gCubeGroup.getGroupId(), orgsInWhichAtLeastEditorRole);
|
groupManager, gCubeGroup.getGroupId(), orgsInWhichAtLeastEditorRole);
|
||||||
|
@ -239,7 +239,7 @@ public class UserUtil {
|
||||||
logger.debug("The current scope is the vre " + groupName);
|
logger.debug("The current scope is the vre " + groupName);
|
||||||
|
|
||||||
// get highest role
|
// get highest role
|
||||||
RolesIntoOrganization correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||||
|
|
||||||
checkIfRoleIsSetInCkanInstance(username, groupName, correspondentRoleToCheck, workspaceInstance,
|
checkIfRoleIsSetInCkanInstance(username, groupName, correspondentRoleToCheck, workspaceInstance,
|
||||||
groupManager, currentGroupId, orgsInWhichAtLeastEditorRole);
|
groupManager, currentGroupId, orgsInWhichAtLeastEditorRole);
|
||||||
|
@ -273,20 +273,20 @@ public class UserUtil {
|
||||||
*/
|
*/
|
||||||
private static void checkIfRoleIsSetInCkanInstance(String username,
|
private static void checkIfRoleIsSetInCkanInstance(String username,
|
||||||
String gCubeGroupName,
|
String gCubeGroupName,
|
||||||
RolesIntoOrganization correspondentRoleToCheck,
|
RolesCkanGroupOrOrg correspondentRoleToCheck,
|
||||||
GWTWorkspaceServiceImpl workspaceInstance,
|
GWTWorkspaceServiceImpl workspaceInstance,
|
||||||
GroupManager groupManager, long groupId, List<OrganizationBean> orgsInWhichAdminRole) throws UserManagementSystemException, GroupRetrievalFault {
|
GroupManager groupManager, long groupId, List<OrganizationBean> orgsInWhichAdminRole) throws UserManagementSystemException, GroupRetrievalFault {
|
||||||
|
|
||||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
||||||
CKanUtils ckanUtils = workspaceInstance.getCkanUtilsObj(groupManager.getInfrastructureScope(groupId));
|
DataCatalogue catalogue = workspaceInstance.getCatalogue(groupManager.getInfrastructureScope(groupId));
|
||||||
|
|
||||||
// if there is an instance of ckan in this scope..
|
// if there is an instance of ckan in this scope..
|
||||||
if(ckanUtils != null){
|
if(catalogue != null){
|
||||||
boolean res = ckanUtils.checkRole(username, gCubeGroupName, correspondentRoleToCheck);
|
boolean res = catalogue.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck);
|
||||||
|
|
||||||
if(res && !correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER)){
|
if(res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)){
|
||||||
// get the orgs of the user
|
// get the orgs of the user
|
||||||
List<CkanOrganization> ckanOrgs = ckanUtils.getOrganizationsByUser(username);
|
List<CkanOrganization> ckanOrgs = catalogue.getOrganizationsByUser(username);
|
||||||
for (CkanOrganization ckanOrganization : ckanOrgs) {
|
for (CkanOrganization ckanOrganization : ckanOrgs) {
|
||||||
if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){//|| ckanOrganization.getName().equals(CKanUtilsImpl.PRODUCTION_CKAN_ORGNAME_ROOT)){
|
if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){//|| ckanOrganization.getName().equals(CKanUtilsImpl.PRODUCTION_CKAN_ORGNAME_ROOT)){
|
||||||
orgsInWhichAdminRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));
|
orgsInWhichAdminRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));
|
||||||
|
@ -305,18 +305,18 @@ public class UserUtil {
|
||||||
* @param roles
|
* @param roles
|
||||||
* @return MEMBER/EDITOR/ADMIN role
|
* @return MEMBER/EDITOR/ADMIN role
|
||||||
*/
|
*/
|
||||||
private static RolesIntoOrganization getLiferayHighestRoleInOrg(
|
private static RolesCkanGroupOrOrg getLiferayHighestRoleInOrg(
|
||||||
List<GCubeRole> roles) {
|
List<GCubeRole> roles) {
|
||||||
|
|
||||||
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||||
for (GCubeRole gCubeRole : roles) {
|
for (GCubeRole gCubeRole : roles) {
|
||||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName())){
|
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName())){
|
||||||
return RolesIntoOrganization.ADMIN;
|
return RolesCkanGroupOrOrg.ADMIN;
|
||||||
}
|
}
|
||||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){
|
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){
|
||||||
return RolesIntoOrganization.EDITOR;
|
return RolesCkanGroupOrOrg.EDITOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RolesIntoOrganization.MEMBER;
|
return RolesCkanGroupOrOrg.MEMBER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue