Compare commits
25 Commits
backup_mas
...
master
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/gcube-ckan-datacatalog-2.3.3/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -30,10 +30,10 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/gcube-ckan-datacatalog-2.3.3/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/gcube-ckan-datacatalog-2.3.3/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
>>>>>>>=refs/heads/task_20699
|
||||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-2.3.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-2.3.3
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -74,7 +74,67 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="gcube-ckan-datacatalog-2.3.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="gcube-ckan-datacatalog-2.3.3">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -205,6 +265,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -281,6 +371,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -306,6 +426,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
@ -361,6 +511,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -437,6 +617,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -513,6 +723,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -589,6 +829,36 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -4,6 +4,22 @@
|
|||
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).
|
||||
|
||||
## [v2.3.4] - 2024-10-15
|
||||
|
||||
- Moved to maven-portal-bom 4.0.0{-SNAPSHOT} [#28026]
|
||||
|
||||
## [v2.3.3] - 2024-10-01
|
||||
|
||||
- Patched `Time_Interval` type via widget [#28111]
|
||||
|
||||
## [v2.3.2] - 2024-07-03
|
||||
|
||||
- Includes the `metadata-profile-form-builder-widget` enhancement [#27488]
|
||||
|
||||
## [v2.3.1] - 2024-05-14
|
||||
|
||||
- Includes `ckan-metadata-publisher-widget` with bug fix [#27455] and new feature [#27467]
|
||||
|
||||
## [v2.3.0] - 2024-02-02
|
||||
|
||||
- Supported the Edit facility [#26639]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# gCube D4Science Data Catalog
|
||||
|
||||
The "gCube Data Catalogue" or "Catalogue" is a system that provides facilities for: a) (meta)data publishing and management based on roles; b) vres' products publishing; c) making data products publicly available; d) enriching products of metadata to maximise their potential reuse and making them searchable (via title, tags etc) are based on the CKAN technology. The Catalogue application allows to show all the metadata available in the CKAN instance, as well as publish a new product, retrieve the list of organizations (i.e. Virtual Research Environments) to which the user belongs and his/her already published products. Moreover, the "Catalgoue" application (via configuration) provides moderation of its content enabling the user/s with the Moderator role to approve/reject the products under review.
|
||||
The "gCube Data Catalogue" or "Catalogue" is a system that provides facilities for: a) (meta)data publishing and management based on roles; b) vres' products publishing; c) making data products publicly available; d) enriching products of metadata to maximise their potential reuse and making them searchable (via title, tags etc) are based on the CKAN technology. The Catalogue application allows to show all the metadata available in the CKAN instance, as well as publish a new product, retrieve the list of organizations (i.e. Virtual Research Environments) to which the user belongs and his/her already published products. Moreover, the "Catalogue" application (via configuration) provides moderation of its content enabling the user/s with the Moderator role to approve/reject the products under review.
|
||||
|
||||
## Built With
|
||||
|
||||
|
|
50
pom.xml
50
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.gcubeckan</groupId>
|
||||
<artifactId>gcube-ckan-datacatalog</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.3.0</version>
|
||||
<version>2.3.4</version>
|
||||
<name>gCube CKAN Data Catalog</name>
|
||||
<description>The gCube CKAN Data Catalog portlet</description>
|
||||
|
||||
|
@ -38,31 +38,29 @@
|
|||
|
||||
<profiles>
|
||||
<!-- PROD profile -->
|
||||
<!-- <profile> -->
|
||||
<!-- <id>catalogue-release-profile</id> -->
|
||||
<!-- <activation> -->
|
||||
<!-- <property> -->
|
||||
<!-- <name>Release</name> -->
|
||||
<!-- </property> -->
|
||||
<!-- </activation> -->
|
||||
<!-- <properties> -->
|
||||
<!-- <gcube-portal-bom-version>3.7.0</gcube-portal-bom-version> -->
|
||||
<!-- <storagehub-version-range>[1.0.0,2.0.0-SNAPSHOT)</storagehub-version-range> -->
|
||||
<!-- </properties> -->
|
||||
<!-- </profile> -->
|
||||
<profile>
|
||||
<id>catalogue-release-profile</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>Release</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven-portal-bom-version>4.0.0</maven-portal-bom-version>
|
||||
</properties>
|
||||
</profile>
|
||||
<!-- DEV profile -->
|
||||
<!-- <profile> -->
|
||||
<!-- <id>catalogue-snapshot-profile</id> -->
|
||||
<!-- <activation> -->
|
||||
<!-- <property> -->
|
||||
<!-- <name>!Release</name> -->
|
||||
<!-- </property> -->
|
||||
<!-- </activation> -->
|
||||
<!-- <properties> -->
|
||||
<!-- <gcube-portal-bom-version>3.8.0-SNAPSHOT</gcube-portal-bom-version> -->
|
||||
<!-- <storagehub-version-range>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</storagehub-version-range> -->
|
||||
<!-- </properties> -->
|
||||
<!-- </profile> -->
|
||||
<profile>
|
||||
<id>catalogue-snapshot-profile</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>!Release</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven-portal-bom-version>4.0.0-SNAPSHOT</maven-portal-bom-version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -70,7 +68,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>${gcube-portal-bom-version}</version>
|
||||
<version>${maven-portal-bom-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
<exclusions>
|
||||
|
|
|
@ -27,6 +27,8 @@ public class GCubeCkanDataCatalog implements EntryPoint {
|
|||
public static final String REVERT_QUERY_PARAM = "manage";
|
||||
public static final String GCUBE_CKAN_IFRAME = "gcube-ckan-iframe";
|
||||
|
||||
//public static final String LOGGED_IN_DIV = "logged_in";
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
|
@ -37,4 +39,7 @@ public class GCubeCkanDataCatalog implements EntryPoint {
|
|||
eventManager.setPanel(panel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -199,6 +199,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
managementPanel.visibilityEditItemButton(true);
|
||||
managementPanel.visibilityDeleteItemButton(true);
|
||||
managementPanel.enablePublishItemButton(true);
|
||||
//RootPanel.get(GCubeCkanDataCatalog.LOGGED_IN_DIV).add(new HTML("Logged in as "+RolesCkanGroupOrOrg.ADMIN));
|
||||
break;
|
||||
}
|
||||
case EDITOR: {
|
||||
|
@ -206,6 +207,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
managementPanel.visibilityEditItemButton(true);
|
||||
managementPanel.visibilityDeleteItemButton(true);
|
||||
managementPanel.enablePublishItemButton(true);
|
||||
//RootPanel.get(GCubeCkanDataCatalog.LOGGED_IN_DIV).add(new HTML("Logged in as "+RolesCkanGroupOrOrg.EDITOR));
|
||||
break;
|
||||
}
|
||||
case MEMBER: {
|
||||
|
@ -215,6 +217,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
// not the rights to publish
|
||||
managementPanel.visibilityPublishItemButton(true, true);
|
||||
managementPanel.enablePublishItemButton(false);
|
||||
//RootPanel.get(GCubeCkanDataCatalog.LOGGED_IN_DIV).add(new HTML("Logged in as "+RolesCkanGroupOrOrg.MEMBER));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -31,14 +32,11 @@ import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
|||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class UserUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @author Costantino Perciante costantino.perciante@isti.cnr.it
|
||||
* Jun 21, 2016
|
||||
* @author Costantino Perciante costantino.perciante@isti.cnr.it Jun 21, 2016
|
||||
*/
|
||||
public class UserUtil {
|
||||
|
||||
|
@ -48,15 +46,16 @@ public class UserUtil {
|
|||
private static final String ADD_USER_TO_OTHER_ORG_KEY = "ADD_USER_TO_OTHER_ORG_KEY";
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* 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
|
||||
* @param httpSession
|
||||
* @param pathVre
|
||||
* @return the list vre for user
|
||||
*/
|
||||
public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance, boolean isViewPerVREEnabled,
|
||||
HttpSession httpSession){
|
||||
public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance,
|
||||
boolean isViewPerVREEnabled, HttpSession httpSession) {
|
||||
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
|
@ -66,14 +65,15 @@ public class UserUtil {
|
|||
try {
|
||||
user = userManager.getUserByEmail(userEMail);
|
||||
|
||||
// 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.
|
||||
// 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 currentVRE = groupManager.getGroup(groupIdContext);
|
||||
String localRoleInThisVre = RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(roleManager.listRolesByUserAndGroup(user.getUserId(), currentVRE.getGroupId())));
|
||||
String localRoleInThisVre = RolesCkanGroupOrOrg.convertToCkanCapacity(getLiferayHighestRoleInOrg(
|
||||
roleManager.listRolesByUserAndGroup(user.getUserId(), currentVRE.getGroupId())));
|
||||
|
||||
// ckan-connector will do it
|
||||
mapRoleByGroupSingleVre.put(currentVRE.getGroupName().toLowerCase(),
|
||||
localRoleInThisVre);
|
||||
mapRoleByGroupSingleVre.put(currentVRE.getGroupName().toLowerCase(), localRoleInThisVre);
|
||||
|
||||
// perform further checks
|
||||
if (!isViewPerVREEnabled) {
|
||||
|
@ -81,16 +81,8 @@ public class UserUtil {
|
|||
Boolean alreadyAdded = (Boolean) httpSession.getAttribute(keyPerScope);
|
||||
|
||||
if (alreadyAdded == null || !alreadyAdded) {
|
||||
new AddUserToOrganizationThread(
|
||||
instance,
|
||||
user,
|
||||
groupManager.listGroupsByUser(user.getUserId()),
|
||||
isViewPerVREEnabled,
|
||||
groupIdContext,
|
||||
roleManager,
|
||||
groupManager,
|
||||
localRoleInThisVre).
|
||||
start();
|
||||
new AddUserToOrganizationThread(instance, user, groupManager.listGroupsByUser(user.getUserId()),
|
||||
isViewPerVREEnabled, groupIdContext, roleManager, groupManager, localRoleInThisVre).start();
|
||||
httpSession.setAttribute(keyPerScope, true);
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +94,11 @@ public class UserUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 the current scope
|
||||
* @param username the current username
|
||||
* @param groupName the current groupName
|
||||
|
@ -112,7 +106,9 @@ public class UserUtil {
|
|||
* @param orgsInWhichAdminRole
|
||||
* @param ckanUtils ckanUtils
|
||||
*/
|
||||
public static RolesCkanGroupOrOrg 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
|
||||
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
|
||||
|
@ -137,7 +133,8 @@ public class UserUtil {
|
|||
// 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 + " is " + groups);
|
||||
logger.info("The current scope is the Root Vo, so the list of organizations of the user " + username
|
||||
+ " is " + groups);
|
||||
|
||||
for (GCubeGroup gCubeGroup : groups) {
|
||||
|
||||
|
@ -148,14 +145,16 @@ public class UserUtil {
|
|||
String gCubeGroupName = gCubeGroup.getGroupName();
|
||||
|
||||
// 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
|
||||
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||
|
||||
// be sure it is so
|
||||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl,
|
||||
orgsInWhichAtLeastEditorRole);
|
||||
|
||||
toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck);
|
||||
|
||||
|
@ -163,7 +162,8 @@ public class UserUtil {
|
|||
|
||||
} 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) {
|
||||
|
||||
|
@ -173,20 +173,23 @@ public class UserUtil {
|
|||
|
||||
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
|
||||
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||
|
||||
// be sure it is so
|
||||
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl,
|
||||
orgsInWhichAtLeastEditorRole);
|
||||
|
||||
toReturn = RolesCkanGroupOrOrg.getHigher(toReturn, correspondentRoleToCheck);
|
||||
}
|
||||
|
||||
} 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);
|
||||
|
||||
|
@ -194,8 +197,8 @@ public class UserUtil {
|
|||
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
|
||||
|
||||
// the ckan connector already did the job for us but we need name and title
|
||||
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId,
|
||||
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId, correspondentRoleToCheck,
|
||||
groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
|
||||
|
||||
toReturn = correspondentRoleToCheck;
|
||||
|
||||
|
@ -211,7 +214,9 @@ public class UserUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if the role admin/editor is set or must be set into the ckan instance at this scope
|
||||
* Check if the role admin/editor is set or must be set into the ckan instance
|
||||
* at this scope
|
||||
*
|
||||
* @param username
|
||||
* @param gCubeGroupName
|
||||
* @param groupId
|
||||
|
@ -222,14 +227,16 @@ public class UserUtil {
|
|||
* @throws UserManagementSystemException
|
||||
* @throws GroupRetrievalFault
|
||||
*/
|
||||
private static void checkIfRoleIsSetInCkanInstance(String username,
|
||||
String gCubeGroupName, long groupId,
|
||||
RolesCkanGroupOrOrg correspondentRoleToCheck,
|
||||
GroupManager groupManager,
|
||||
GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole) throws UserManagementSystemException, GroupRetrievalFault {
|
||||
private static void checkIfRoleIsSetInCkanInstance(String username, String gCubeGroupName, long groupId,
|
||||
RolesCkanGroupOrOrg correspondentRoleToCheck, GroupManager groupManager,
|
||||
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
|
||||
DataCatalogue catalogue = gcubeCkanDataCatalogServiceImpl.getCatalogue(groupManager.getInfrastructureScope(groupId));
|
||||
// with this invocation, we check if the role is present in ckan and if it is
|
||||
// not it will be added
|
||||
DataCatalogue catalogue = gcubeCkanDataCatalogServiceImpl
|
||||
.getCatalogue(groupManager.getInfrastructureScope(groupId));
|
||||
|
||||
// if there is an instance of ckan in this scope..
|
||||
if (catalogue != null) {
|
||||
|
@ -238,31 +245,54 @@ public class UserUtil {
|
|||
if (res && !correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) {
|
||||
// get the orgs of the user and retrieve its title and name
|
||||
CkanOrganization organization = catalogue.getOrganizationByName(gCubeGroupName.toLowerCase());
|
||||
orgsInWhichAtLeastEditorRole.add(new OrganizationBean(organization.getTitle(), organization.getName(), true));
|
||||
orgsInWhichAtLeastEditorRole
|
||||
.add(new OrganizationBean(organization.getTitle(), organization.getName(), true));
|
||||
}
|
||||
}
|
||||
else
|
||||
logger.warn("It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(groupId));
|
||||
} else
|
||||
logger.warn(
|
||||
"It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(groupId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ckan role among a list of liferay roles
|
||||
*
|
||||
* @param roles
|
||||
* @return MEMBER/EDITOR/ADMIN role
|
||||
*/
|
||||
public static RolesCkanGroupOrOrg getLiferayHighestRoleInOrg(
|
||||
List<GCubeRole> roles) {
|
||||
public static RolesCkanGroupOrOrg getLiferayHighestRoleInOrg(List<GCubeRole> roles) {
|
||||
logger.info("getLiferayHighestRoleInOrg in: " + roles);
|
||||
|
||||
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||
for (GCubeRole gCubeRole : roles) {
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName())){
|
||||
return RolesCkanGroupOrOrg.ADMIN;
|
||||
RolesCkanGroupOrOrg highestRoleFound = null;
|
||||
|
||||
if(roles==null || roles.isEmpty()) {
|
||||
highestRoleFound = RolesCkanGroupOrOrg.MEMBER;
|
||||
logger.info("getLiferayHighestRoleInOrg returns: " + highestRoleFound +", as default");
|
||||
return highestRoleFound;
|
||||
}
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName())){
|
||||
return RolesCkanGroupOrOrg.EDITOR;
|
||||
}
|
||||
}
|
||||
return RolesCkanGroupOrOrg.MEMBER;
|
||||
|
||||
List<GCubeRole> adminList = roles.stream()
|
||||
.filter(a -> a.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_ADMIN.getRoleName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (adminList.size() > 0) {
|
||||
highestRoleFound = RolesCkanGroupOrOrg.ADMIN;
|
||||
logger.info("getLiferayHighestRoleInOrg returns: " + highestRoleFound);
|
||||
return highestRoleFound;
|
||||
}
|
||||
|
||||
List<GCubeRole> editorList = roles.stream()
|
||||
.filter(a -> a.getRoleName().equalsIgnoreCase(GatewayRolesNames.CATALOGUE_EDITOR.getRoleName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (editorList.size() > 0) {
|
||||
highestRoleFound = RolesCkanGroupOrOrg.EDITOR;
|
||||
logger.info("getLiferayHighestRoleInOrg returns: " + highestRoleFound);
|
||||
return highestRoleFound;
|
||||
}
|
||||
|
||||
highestRoleFound = RolesCkanGroupOrOrg.MEMBER;
|
||||
logger.info("getLiferayHighestRoleInOrg returns: " + highestRoleFound);
|
||||
return highestRoleFound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,3 +180,10 @@ h1 {
|
|||
padding: 10px 5px;
|
||||
background-color: #FAFAFA;
|
||||
}
|
||||
|
||||
.logged_in_label {
|
||||
float: right;
|
||||
margin-right: 20px;
|
||||
font-size: 12px;
|
||||
padding-top: 5px;
|
||||
}
|
|
@ -37,6 +37,7 @@
|
|||
Your web browser must have JavaScript enabled in order for this
|
||||
application to display correctly.</div>
|
||||
</noscript>
|
||||
<div id="logged_in" class="logged_in_label"></div>
|
||||
<div id="gCubeCkanDataCatalog"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -32,5 +32,5 @@
|
|||
<script type="text/javascript"
|
||||
src='<%=request.getContextPath()%>/js/jquery.autosize.js'></script>
|
||||
|
||||
|
||||
<div id="logged_in" class="logged_in_label"></div>
|
||||
<div id="gCubeCkanDataCatalog"></div>
|
Loading…
Reference in New Issue