#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.
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**

View File

@ -15,7 +15,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan2zenodo-publisher-widget</artifactId>
<packaging>jar</packaging>
<version>1.0.2</version>
<version>1.1.0-SNAPSHOT</version>
<description>
gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo
@ -44,7 +44,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.1</version>
<version>3.6.3-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</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)
*
* 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<String, String> readFieldsDescriptions() throws Exception;
/**
* Read fields descriptions.
*
* @return the map
* @throws Exception the 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 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.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<String, String> 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;
}
}
}