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
This commit is contained in:
Francesco Mangiacrapa 2019-06-12 10:15:07 +00:00
parent 5182d0af63
commit f53c8d0c3b
7 changed files with 37 additions and 16 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"> <classpathentry including="**/*.java" kind="src" output="target/ckan-metadata-publisher-widget-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -18,7 +18,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/ckan-metadata-publisher-widget-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -34,5 +34,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/ckan-metadata-publisher-widget-1.6.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -2,7 +2,11 @@
<Changeset <Changeset
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-6-0" component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-6-0"
date="${buildDate}"> date="${buildDate}">
<Change>[Feature #11331] Field repeatability: support for catalogue widget <Change>[Feature #11331] Field repeatability: support for catalogue
widget
</Change>
<Change>[Task #12480] Data Catalogue Publishing widget: filter the VREs for the working gateway
widget
</Change> </Change>
</Changeset> </Changeset>
<Changeset <Changeset
@ -15,13 +19,15 @@
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-1" component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-1"
date="2018-11-20"> date="2018-11-20">
<Change>[Bug #12914] The form to add/choice the resources to <Change>[Bug #12914] The form to add/choice the resources to
publishing remains frozen</Change> publishing remains frozen
</Change>
</Changeset> </Changeset>
<Changeset <Changeset
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-0" component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-0"
date="2018-09-28"> date="2018-09-28">
<Change>[Incident #12563] Error when trying to publish the content of <Change>[Incident #12563] Error when trying to publish the content of
a workspace folder into the catalogue</Change> a workspace folder into the catalogue
</Change>
</Changeset> </Changeset>
<Changeset <Changeset
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3" component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3"

View File

@ -27,7 +27,7 @@
<properties> <properties>
<!-- Convenience property to set the GWT version --> <!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion> <gwtVersion>2.7.0</gwtVersion>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <!-- <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> -->
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

View File

@ -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.Button;
import com.github.gwtbootstrap.client.ui.Label; 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.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
@ -95,8 +96,10 @@ public class MetaDataField extends Composite {
//The field is repeatable //The field is repeatable
if(field.getMaxOccurs()>1) { if(field.getMaxOccurs()>1) {
repeatabilityLabel.setVisible(true); 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)"; // String maxTxt = field.getMaxOccurs()==Integer.MAX_VALUE?"":"(max occurs declared are "+field.getMaxOccurs()+" times)";
repeatabilityLabel.setText("Repeat "+field.getFieldName());
} }
} }

View File

@ -3,8 +3,8 @@
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style> <ui:style>
.important { .margin-left-max-occurrs {
font-weight: bold; padding-left: 28px;
} }
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
@ -12,8 +12,8 @@
ui:field="panelMetaDataFieldsSkeleton" width="100%"> ui:field="panelMetaDataFieldsSkeleton" width="100%">
</g:VerticalPanel> </g:VerticalPanel>
<b:ControlGroup> <b:ControlGroup>
<b:Controls> <b:Controls addStyleNames="{style.margin-left-max-occurrs}">
<b:Label ui:field="repeatabilityLabel" visible="false">Repeatability</b:Label> <b:Label ui:field="repeatabilityLabel" visible="false">Repeatable field</b:Label>
<b:Button icon="MINUS_SIGN" title="Remove Latest Field" <b:Button icon="MINUS_SIGN" title="Remove Latest Field"
ui:field="removeFieldButton" visible="false"></b:Button> ui:field="removeFieldButton" visible="false"></b:Button>
<b:Button icon="PLUS_SIGN" title="Add Another Field" <b:Button icon="PLUS_SIGN" title="Add Another Field"

View File

@ -108,7 +108,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.info("List of organizations was into session " + orgsName); logger.info("List of organizations was into session " + orgsName);
} }
else{ else{
CatalogueRoleManager.getHighestRole(scope, username, GenericUtils.getGroupFromScope(scope).getGroupName(), this, orgsName); String gatewayURL = GenericUtils.getCurrentClientUrl(getThreadLocalRequest());
logger.info("The Gateway URL is: "+gatewayURL);
CatalogueRoleManager.getHighestRole(scope, username, GenericUtils.getGroupFromScope(scope).getGroupName(), this, orgsName, gatewayURL);
httpSession.setAttribute(keyPerScope, orgsName); httpSession.setAttribute(keyPerScope, orgsName);
logger.info("Organizations name for user " + username + " has been saved into session " + orgsName); logger.info("Organizations name for user " + username + " has been saved into session " + orgsName);
} }
@ -621,7 +623,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// we build up also a list that keeps track of the scopes (orgs) in which the user has role ADMIN/EDITOR // we build up also a list that keeps track of the scopes (orgs) in which the user has role ADMIN/EDITOR
List<OrganizationBean> orgsInWhichAtLeastEditorRole = new ArrayList<OrganizationBean>(); List<OrganizationBean> orgsInWhichAtLeastEditorRole = new ArrayList<OrganizationBean>();
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: // if he is an admin/editor preload:
// 1) organizations in which he can publish (the widget will find these info in session) // 1) organizations in which he can publish (the widget will find these info in session)

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils; package org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils;
import java.util.List; import java.util.List;
import java.util.Set;
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
@ -39,7 +40,7 @@ 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){ 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;
@ -59,7 +60,14 @@ public class CatalogueRoleManager {
logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope); logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope);
// retrieve the flat list of organizations for the current user // retrieve the flat list of organizations for the current user
List<GCubeGroup> groups = groupManager.listGroupsByUser(userid); //List<GCubeGroup> groups = groupManager.listGroupsByUser(userid);
// retrieve the list of organizations for the current user filtered for gateway
Set<GCubeGroup> 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) // root (so check into the root, the VOs and the VRES)
if(groupManager.isRootVO(currentGroupId)){ if(groupManager.isRootVO(currentGroupId)){