diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ba7b8..c686037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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). +## [v1.1.0-SNAPSHOT] - 2021-10-05 + +**New Features** +[#19988] Integrated with `checkEnvironment` reporting the status of "Upload to Zenodo" facility +Moved to `maven-portal-bom` 3.6.3 + ## [v1.0.2] - 2021-04-26 **Bug fixes** diff --git a/pom.xml b/pom.xml index 2cd4e05..1022226 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.gcube.portlets.widgets ckan2zenodo-publisher-widget jar - 1.0.2 + 1.1.0-SNAPSHOT gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo @@ -44,7 +44,7 @@ org.gcube.distribution maven-portal-bom - 3.6.1 + 3.6.3-SNAPSHOT pom import diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherService.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherService.java index 0226c3b..a32476b 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherService.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherService.java @@ -13,35 +13,43 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Jan 28, 2020 + * Jan 28, 2020 */ @RemoteServiceRelativePath("ckantozenodo") public interface CkanToZenodoPublisherService extends RemoteService { - /** - * Convert to zenodo item. - * - * @param item the item - * @return the zenodo item - * @throws Exception the exception - */ - ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception; + /** + * Convert to zenodo item. + * + * @param item the item + * @return the zenodo item + * @throws Exception the exception + */ + ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception; - /** - * Publish on zenodo. - * - * @param zenodoItem the zenodo item - * @return the DOI of published Zenodo Item - * @throws Exception the exception - */ - String publishOnZenodo(ZenodoItem zenodoItem) throws Exception; + /** + * Publish on zenodo. + * + * @param zenodoItem the zenodo item + * @return the DOI of published Zenodo Item + * @throws Exception the exception + */ + String publishOnZenodo(ZenodoItem zenodoItem) throws Exception; - /** - * Read fields descriptions. - * - * @return the map - * @throws Exception the exception - */ - Map readFieldsDescriptions() throws Exception; + /** + * Read fields descriptions. + * + * @return the map + * @throws Exception the exception + */ + Map readFieldsDescriptions() throws Exception; + + /** + * Check zenodo environment. + * + * @return the true is Zenodo environment is configured in the operating scope, + * false otherwise + */ + Boolean checkZenodoEnvironment(); } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherServiceAsync.java index e27b33d..6f0e3e1 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherServiceAsync.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZenodoPublisherServiceAsync.java @@ -36,6 +36,8 @@ public interface CkanToZenodoPublisherServiceAsync { void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback callback); void readFieldsDescriptions(AsyncCallback> callback); + + void checkZenodoEnvironment(AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java index 6367540..dfac229 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java @@ -15,6 +15,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.faults.ConfigurationException import org.gcube.data.publishing.ckan2zenodo.model.faults.GcatException; import org.gcube.data.publishing.ckan2zenodo.model.faults.TransformationException; import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException; +import org.gcube.data.publishing.ckan2zenodo.model.report.EnvironmentReport; import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata; import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService; @@ -51,7 +52,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple */ @Override public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception { - + LOG.info("publishOnZenodo called"); try { if(isOutFromPortal()) { @@ -59,7 +60,6 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true); } - Ckan2Zenodo client = new Ckan2ZenodoImpl(); // Get the item representation CkanItemDescriptor itemDescr = client.read(zenodoItem.getName()); @@ -154,7 +154,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple */ @Override public ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception { - + LOG.info("convertToZenodoItem called"); try { if(isOutFromPortal()) { @@ -223,7 +223,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple */ @Override public Map readFieldsDescriptions() throws Exception { - + LOG.info("readFieldsDescriptions called"); try { if(isOutFromPortal()) { @@ -242,6 +242,31 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple } + @Override + public Boolean checkZenodoEnvironment() { + LOG.info("checkZenodoEnvironment called"); + boolean isZenodoConfigured = false; + + try { + + if(isOutFromPortal()) { + PortalUtils.getCurrentContext(this.getThreadLocalRequest(), true); + PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true); + } + + LOG.info("readFieldsDescriptions called"); + Ckan2Zenodo client = new Ckan2ZenodoImpl(); + EnvironmentReport report = client.checkEnvironment(); + LOG.info("EnvironmentReport returned: "+report); + isZenodoConfigured = report.isok(); + } catch (Exception e) { + LOG.error("Error occurred during checkEnvironment: ", e); + } + + LOG.info("Is Zenodo Environment configured? " + isZenodoConfigured); + return isZenodoConfigured; + } + /** * Load filter resources. * @@ -275,4 +300,5 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple return true; } } + }