added code to speed up connection on ckan, but it is still slow sometimes (vres and role of the user in that vres are sent)
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@141795 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7053c761b5
commit
c793a06e5b
10
.classpath
10
.classpath
|
@ -22,16 +22,16 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<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-metadata-publisher-widget-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-metadata-publisher-widget/ckan-metadata-publisher-widget">
|
||||
<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>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -23,7 +23,7 @@
|
|||
<distroDirectory>distro</distroDirectory>
|
||||
<!-- GWT needs at least java 1.6 -->
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@ -215,7 +215,7 @@
|
|||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- SA Plugin -->
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
<!-- Inherits widget -->
|
||||
<inherits
|
||||
name='org.gcube.portlets.widgets.ckandatapublisherwidget.CKanMetadataPublisher' />
|
||||
|
||||
<inherits
|
||||
name='org.gcube.datacatalogue.ckanutillibrary.CkanUtilLibrary' />
|
||||
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
|
|
|
@ -2,9 +2,9 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductBean;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -26,12 +26,11 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
|
|||
*
|
||||
* @param pathInfoParameters the path info parameters
|
||||
* @param queryStringParameters the query string parameters
|
||||
* @param currentUrl the current url
|
||||
* @return the c kan connector
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
CkanConnectorAccessPoint getCKanConnector(
|
||||
String pathInfoParameters, String queryStringParameters, String currentUrl) throws Exception;
|
||||
String pathInfoParameters, String queryStringParameters) throws Exception;
|
||||
|
||||
/**
|
||||
* Get the current role in CKAN for this user.
|
||||
|
@ -39,7 +38,7 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
|
|||
* @return the my role
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
CkanRole getMyRole() throws Exception;
|
||||
RolesCkanGroupOrOrg getMyRole() throws Exception;
|
||||
|
||||
/**
|
||||
* Retrieve the list of organizations to whom the user belongs and their urls.
|
||||
|
|
|
@ -5,9 +5,9 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductBean;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -28,19 +28,18 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
* @param callback the callback
|
||||
* @return the my role
|
||||
*/
|
||||
void getMyRole(AsyncCallback<CkanRole> callback);
|
||||
void getMyRole(AsyncCallback<RolesCkanGroupOrOrg> callback);
|
||||
|
||||
/**
|
||||
* Gets the c kan connector.
|
||||
*
|
||||
* @param pathInfoParameters the path info parameters
|
||||
* @param queryStringParameters the query string parameters
|
||||
* @param currentUrl the current url
|
||||
* @param callback the callback
|
||||
* @return the c kan connector
|
||||
*/
|
||||
void getCKanConnector(
|
||||
String pathInfoParameters, String queryStringParameters, String currentUrl,
|
||||
String pathInfoParameters, String queryStringParameters,
|
||||
AsyncCallback<CkanConnectorAccessPoint> callback);
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,11 +8,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GCubeCkanDataCatalog;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.resource.CkanPortletResources;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
|
@ -85,10 +85,9 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
|
||||
String pathParameter = paramsMap.get(GCubeCkanDataCatalog.GET_PATH_PARAMETER); //Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
|
||||
String queryParameter = paramsMap.get(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);// Window.Location.getParameter(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);
|
||||
String currentPortletUrl = Window.Location.getHref().split("\\?")[0];// ignore get parameters
|
||||
|
||||
GCubeCkanDataCatalog.service.getCKanConnector(
|
||||
pathParameter, queryParameter, currentPortletUrl,
|
||||
pathParameter, queryParameter,
|
||||
new AsyncCallback<CkanConnectorAccessPoint>() {
|
||||
|
||||
@Override
|
||||
|
@ -131,7 +130,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
});
|
||||
|
||||
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
|
||||
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<CkanRole>() {
|
||||
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<RolesCkanGroupOrOrg>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -139,7 +138,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(CkanRole result) {
|
||||
public void onSuccess(RolesCkanGroupOrOrg result) {
|
||||
switch (result) {
|
||||
case ADMIN:
|
||||
showEditInsertButtons(true);
|
||||
|
@ -155,44 +154,38 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
break;
|
||||
}
|
||||
|
||||
// retrieve organizations
|
||||
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
|
||||
|
||||
ckanOrganizationsPanel.setOrganizations(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
// an error message will be displayed
|
||||
ckanOrganizationsPanel.setOrganizations(null);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// retrieve groups
|
||||
GCubeCkanDataCatalog.service.getCkanGroupsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
|
||||
|
||||
ckanGroupsPanel.setGroups(result);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
ckanGroupsPanel.setGroups(null);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// retrieve organizations
|
||||
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
|
||||
ckanOrganizationsPanel.setOrganizations(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// an error message will be displayed
|
||||
ckanOrganizationsPanel.setOrganizations(null);
|
||||
}
|
||||
});
|
||||
|
||||
// retrieve groups
|
||||
GCubeCkanDataCatalog.service.getCkanGroupsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
|
||||
ckanGroupsPanel.setGroups(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
ckanGroupsPanel.setGroups(null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,20 +12,20 @@ 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;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.GroupBean;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.manage.GRSFNotificationService;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.BeanUserInOrgGroupRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.GRSFStatus;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductBean;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ex.NoGRSFRecordException;
|
||||
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;
|
||||
|
@ -67,7 +67,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
* @return
|
||||
*/
|
||||
public DataCatalogue getCatalogue(String discoverScope){
|
||||
String currentScope = SessionUtil.getCurrentContext(getThreadLocalRequest(), false);
|
||||
String currentScope = SessionUtil.getCurrentContext(getThreadLocalRequest(), false);
|
||||
DataCatalogue instance = null;
|
||||
try{
|
||||
String scopeInWhichDiscover = discoverScope != null && !discoverScope.isEmpty() ? discoverScope : currentScope;
|
||||
|
@ -83,8 +83,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public CkanConnectorAccessPoint getCKanConnector(String pathInfoParameter, String queryStringParameters, String currentPortletUrl) throws Exception {
|
||||
logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"], current url is " + currentPortletUrl);
|
||||
public CkanConnectorAccessPoint getCKanConnector(String pathInfoParameter, String queryStringParameters) throws Exception {
|
||||
logger.info("getCKanConnector [pathInfo: "+pathInfoParameter + ", query: "+queryStringParameters+"]");
|
||||
try{
|
||||
|
||||
// just get the current scope and set it into ScopeProvider...
|
||||
|
@ -167,8 +167,8 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
// retrieve the list of VREs to whom the user belongs
|
||||
List<String> listVres = UserUtil.getListVreForUser(SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail());
|
||||
ckan.addListOfVREs(listVres);
|
||||
Map<String, String> roleForVre = UserUtil.getVreRoleForUser(SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(), scopePerCurrentUrl);
|
||||
ckan.addListOfVREs(roleForVre);
|
||||
|
||||
return ckan;
|
||||
}
|
||||
|
@ -201,14 +201,14 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getMyRole()
|
||||
*/
|
||||
@Override
|
||||
public CkanRole getMyRole(){
|
||||
public RolesCkanGroupOrOrg getMyRole(){
|
||||
|
||||
// base role as default value
|
||||
CkanRole toReturn = CkanRole.MEMBER;
|
||||
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
|
||||
|
||||
if(!SessionUtil.isIntoPortal()){
|
||||
logger.warn("OUT FROM PORTAL DETECTED RETURNING ROLE: "+CkanRole.ADMIN);
|
||||
toReturn = CkanRole.ADMIN;
|
||||
logger.warn("OUT FROM PORTAL DETECTED RETURNING ROLE: "+RolesCkanGroupOrOrg.ADMIN);
|
||||
toReturn = RolesCkanGroupOrOrg.ADMIN;
|
||||
}else{
|
||||
|
||||
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||
|
@ -225,7 +225,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
// check into session
|
||||
if(httpSession.getAttribute(keyPerScopeRole) != null){
|
||||
|
||||
toReturn = (CkanRole)httpSession.getAttribute(keyPerScopeRole);
|
||||
toReturn = (RolesCkanGroupOrOrg)httpSession.getAttribute(keyPerScopeRole);
|
||||
logger.info("Found user role into session " + toReturn + " and it is going to be returned for user " + username);
|
||||
|
||||
}else{
|
||||
|
@ -245,7 +245,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
// if he is an admin/editor preload:
|
||||
// 1) organizations in which he can publish (the widget will find these info in session)
|
||||
// 2) the list of groups
|
||||
if(toReturn.equals(CkanRole.ADMIN) || toReturn.equals(CkanRole.EDITOR)){
|
||||
if(!toReturn.equals(RolesCkanGroupOrOrg.MEMBER)){
|
||||
httpSession.setAttribute(keyPerScopeOrganizations, orgsInWhichAtLeastEditorRole);
|
||||
httpSession.setAttribute(keyPerScopeGroups, fetchUserGroups(scopePerCurrentUrl, username));
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
if(!SessionUtil.isIntoPortal()){
|
||||
|
||||
logger.warn("You are not into the portal");
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole("testVRE", "/organization/devvre", CkanRole.ADMIN);
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole("testVRE", "/organization/devvre", RolesCkanGroupOrOrg.ADMIN);
|
||||
toReturn.add(org);
|
||||
|
||||
}else{
|
||||
|
@ -437,7 +437,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||
for (CkanOrganization ckanOrganization : organizations) {
|
||||
String role = catalogue.getRoleOfUserInOrganization(username, ckanOrganization.getName(), apiKey);
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole(ckanOrganization.getTitle(), "/organization/" + ckanOrganization.getName(), CkanRole.valueOf(role.toUpperCase()));
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole(ckanOrganization.getTitle(), "/organization/" + ckanOrganization.getName(), RolesCkanGroupOrOrg.valueOf(role.toUpperCase()));
|
||||
toReturn.add(org);
|
||||
}
|
||||
logger.debug("List of organizations to return for user " + username + " is " + toReturn);
|
||||
|
@ -457,7 +457,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
if(!SessionUtil.isIntoPortal()){
|
||||
|
||||
logger.warn("You are not into the portal");
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole("testGroup", "/group/testgroup", CkanRole.MEMBER);
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole("testGroup", "/group/testgroup", RolesCkanGroupOrOrg.MEMBER);
|
||||
toReturn.add(org);
|
||||
|
||||
}else{
|
||||
|
@ -480,7 +480,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||
for (CkanGroup ckanGroup : groups) {
|
||||
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole(ckanGroup.getTitle(), "/group/" + ckanGroup.getName(), CkanRole.valueOf(role.toUpperCase()));
|
||||
BeanUserInOrgGroupRole org = new BeanUserInOrgGroupRole(ckanGroup.getTitle(), "/group/" + ckanGroup.getName(), RolesCkanGroupOrOrg.valueOf(role.toUpperCase()));
|
||||
toReturn.add(org);
|
||||
}
|
||||
logger.debug("List of groups to return for user " + username + " is " + toReturn);
|
||||
|
|
|
@ -8,7 +8,7 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.ApplicationProfileScopePerUrlReader;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
|
@ -16,8 +16,6 @@ import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemExcep
|
|||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
*/
|
||||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
|
@ -40,73 +41,76 @@ public class UserUtil {
|
|||
|
||||
//private static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
||||
private static final Log logger = LogFactoryUtil.getLog(UserUtil.class);
|
||||
private static final String SOBIGDATA_VO_CONTEXT = "/d4science.research-infrastructures.eu/SoBigData";
|
||||
|
||||
/**
|
||||
* Gets the list vre for user.
|
||||
* Gets the list vre for user and the role the user has in them.
|
||||
* retrieve the groups to whom a given user belongs (given the user EMail)
|
||||
*
|
||||
* @param userEMail the user e mail
|
||||
* @return the list vre for user
|
||||
*/
|
||||
public static List<String> getListVreForUser(String userEMail){
|
||||
public static Map<String, String> getVreRoleForUser(String userEMail, String context){
|
||||
|
||||
// Instanciate the manager
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
// Instanciate the manager
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
Map<String, String> mapRoleByGroup = new HashMap<String, String>();
|
||||
GCubeUser user;
|
||||
try {
|
||||
user = userManager.getUserByEmail(userEMail);
|
||||
// retrieve the groups to whom a given user belongs (given the user identifier)
|
||||
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(user.getUserId());
|
||||
logger.info("List of VREs for "+userEMail+ " is/are: "+listOfGroups.size());
|
||||
List<String> vreNames = new ArrayList<String>(listOfGroups.size());
|
||||
|
||||
boolean containsSoBigDataVRE = false;
|
||||
for (GCubeGroup gCubeGroup : listOfGroups) {
|
||||
vreNames.add(gCubeGroup.getGroupName());
|
||||
// filter according the current context: if it is a VO/VRE, we send all the VRES under the VO. If it is the root vo, we send all user's vres.
|
||||
long groupIdContext = groupManager.getGroupIdFromInfrastructureScope(context);
|
||||
GCubeGroup groupContext = groupManager.getGroup(groupIdContext);
|
||||
Iterator<GCubeGroup> iterator = listOfGroups.iterator();
|
||||
if(groupManager.isVRE(groupIdContext)){
|
||||
|
||||
// in case of sobigdata vres (under the SoBigData VO) we need to let users access all the sobigdata organizations in ckan
|
||||
// The VO scope is "/d4science.research-infrastructures.eu/SoBigData"
|
||||
// This code will work only if all the sobigdata organizations are on the same ckan, of course
|
||||
if(!containsSoBigDataVRE)
|
||||
if(gCubeGroup.getParentGroupId() != -1 && SOBIGDATA_VO_CONTEXT.equals(groupManager.getInfrastructureScope(gCubeGroup.getParentGroupId())))
|
||||
containsSoBigDataVRE = true;
|
||||
long parentId = groupContext.getParentGroupId();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
GCubeGroup gCubeGroup = (GCubeGroup) iterator.next();
|
||||
if(gCubeGroup.getParentGroupId() != parentId)
|
||||
iterator.remove();
|
||||
|
||||
}
|
||||
|
||||
}else if(groupManager.isVO(groupIdContext)){
|
||||
|
||||
// get the list of vres
|
||||
while (iterator.hasNext()) {
|
||||
GCubeGroup gCubeGroup = (GCubeGroup) iterator.next();
|
||||
if(groupIdContext != gCubeGroup.getParentGroupId())
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
// only the vres
|
||||
while (iterator.hasNext()) {
|
||||
GCubeGroup gCubeGroup = (GCubeGroup) iterator.next();
|
||||
if(!groupManager.isVRE(gCubeGroup.getGroupId()))
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check if we need to add also sobigdata vres
|
||||
if(containsSoBigDataVRE)
|
||||
addSoBigDataVREs(groupManager, vreNames);
|
||||
// retrieve the role
|
||||
for (GCubeGroup vre: listOfGroups) {
|
||||
|
||||
logger.debug("Returning VRE names: "+vreNames);
|
||||
return vreNames;
|
||||
mapRoleByGroup.put(vre.getGroupName().toLowerCase(),
|
||||
RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), vre.getGroupId()))));
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Returning Map : " + mapRoleByGroup);
|
||||
return mapRoleByGroup;
|
||||
}catch (UserManagementSystemException | UserRetrievalFault | GroupRetrievalFault e) {
|
||||
logger.error("An error occurred during get list of VREs for user: "+userEMail, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch (if needed) the groups' names of the vres under sobigdata
|
||||
* @param groupManager
|
||||
* @param vreNames
|
||||
*/
|
||||
private static void addSoBigDataVREs(GroupManager groupManager, List<String> vreNames){
|
||||
|
||||
try{
|
||||
// fetch all sobigdata contexts
|
||||
GCubeGroup sobigdataVO = groupManager.getGroup(groupManager.getGroupIdFromInfrastructureScope(SOBIGDATA_VO_CONTEXT));
|
||||
List<GCubeGroup> children = sobigdataVO.getChildren();
|
||||
|
||||
for (GCubeGroup gcubeSobigDataChild : children) {
|
||||
vreNames.add(gcubeSobigDataChild.getGroupName());
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve SoBigData vres", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the highest ckan role the user has and also retrieve the list of organizations (scopes) in which the user has the ckan-admin or ckan-editor role
|
||||
|
@ -117,10 +121,10 @@ public class UserUtil {
|
|||
* @param orgsInWhichAdminRole
|
||||
* @param ckanUtils ckanUtils
|
||||
*/
|
||||
public static CkanRole getHighestRole(String currentScope, String username, String groupName, GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole){
|
||||
public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName, GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole){
|
||||
|
||||
// base role as default value
|
||||
CkanRole toReturn = CkanRole.MEMBER;
|
||||
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
|
||||
|
||||
try{
|
||||
|
||||
|
@ -159,12 +163,12 @@ public class UserUtil {
|
|||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
|
||||
if(toReturn.equals(CkanRole.ADMIN))
|
||||
if(toReturn.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
continue;
|
||||
else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
toReturn = CkanRole.ADMIN;
|
||||
else if(toReturn.equals(RolesCkanGroupOrOrg.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
toReturn = RolesCkanGroupOrOrg.ADMIN;
|
||||
else // it was MEMBER
|
||||
toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck);
|
||||
toReturn = correspondentRoleToCheck;
|
||||
|
||||
}
|
||||
|
||||
|
@ -189,12 +193,12 @@ public class UserUtil {
|
|||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
|
||||
if(toReturn.equals(CkanRole.ADMIN))
|
||||
if(toReturn.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
continue;
|
||||
else if(toReturn.equals(CkanRole.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
toReturn = CkanRole.ADMIN;
|
||||
else if(toReturn.equals(RolesCkanGroupOrOrg.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
|
||||
toReturn = RolesCkanGroupOrOrg.ADMIN;
|
||||
else
|
||||
toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck);
|
||||
toReturn = correspondentRoleToCheck;
|
||||
}
|
||||
|
||||
}else if(groupManager.isVRE(currentGroupId)){
|
||||
|
@ -209,12 +213,12 @@ public class UserUtil {
|
|||
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId,
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
|
||||
toReturn = mapRolesCkanGroupOrOrgToCkanRole(correspondentRoleToCheck);
|
||||
toReturn = correspondentRoleToCheck;
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve the role information for this user. Returning member role", e);
|
||||
return CkanRole.MEMBER;
|
||||
return RolesCkanGroupOrOrg.MEMBER;
|
||||
}
|
||||
|
||||
// return the role
|
||||
|
@ -281,21 +285,4 @@ public class UserUtil {
|
|||
}
|
||||
return RolesCkanGroupOrOrg.MEMBER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the correspondent CkanRole
|
||||
* @param correspondentRoleToCheck
|
||||
* @return
|
||||
*/
|
||||
private static CkanRole mapRolesCkanGroupOrOrgToCkanRole(
|
||||
RolesCkanGroupOrOrg correspondentRoleToCheck) {
|
||||
switch(correspondentRoleToCheck){
|
||||
|
||||
case ADMIN: return CkanRole.ADMIN;
|
||||
case EDITOR: return CkanRole.EDITOR;
|
||||
case MEMBER: return CkanRole.MEMBER;
|
||||
default:return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ import java.util.List;
|
|||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.SessionUtil;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.ManageProductBean;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
|
@ -20,8 +19,6 @@ import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
|
||||
/**
|
||||
* A bean that contains the tuple:
|
||||
* <ul>
|
||||
|
@ -17,7 +19,7 @@ public class BeanUserInOrgGroupRole implements Serializable {
|
|||
private static final long serialVersionUID = 9022496195659804838L;
|
||||
private String name;
|
||||
private String url;
|
||||
private CkanRole role;
|
||||
private RolesCkanGroupOrOrg role;
|
||||
|
||||
public BeanUserInOrgGroupRole() {
|
||||
super();
|
||||
|
@ -28,7 +30,7 @@ public class BeanUserInOrgGroupRole implements Serializable {
|
|||
* @param orgUrl
|
||||
* @param role
|
||||
*/
|
||||
public BeanUserInOrgGroupRole(String name, String url, CkanRole role) {
|
||||
public BeanUserInOrgGroupRole(String name, String url, RolesCkanGroupOrOrg role) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
|
@ -51,11 +53,11 @@ public class BeanUserInOrgGroupRole implements Serializable {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public CkanRole getRole() {
|
||||
public RolesCkanGroupOrOrg getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(CkanRole role) {
|
||||
public void setRole(RolesCkanGroupOrOrg role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.GcubeCkanDataCatalogServiceImpl;
|
||||
|
||||
|
@ -30,7 +32,7 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
private String pathInfoParameter;
|
||||
private String queryStringParameters;
|
||||
private String gcubeTokenValue;
|
||||
private List<String> listOfVRes;
|
||||
private Map<String, String> mapVresRoles;
|
||||
private String serverviceContext;
|
||||
|
||||
/**
|
||||
|
@ -94,14 +96,15 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
*
|
||||
* @param listVREs the list vr es
|
||||
*/
|
||||
public void addListOfVREs(List<String> listVREs){
|
||||
this.listOfVRes = listVREs;
|
||||
public void addListOfVREs(Map<String, String> listVREs){
|
||||
this.mapVresRoles = listVREs;
|
||||
String vres = "";
|
||||
if(listVREs!=null && listVREs.size()>0){
|
||||
for (String vre : listVREs) {
|
||||
vres+=vre+",";
|
||||
Set<Entry<String, String>> set = listVREs.entrySet();
|
||||
for (Entry<String, String> entry : set) {
|
||||
vres += entry.getKey().toLowerCase() + "|" + entry.getValue() + ",";
|
||||
}
|
||||
vres = vres.substring(0, vres.length()-1).toLowerCase(); //remove last "," and to lower case. A CKAN Organization ID must be lower case
|
||||
vres = vres.substring(0, vres.length()-1); //remove last "," and to lower case. A CKAN Organization ID must be lower case
|
||||
}
|
||||
|
||||
if(vres.length()>0){
|
||||
|
@ -182,9 +185,9 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
*
|
||||
* @return the listOfVRes
|
||||
*/
|
||||
public List<String> getListOfVRes() {
|
||||
public Map<String, String> getListOfVRes() {
|
||||
|
||||
return listOfVRes;
|
||||
return mapVresRoles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +253,7 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
builder.append(", gcubeTokenValue=");
|
||||
builder.append(gcubeTokenValue);
|
||||
builder.append(", listOfVRes=");
|
||||
builder.append(listOfVRes);
|
||||
builder.append(mapVresRoles);
|
||||
builder.append(", context=");
|
||||
builder.append(serverviceContext);
|
||||
builder.append("]");
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared;
|
||||
|
||||
|
||||
/**
|
||||
* The Ckan role list
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @author Costantino Perciante costantino.perciante@isti.cnr.it
|
||||
* Jun 9, 2016
|
||||
*/
|
||||
public enum CkanRole {
|
||||
MEMBER,
|
||||
EDITOR,
|
||||
ADMIN
|
||||
}
|
Loading…
Reference in New Issue