added check to retrieve groups already stored by the portlet
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@134318 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cf300cf7e3
commit
9e1c853f33
|
@ -579,22 +579,31 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
|||
// get http session
|
||||
HttpSession httpSession = getThreadLocalRequest().getSession();
|
||||
String scope = (String)httpSession.getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
|
||||
DataCatalogue catalogue = getCatalogue(scope);
|
||||
List<CkanGroup> ckanGroups = catalogue.getGroups();
|
||||
|
||||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||
// check if they are in session
|
||||
String keyPerScopeGroups = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_GROUPS_MEMBER, scope);
|
||||
|
||||
// Members/Admin of the group
|
||||
for (CkanGroup ckanGroup : ckanGroups) {
|
||||
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
|
||||
if(httpSession.getAttribute(keyPerScopeGroups) != null){
|
||||
toReturn = (List<GroupBean>)httpSession.getAttribute(keyPerScopeGroups);
|
||||
logger.info("Found user's groups in session " + toReturn);
|
||||
}else{
|
||||
|
||||
if(role == null)
|
||||
continue;
|
||||
DataCatalogue catalogue = getCatalogue(scope);
|
||||
List<CkanGroup> ckanGroups = catalogue.getGroups();
|
||||
|
||||
toReturn.add(new GroupBean(ckanGroup.getTitle(), ckanGroup.getName()));
|
||||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||
|
||||
// Members/Admin of the group
|
||||
for (CkanGroup ckanGroup : ckanGroups) {
|
||||
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
|
||||
if(role == null)
|
||||
continue;
|
||||
|
||||
toReturn.add(new GroupBean(ckanGroup.getTitle(), ckanGroup.getName()));
|
||||
}
|
||||
|
||||
httpSession.setAttribute(keyPerScopeGroups, toReturn);
|
||||
}
|
||||
logger.debug("List of groups to return is " + toReturn);
|
||||
|
||||
}else{
|
||||
logger.warn("Dev mode detected");
|
||||
toReturn = Arrays.asList(new GroupBean("Group title", "aaa"));
|
||||
|
|
Loading…
Reference in New Issue