From f53c8d0c3b8684bb21e4e56cf061c0250c06d180 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Wed, 12 Jun 2019 10:15:07 +0000 Subject: [PATCH] Data Catalogue Publishing widget: filter the VREs for the working gateway git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@179794 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 6 +++--- distro/changelog.xml | 12 +++++++++--- pom.xml | 2 +- .../client/ui/form/MetaDataField.java | 5 ++++- .../client/ui/form/MetaDataField.ui.xml | 8 ++++---- .../server/CKANPublisherServicesImpl.java | 8 ++++++-- .../server/utils/CatalogueRoleManager.java | 12 ++++++++++-- 7 files changed, 37 insertions(+), 16 deletions(-) diff --git a/.classpath b/.classpath index ce7b7f2..5347206 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -18,7 +18,7 @@ - + @@ -34,5 +34,5 @@ - + diff --git a/distro/changelog.xml b/distro/changelog.xml index 89f8b54..69324f5 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -2,7 +2,11 @@ - [Feature #11331] Field repeatability: support for catalogue widget + [Feature #11331] Field repeatability: support for catalogue + widget + + [Task #12480] Data Catalogue Publishing widget: filter the VREs for the working gateway + widget [Bug #12914] The form to add/choice the resources to - publishing remains frozen + publishing remains frozen + [Incident #12563] Error when trying to publish the content of - a workspace folder into the catalogue + a workspace folder into the catalogue + 2.7.0 - ${project.build.directory}/${project.build.finalName} + distro UTF-8 UTF-8 diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java index 5984527..69015ca 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java @@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.Metada import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Label; +import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -95,8 +96,10 @@ public class MetaDataField extends Composite { //The field is repeatable if(field.getMaxOccurs()>1) { repeatabilityLabel.setVisible(true); + repeatabilityLabel.setType(LabelType.INFO); + addFieldButton.setTitle("Add another "+field.getFieldName()); + removeFieldButton.setTitle("Remove latest "+field.getFieldName()); // String maxTxt = field.getMaxOccurs()==Integer.MAX_VALUE?"":"(max occurs declared are "+field.getMaxOccurs()+" times)"; - repeatabilityLabel.setText("Repeat "+field.getFieldName()); } } diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml index 7590e1b..2895687 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml @@ -3,8 +3,8 @@ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> - .important { - font-weight: bold; + .margin-left-max-occurrs { + padding-left: 28px; } @@ -12,8 +12,8 @@ ui:field="panelMetaDataFieldsSkeleton" width="100%"> - - Repeatability + + Repeatable field orgsInWhichAtLeastEditorRole = new ArrayList(); - role = CatalogueRoleManager.getHighestRole(scopePerCurrentUrl, username, groupName, this, orgsInWhichAtLeastEditorRole); + String gatewayURL = GenericUtils.getCurrentClientUrl(getThreadLocalRequest()); + logger.info("The Gateway URL is: "+gatewayURL); + role = CatalogueRoleManager.getHighestRole(scopePerCurrentUrl, username, groupName, this, orgsInWhichAtLeastEditorRole, gatewayURL); // if he is an admin/editor preload: // 1) organizations in which he can publish (the widget will find these info in session) diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java index cb574cd..7caea27 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java +++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java @@ -1,6 +1,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils; import java.util.List; +import java.util.Set; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; @@ -39,7 +40,7 @@ public class CatalogueRoleManager { * @param orgsInWhichAtLeastEditorRole * @return the highest among the roles */ - public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName, CKANPublisherServicesImpl gcubeCkanDataCatalogServiceImpl, List orgsInWhichAtLeastEditorRole){ + public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName, CKANPublisherServicesImpl gcubeCkanDataCatalogServiceImpl, List orgsInWhichAtLeastEditorRole, String gatewayHostname){ // base role as default value RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER; @@ -59,7 +60,14 @@ public class CatalogueRoleManager { logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope); // retrieve the flat list of organizations for the current user - List groups = groupManager.listGroupsByUser(userid); + //List groups = groupManager.listGroupsByUser(userid); + + // retrieve the list of organizations for the current user filtered for gateway + Set groups = groupManager.listGroupsByUserAndSite(userid, gatewayHostname); + + for (GCubeGroup gCubeGroup : groups) { + logger.info("Found group filter per "+gatewayHostname+": "+gCubeGroup.toString()); + } // root (so check into the root, the VOs and the VRES) if(groupManager.isRootVO(currentGroupId)){