added GRSF Admin role to let user manage grsf records (the manage product property needs to be enabled on its own)
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@141405 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7ccca68c9c
commit
e49f7436e4
|
@ -11,6 +11,7 @@ import javax.servlet.http.HttpSession;
|
|||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes;
|
||||
|
@ -27,6 +28,8 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.GroupBean;
|
|||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -53,6 +56,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
public static String CKANCONNECTORCONTEXT = "CkanConnectorContext";
|
||||
public static String CKANCONNECTORLOGOUT = "CkanConnectorLogout";
|
||||
public static final String GRSF_UPDATER_SERVICE = "GRSFUpdaterEndPoint";
|
||||
private static final String GRSF_ADMIN_ROLE = "GRSF-Admin";
|
||||
private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
|
||||
|
||||
/**
|
||||
|
@ -511,16 +515,25 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
@Override
|
||||
public boolean isManageProductEnabled() {
|
||||
|
||||
logger.info("Checking if the manage product button needs to be shown or not");
|
||||
|
||||
logger.info("Checking if the manage product button needs to be shown or not for the current context/user");
|
||||
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
|
||||
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
|
||||
if(catalogue == null){
|
||||
logger.warn("There is no catalogue instance here..., returning false");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return catalogue.isManageProductEnabled();
|
||||
else{
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
List<GCubeRole> userRoles = new LiferayRoleManager().listRolesByUserAndGroup(pContext.getCurrentUser(getThreadLocalRequest()).getUserId(), pContext.getCurrentGroupId(getThreadLocalRequest()));
|
||||
boolean isGRSFAdminRoleSet = false;
|
||||
for (GCubeRole gCubeRole : userRoles) {
|
||||
if(gCubeRole.getRoleName().equals(GRSF_ADMIN_ROLE)){
|
||||
isGRSFAdminRoleSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return catalogue.isManageProductEnabled() & isGRSFAdminRoleSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue