#19988 Integrated with 'checkEnvironment'. Moved to 1.1.0-SNAPSHOT

This commit is contained in:
Francesco Mangiacrapa 2021-10-05 10:50:05 +02:00
parent 347ab5f764
commit de81ad01f6
5 changed files with 72 additions and 30 deletions

View File

@ -4,6 +4,12 @@
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).
## [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 ## [v1.0.2] - 2021-04-26
**Bug fixes** **Bug fixes**

View File

@ -15,7 +15,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan2zenodo-publisher-widget</artifactId> <artifactId>ckan2zenodo-publisher-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0.2</version> <version>1.1.0-SNAPSHOT</version>
<description> <description>
gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo
@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.1</version> <version>3.6.3-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -13,35 +13,43 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Jan 28, 2020 * Jan 28, 2020
*/ */
@RemoteServiceRelativePath("ckantozenodo") @RemoteServiceRelativePath("ckantozenodo")
public interface CkanToZenodoPublisherService extends RemoteService { public interface CkanToZenodoPublisherService extends RemoteService {
/** /**
* Convert to zenodo item. * Convert to zenodo item.
* *
* @param item the item * @param item the item
* @return the zenodo item * @return the zenodo item
* @throws Exception the exception * @throws Exception the exception
*/ */
ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception; ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception;
/** /**
* Publish on zenodo. * Publish on zenodo.
* *
* @param zenodoItem the zenodo item * @param zenodoItem the zenodo item
* @return the DOI of published Zenodo Item * @return the DOI of published Zenodo Item
* @throws Exception the exception * @throws Exception the exception
*/ */
String publishOnZenodo(ZenodoItem zenodoItem) throws Exception; String publishOnZenodo(ZenodoItem zenodoItem) throws Exception;
/** /**
* Read fields descriptions. * Read fields descriptions.
* *
* @return the map * @return the map
* @throws Exception the exception * @throws Exception the exception
*/ */
Map<String, String> readFieldsDescriptions() throws Exception; Map<String, String> readFieldsDescriptions() throws Exception;
/**
* Check zenodo environment.
*
* @return the true is Zenodo environment is configured in the operating scope,
* false otherwise
*/
Boolean checkZenodoEnvironment();
} }

View File

@ -36,6 +36,8 @@ public interface CkanToZenodoPublisherServiceAsync {
void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback<String> callback); void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback<String> callback);
void readFieldsDescriptions(AsyncCallback<Map<String, String>> callback); void readFieldsDescriptions(AsyncCallback<Map<String, String>> callback);
void checkZenodoEnvironment(AsyncCallback<Boolean> callback);
} }

View File

@ -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.GcatException;
import org.gcube.data.publishing.ckan2zenodo.model.faults.TransformationException; 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.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.DepositionMetadata;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition; import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
@ -51,7 +52,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
*/ */
@Override @Override
public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception { public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception {
LOG.info("publishOnZenodo called");
try { try {
if(isOutFromPortal()) { if(isOutFromPortal()) {
@ -59,7 +60,6 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true); PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
} }
Ckan2Zenodo client = new Ckan2ZenodoImpl(); Ckan2Zenodo client = new Ckan2ZenodoImpl();
// Get the item representation // Get the item representation
CkanItemDescriptor itemDescr = client.read(zenodoItem.getName()); CkanItemDescriptor itemDescr = client.read(zenodoItem.getName());
@ -154,7 +154,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
*/ */
@Override @Override
public ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception { public ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception {
LOG.info("convertToZenodoItem called");
try { try {
if(isOutFromPortal()) { if(isOutFromPortal()) {
@ -223,7 +223,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
*/ */
@Override @Override
public Map<String, String> readFieldsDescriptions() throws Exception { public Map<String, String> readFieldsDescriptions() throws Exception {
LOG.info("readFieldsDescriptions called");
try { try {
if(isOutFromPortal()) { 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. * Load filter resources.
* *
@ -275,4 +300,5 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
return true; return true;
} }
} }
} }