|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|