Compare commits

...

9 Commits

5 changed files with 155 additions and 71 deletions

View File

@ -4,7 +4,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.2.1-SNAPSHOT] - 2024-29-02 ## [v2.2.2] - 2024-05-14
**Bug fixes**
- Incident Catalogue edit is leading to duplicate fields [#27455]
**Enhancement**
- The Catalogue should read the (Liferay) Highest Role in the VRE (i.e. the Organization) [#27467]
## [v2.2.1] - 2024-03-19
**Enhancement** **Enhancement**

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan-metadata-publisher-widget</artifactId> <artifactId>ckan-metadata-publisher-widget</artifactId>
<version>2.2.1-SNAPSHOT</version> <version>2.2.2</version>
<name>gCube Ckan metadata publisher widget</name> <name>gCube Ckan metadata publisher widget</name>
<description> <description>
@ -97,7 +97,7 @@
<dependency> <dependency>
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId> <artifactId>metadata-profile-form-builder-widget</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.data-catalogue</groupId> <groupId>org.gcube.data-catalogue</groupId>
@ -107,7 +107,7 @@
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>uri-resolver-manager</artifactId> <artifactId>uri-resolver-manager</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version> <version>[1.7.0, 2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -154,7 +154,7 @@
<dependency> <dependency>
<groupId>org.gcube.datacatalogue</groupId> <groupId>org.gcube.datacatalogue</groupId>
<artifactId>catalogue-util-library</artifactId> <artifactId>catalogue-util-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0)</version> <version>[1.0.0, 2.0.0)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View File

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
@ -566,6 +567,8 @@ public class UpdateDatasetForm extends Composite {
public void onSuccess( public void onSuccess(
final MetadataProfileBeanForUpdate metadataProfileForUpdate) { final MetadataProfileBeanForUpdate metadataProfileForUpdate) {
setAlertBlock("", null, AlertType.ERROR, false); setAlertBlock("", null, AlertType.ERROR, false);
GWT.log("MetadataProfileBeanForUpdate: "+metadataProfileForUpdate);
List<MetaDataProfileBean> profiles = metadataProfileForUpdate List<MetaDataProfileBean> profiles = metadataProfileForUpdate
.getListProfileBean(); .getListProfileBean();
@ -817,6 +820,7 @@ public class UpdateDatasetForm extends Composite {
GWT.log("There are " + categories.size() + " categories for profile " + bean.getTitle()); GWT.log("There are " + categories.size() + " categories for profile " + bean.getTitle());
//Adding fields without categories
if (categories == null || categories.isEmpty()) { if (categories == null || categories.isEmpty()) {
for (MetadataFieldWrapper field : fields) { for (MetadataFieldWrapper field : fields) {
@ -830,12 +834,41 @@ public class UpdateDatasetForm extends Composite {
} }
} }
} else { } else {
// create the categories, then parse the fields. Fields do not belonging to a
// category are put at the end
//Collecting and showing the fields for categories
for (CategoryWrapper categoryWrapper : categories) {
List<MetadataFieldWrapper> fieldsForThisCategory = fields.stream().filter(f -> f.getOwnerCategory().getId()==categoryWrapper.getId()).collect(Collectors.toList());
CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(),
categoryWrapper.getDescription());
fields.removeAll(fieldsForThisCategory);
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
MetaDataField fieldWidget;
try {
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBusPublisherWidget,
operation);
cp.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
GWT.log("Unable to build such widget", e);
}
}
metadataFieldsPanel.add(cp);
}
// create the categories, then parse the fields. Fields do not belonging to a // create the categories, then parse the fields. Fields do not belonging to a
// category are put at the end // category are put at the end
for (CategoryWrapper categoryWrapper : categories) { /*for (CategoryWrapper categoryWrapper : categories) {
if (categoryWrapper.getFieldsForThisCategory() != null if (categoryWrapper.getFieldsForThisCategory() != null
&& categoryWrapper.getFieldsForThisCategory().size() > 0) { && categoryWrapper.getFieldsForThisCategory().size() > 0) {
CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(), CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(),
categoryWrapper.getDescription()); categoryWrapper.getDescription());
List<MetadataFieldWrapper> fieldsForThisCategory = categoryWrapper List<MetadataFieldWrapper> fieldsForThisCategory = categoryWrapper
@ -856,7 +889,7 @@ public class UpdateDatasetForm extends Composite {
} }
metadataFieldsPanel.add(cp); metadataFieldsPanel.add(cp);
} }
} }*/
// add the remaining one at the end of the categories // add the remaining one at the end of the categories
CategoryPanel extrasCategory = new CategoryPanel("Other", null); CategoryPanel extrasCategory = new CategoryPanel("Other", null);

View File

@ -29,6 +29,7 @@ import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanGroup; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanGroup;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanLicense; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanLicense;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanOrganization; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanOrganization;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanPair;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanTag; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanTag;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager; import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
@ -485,9 +486,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
bean.setResources(list); bean.setResources(list);
} }
logger.debug("extras are #: "+dataset.getExtras().size());
// Settings the dataset type // Settings the dataset type
Map<String, List<String>> extras = dataset.getListExtrasAsHashMap(); Map<String, List<String>> extras = dataset.getListExtrasAsHashMap();
printExtras(dataset);
if (extras != null) { if (extras != null) {
List<String> theDatasetType = extras.get(SYS_TYPE); List<String> theDatasetType = extras.get(SYS_TYPE);
if (theDatasetType != null && theDatasetType.size() > 0) { if (theDatasetType != null && theDatasetType.size() > 0) {
@ -499,6 +503,18 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.info("Returning the bean for dataset title {} and type {}" + bean.getTitle(), bean.getChosenType()); logger.info("Returning the bean for dataset title {} and type {}" + bean.getTitle(), bean.getChosenType());
return bean; return bean;
} }
private void printExtras(CkanDataset dataset) {
if(logger.isDebugEnabled()) {
logger.trace("extras are: "+dataset.getExtras());
if (dataset.getExtras() != null) {
int i = 0;
for (CkanPair cp : dataset.getExtras()) {
logger.debug(++i+") key:" + cp.getKey() + ", value: "+cp.getValue());
}
}
}
}
/** /**
* Discover from the IS the vocabulary of tags for this scope, if present. * Discover from the IS the vocabulary of tags for this scope, if present.
@ -1277,7 +1293,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest()); String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
if (!isWithinPortal()) { if (!isWithinPortal()) {
role = RolesCkanGroupOrOrg.EDITOR; role = RolesCkanGroupOrOrg.ADMIN;
logger.warn("OUT FROM PORTAL SETTING HARD-CODED ROLE " + role); logger.warn("OUT FROM PORTAL SETTING HARD-CODED ROLE " + role);
} else { } else {
String keyPerScopeRole = CatalogueUtilMethods String keyPerScopeRole = CatalogueUtilMethods

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogue; import org.gcube.datacatalogue.utillibrary.server.DataCatalogue;
@ -23,17 +24,18 @@ import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Facilities to check roles into the catalogue. * Facilities to check roles into the catalogue.
*/ */
public class CatalogueRoleManager { public class CatalogueRoleManager {
private static final Logger logger = LoggerFactory.getLogger(CatalogueRoleManager.class); private static final Logger logger = LoggerFactory.getLogger(CatalogueRoleManager.class);
/** /**
* 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 * 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
*
* @param currentScope * @param currentScope
* @param username * @param username
* @param groupName * @param groupName
@ -41,12 +43,14 @@ public class CatalogueRoleManager {
* @param orgsInWhichAtLeastEditorRole * @param orgsInWhichAtLeastEditorRole
* @return the highest among the roles * @return the highest among the roles
*/ */
public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName, CKANPublisherServicesImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole, String gatewayHostname){ public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName,
CKANPublisherServicesImpl gcubeCkanDataCatalogServiceImpl,
List<OrganizationBean> orgsInWhichAtLeastEditorRole, String gatewayHostname) {
// base role as default value // base role as default value
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER; RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
try{ try {
UserManager userManager = new LiferayUserManager(); UserManager userManager = new LiferayUserManager();
RoleManager roleManager = new LiferayRoleManager(); RoleManager roleManager = new LiferayRoleManager();
@ -58,80 +62,89 @@ public class CatalogueRoleManager {
// retrieve current group id // retrieve current group id
long currentGroupId = groupManager.getGroupIdFromInfrastructureScope(currentScope); long currentGroupId = groupManager.getGroupIdFromInfrastructureScope(currentScope);
logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope + "and gateway is "+gatewayHostname); logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope + "and gateway is "
+ gatewayHostname);
Set<GCubeGroup> groups; Set<GCubeGroup> groups;
//Updated by Francesco see Task #12480 // Updated by Francesco see Task #12480
if(gatewayHostname!=null && !gatewayHostname.isEmpty()) { if (gatewayHostname != null && !gatewayHostname.isEmpty()) {
// retrieve the list of organizations for the current user filtered for gateway // retrieve the list of organizations for the current user filtered for gateway
groups = groupManager.listGroupsByUserAndSite(userid, gatewayHostname); groups = groupManager.listGroupsByUserAndSite(userid, gatewayHostname);
for (GCubeGroup gCubeGroup : groups) { for (GCubeGroup gCubeGroup : groups) {
logger.info("Found group (alias VRE) belonging to "+gatewayHostname+": "+gCubeGroup.getGroupName()); logger.info("Found group (alias VRE) belonging to " + gatewayHostname + ": "
+ gCubeGroup.getGroupName());
} }
}else { } else {
// retrieve the flat list of organizations for the current user // retrieve the flat list of organizations for the current user
List<GCubeGroup> listGroups = groupManager.listGroupsByUser(userid); List<GCubeGroup> listGroups = groupManager.listGroupsByUser(userid);
groups = new HashSet<GCubeGroup>(listGroups); groups = new HashSet<GCubeGroup>(listGroups);
} }
//Used by Workspace?
// root (so check into the root, the VOs and the VRES)
if(groupManager.isRootVO(currentGroupId)){
logger.info("The current scope is the Root Vo, so the list of organizations of the user " + username + " has " + groups.size() + " group/s"); // Used by Workspace?
// root (so check into the root, the VOs and the VRES)
if (groupManager.isRootVO(currentGroupId)) {
logger.info("The current scope is the Root Vo, so the list of organizations of the user " + username
+ " has " + groups.size() + " group/s");
for (GCubeGroup gCubeGroup : groups) { for (GCubeGroup gCubeGroup : groups) {
if(!groupManager.isVRE(gCubeGroup.getGroupId())) if (!groupManager.isVRE(gCubeGroup.getGroupId()))
continue; continue;
// get the name of this group // get the name of this group
String gCubeGroupName = gCubeGroup.getGroupName(); String gCubeGroupName = gCubeGroup.getGroupName();
logger.info("Cheking role of the user " + username + " in the VRE " + gCubeGroupName); logger.info("Cheking role of the user " + username + " in the VRE " + gCubeGroupName);
// get the role of the users in this group // get the role of the users in this group
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid,
groupManager.getGroupId(gCubeGroupName));
// get highest role // get highest role
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// be sure it is so // be sure it is so
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl,
orgsInWhichAtLeastEditorRole);
toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck); toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck);
logger.info("Found the role "+toReturn+" for " + username + " in the VRE " + gCubeGroupName); logger.info("Found the role " + toReturn + " for " + username + " in the VRE " + gCubeGroupName);
} }
}else if(groupManager.isVO(currentGroupId)){ } else if (groupManager.isVO(currentGroupId)) {
logger.debug("The list of organizations of the user " + username + " to scan is the one under the VO " + groupName); logger.debug("The list of organizations of the user " + username + " to scan is the one under the VO "
+ groupName);
for (GCubeGroup gCubeGroup : groups) { for (GCubeGroup gCubeGroup : groups) {
// if the gCubeGroup is not under the VO or it is not the VO continue // if the gCubeGroup is not under the VO or it is not the VO continue
if(currentGroupId != gCubeGroup.getParentGroupId() || currentGroupId != gCubeGroup.getGroupId()) if (currentGroupId != gCubeGroup.getParentGroupId() || currentGroupId != gCubeGroup.getGroupId())
continue; continue;
String gCubeGroupName = gCubeGroup.getGroupName(); String gCubeGroupName = gCubeGroup.getGroupName();
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid,
groupManager.getGroupId(gCubeGroupName));
// get highest role // get highest role
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// be sure it is so // be sure it is so
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl,
orgsInWhichAtLeastEditorRole);
toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck); toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck);
} }
}else if(groupManager.isVRE(currentGroupId)){ } else if (groupManager.isVRE(currentGroupId)) {
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username),
groupManager.getGroupId(groupName));
logger.debug("The current scope is the vre " + groupName); logger.debug("The current scope is the vre " + groupName);
@ -139,24 +152,26 @@ public class CatalogueRoleManager {
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// be sure it is so // be sure it is so
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId, checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId, correspondentRoleToCheck,
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole); groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
toReturn = correspondentRoleToCheck; toReturn = correspondentRoleToCheck;
} }
}catch(Exception e){ } catch (Exception e) {
logger.error("Unable to retrieve the role information for this user. Returning member role", e); logger.error("Unable to retrieve the role information for this user. Returning member role", e);
return RolesCkanGroupOrOrg.MEMBER; return RolesCkanGroupOrOrg.MEMBER;
} }
// return the role // return the role
logger.debug("Returning role " + toReturn + " for user " + username); logger.debug("Returning role " + toReturn + " for user " + username);
return toReturn; return toReturn;
} }
/** /**
* Check if the role admin is set or must be set into the ckan instance at this scope * Check if the role admin is set or must be set into the ckan instance at this
* scope
*
* @param username * @param username
* @param gCubeGroupName * @param gCubeGroupName
* @param groupId * @param groupId
@ -167,43 +182,53 @@ public class CatalogueRoleManager {
* @throws UserManagementSystemException * @throws UserManagementSystemException
* @throws GroupRetrievalFault * @throws GroupRetrievalFault
*/ */
private static void checkIfRoleIsSetInCkanInstance(String username, private static void checkIfRoleIsSetInCkanInstance(String username, String gCubeGroupName, long groupId,
String gCubeGroupName, long groupId, RolesCkanGroupOrOrg correspondentRoleToCheck, GroupManager groupManager,
RolesCkanGroupOrOrg correspondentRoleToCheck, CKANPublisherServicesImpl ckanPublisherServicesImpl, List<OrganizationBean> orgs)
GroupManager groupManager, CKANPublisherServicesImpl ckanPublisherServicesImpl, List<OrganizationBean> orgs) throws UserManagementSystemException, GroupRetrievalFault { 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
DataCatalogue catalogue = ckanPublisherServicesImpl.getCatalogue(groupManager.getInfrastructureScope(groupId)); DataCatalogue catalogue = ckanPublisherServicesImpl.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(catalogue != null){ if (catalogue != null) {
boolean res = catalogue.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck); boolean res = catalogue.checkRoleIntoOrganization(username, gCubeGroupName, correspondentRoleToCheck);
if(res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)){ if (res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) {
// get the orgs of the user and retrieve its title and name // get the orgs of the user and retrieve its title and name
CkanOrganization organization = catalogue.getOrganizationByName(gCubeGroupName.toLowerCase()); CkanOrganization organization = catalogue.getOrganizationByName(gCubeGroupName.toLowerCase());
orgs.add(new OrganizationBean(organization.getTitle(), organization.getName(), true)); orgs.add(new OrganizationBean(organization.getTitle(), organization.getName(), true));
} }
}else } else
logger.warn("It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(groupId)); logger.warn(
"It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(groupId));
} }
/** /**
* Retrieve the ckan roles among a list of liferay roles * Retrieve the highest ckan role among a list of liferay roles
*
* @param roles * @param roles
* @return * @return Updated by Francesco M. see #27467
*/ */
private static RolesCkanGroupOrOrg 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 if (roles == null || roles.isEmpty())
for (GCubeRole gCubeRole : roles) { return RolesCkanGroupOrOrg.MEMBER;
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName())){
return RolesCkanGroupOrOrg.ADMIN; Optional<GCubeRole> admin = roles.stream()
} .filter(r -> r.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName()))
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){ .findFirst();
return RolesCkanGroupOrOrg.EDITOR;
} if (admin.isPresent())
} return RolesCkanGroupOrOrg.ADMIN;
Optional<GCubeRole> editor = roles.stream()
.filter(r -> r.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName()))
.findFirst();
if (editor.isPresent())
return RolesCkanGroupOrOrg.EDITOR;
return RolesCkanGroupOrOrg.MEMBER; return RolesCkanGroupOrOrg.MEMBER;
} }
} }