minor changes due to modified underneath widget and library

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@131995 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-28 14:44:27 +00:00
parent e2d786340c
commit 902df89242
2 changed files with 13 additions and 13 deletions

View File

@ -20,8 +20,8 @@ import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader;
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
import org.gcube.datacatalogue.ckanutillibrary.CkanUtilsFactory;
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
@ -70,18 +70,18 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
* @param discoverScope if you want to the discover the utils library in this specified scope
* @return
*/
public CKanUtils getCkanUtilsObj(String discoverScope){
public DataCatalogue getCatalogue(String discoverScope){
HttpSession httpSession = getThreadLocalRequest().getSession();
ASLSession aslSession = getASLSession(httpSession);
String currentScope = aslSession.getScope();
CKanUtils instance = null;
DataCatalogue instance = null;
try{
String scopeInWhichDiscover = (discoverScope != null && !discoverScope.isEmpty()) ? discoverScope : currentScope;
logger.debug("Discovering ckan utils library into scope " + scopeInWhichDiscover);
instance = CkanUtilsFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
}catch(Exception e){
logger.error("Unable to retrieve ckan utils", e);
@ -136,7 +136,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String pathInfoParameter, String queryStringParameters, String scopePerCurrentUrl) throws Exception {
if(outsidePortal()){
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(getCkanUtilsObj(scopePerCurrentUrl).getCatalogueUrl(),"");
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(getCatalogue(scopePerCurrentUrl).getCatalogueUrl(),"");
return ckan;
}
@ -439,10 +439,10 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
logger.debug("List of organizations was into the session " + toReturn);
}else{
logger.debug("Organizations list wasn't into session, retrieving them");
CKanUtils utils = getCkanUtilsObj(scopePerCurrentUrl);
DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
List<CkanOrganization> organizations = utils.getOrganizationsByUser(username);
for (CkanOrganization ckanOrganization : organizations) {
String role = getCkanUtilsObj(scopePerCurrentUrl).getRoleOfUserInOrganization(username, ckanOrganization.getName(), utils.getApiKeyFromUsername(username));
String role = utils.getRoleOfUserInOrganization(username, ckanOrganization.getName(), utils.getApiKeyFromUsername(username));
BeanUserInOrgRole org = new BeanUserInOrgRole(ckanOrganization.getTitle(), "/organization/" + ckanOrganization.getName(), CkanRole.valueOf(role.toUpperCase()));
toReturn.add(org);
}

View File

@ -6,7 +6,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server;
import java.util.ArrayList;
import java.util.List;
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg;
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
@ -218,15 +218,15 @@ public class UserUtil {
GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole) throws UserManagementSystemException, GroupRetrievalFault {
// with this invocation, we check if the role is present in ckan and if it is not it will be added
CKanUtils ckanUtils = gcubeCkanDataCatalogServiceImpl.getCkanUtilsObj(groupManager.getInfrastructureScope(groupId));
DataCatalogue catalogue = gcubeCkanDataCatalogServiceImpl.getCatalogue(groupManager.getInfrastructureScope(groupId));
// if there is an instance of ckan in this scope..
if(ckanUtils != null){
boolean res = ckanUtils.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck);
if(catalogue != null){
boolean res = catalogue.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck);
if(res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)){
// get the orgs of the user and retrieve its title and name
List<CkanOrganization> ckanOrgs = ckanUtils.getOrganizationsByUser(username);
List<CkanOrganization> ckanOrgs = catalogue.getOrganizationsByUser(username);
for (CkanOrganization ckanOrganization : ckanOrgs) {
if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){
orgsInWhichAtLeastEditorRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));