Compare commits
No commits in common. "master" and "v1.0.2" have entirely different histories.
|
@ -1,11 +1,11 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
org.eclipse.jdt.core.compiler.release=disabled
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -4,27 +4,6 @@
|
||||||
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.4] - 2023-12-21
|
|
||||||
|
|
||||||
- Fixing `publication_date` issue [#26166]
|
|
||||||
|
|
||||||
## [v1.1.3] - 2023-07-25
|
|
||||||
|
|
||||||
- Fixing `null` issue, recompiling this component [#25275]
|
|
||||||
|
|
||||||
## [v1.1.2] - 2022-10-27
|
|
||||||
|
|
||||||
**Enhancements**
|
|
||||||
|
|
||||||
- [#24038] Moved to GWT 2.9.0
|
|
||||||
- Moved to maven-portal-bom 3.6.4
|
|
||||||
|
|
||||||
## [v1.1.0] - 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**
|
||||||
|
|
34
pom.xml
34
pom.xml
|
@ -7,14 +7,15 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>maven-parent</artifactId>
|
<artifactId>maven-parent</artifactId>
|
||||||
<groupId>org.gcube.tools</groupId>
|
<groupId>org.gcube.tools</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.1.0</version>
|
||||||
<relativePath />
|
<relativePath />
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
<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.1.4</version>
|
<version>1.0.2</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
|
||||||
|
@ -30,10 +31,10 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Convenience property to set the GWT version -->
|
<!-- Convenience property to set the GWT version -->
|
||||||
<gwtVersion>2.10.0</gwtVersion>
|
<gwtVersion>2.7.0</gwtVersion>
|
||||||
|
|
||||||
<!-- GWT needs at least java 1.6 -->
|
<!-- GWT needs at least java 1.6 -->
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -43,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.4</version>
|
<version>3.6.1</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -57,18 +58,6 @@
|
||||||
<version>${gwtVersion}</version>
|
<version>${gwtVersion}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.gwt</groupId>
|
|
||||||
<artifactId>gwt-servlet</artifactId>
|
|
||||||
<version>${gwtVersion}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.gwt</groupId>
|
|
||||||
<artifactId>gwt-dev</artifactId>
|
|
||||||
<version>${gwtVersion}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.gwtbootstrap</groupId>
|
<groupId>com.github.gwtbootstrap</groupId>
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
|
@ -76,7 +65,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>switch-button-widget</artifactId>
|
<artifactId>switch-button-widget</artifactId>
|
||||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0, 2.0.0)</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -130,15 +119,6 @@
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- REQUIRED FOR JDK_11 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.4</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoError;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoError;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.DOI_dv;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Alert;
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
|
@ -31,8 +30,6 @@ import com.google.gwt.json.client.JSONParser;
|
||||||
import com.google.gwt.json.client.JSONValue;
|
import com.google.gwt.json.client.JSONValue;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -100,7 +97,6 @@ public class CkanToZendoPublisherWidget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ZenodoItem result) {
|
public void onSuccess(ZenodoItem result) {
|
||||||
GWT.log("Zenodo item returned is: "+result);
|
|
||||||
loader.setVisible(false);
|
loader.setVisible(false);
|
||||||
modal.remove(loader);
|
modal.remove(loader);
|
||||||
manager = new Ckan2ZenodoViewManager();
|
manager = new Ckan2ZenodoViewManager();
|
||||||
|
@ -167,7 +163,7 @@ public class CkanToZendoPublisherWidget {
|
||||||
//Submit publish on zenodo.
|
//Submit publish on zenodo.
|
||||||
ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm();
|
ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm();
|
||||||
GWT.log("Publishing file: "+zenodoItem.getFiles());
|
GWT.log("Publishing file: "+zenodoItem.getFiles());
|
||||||
ckanToZenodoService.publishOnZenodo(zenodoItem, new AsyncCallback<DOI_dv>() {
|
ckanToZenodoService.publishOnZenodo(zenodoItem, new AsyncCallback<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -183,7 +179,7 @@ public class CkanToZendoPublisherWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(DOI_dv doi_dv) {
|
public void onSuccess(String doi) {
|
||||||
buttonPublish.setEnabled(false);
|
buttonPublish.setEnabled(false);
|
||||||
basicTabPanel.getElement().getStyle().setOpacity(1.0);
|
basicTabPanel.getElement().getStyle().setOpacity(1.0);
|
||||||
try {
|
try {
|
||||||
|
@ -193,27 +189,15 @@ public class CkanToZendoPublisherWidget {
|
||||||
}
|
}
|
||||||
String msg = "The item has been uploaded to Zenodo correctly";
|
String msg = "The item has been uploaded to Zenodo correctly";
|
||||||
|
|
||||||
|
if(doi!=null)
|
||||||
|
msg+=" "+doi;
|
||||||
|
|
||||||
Alert infoLabel = new Alert();
|
Alert infoLabel = new Alert();
|
||||||
infoLabel.setClose(false);
|
infoLabel.setClose(false);
|
||||||
infoLabel.setType(AlertType.INFO);
|
infoLabel.setType(AlertType.INFO);
|
||||||
infoLabel.setText(msg);
|
infoLabel.setText(msg);
|
||||||
|
|
||||||
Modal modal = new Modal(true, true);
|
showResults(Arrays.asList(infoLabel.asWidget()));
|
||||||
modal.setCloseVisible(true);
|
|
||||||
modal.setTitle("Item uploaded to Zenodo!");
|
|
||||||
modal.add(infoLabel);
|
|
||||||
if(doi_dv!=null) {
|
|
||||||
FlowPanel dF = new FlowPanel();
|
|
||||||
dF.add(new HTML("DOI: "+doi_dv.getDoi()));
|
|
||||||
FlowPanel dFU = new FlowPanel();
|
|
||||||
dFU.add(new HTML("DOI URL: <a href='"+doi_dv.getDoi_url()+"' target='_blank'>"+doi_dv.getDoi_url()+"</a>"));
|
|
||||||
modal.add(dF);
|
|
||||||
modal.add(dFU);
|
|
||||||
}
|
|
||||||
|
|
||||||
modal.show();
|
|
||||||
|
|
||||||
//showResults(Arrays.asList(infoLabel.asWidget()));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.DOI_dv;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
@ -35,7 +34,7 @@ public interface CkanToZenodoPublisherService extends RemoteService {
|
||||||
* @return the DOI of published Zenodo Item
|
* @return the DOI of published Zenodo Item
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
DOI_dv publishOnZenodo(ZenodoItem zenodoItem) throws Exception;
|
String publishOnZenodo(ZenodoItem zenodoItem) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read fields descriptions.
|
* Read fields descriptions.
|
||||||
|
@ -45,12 +44,4 @@ public interface CkanToZenodoPublisherService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.DOI_dv;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -34,11 +33,9 @@ public interface CkanToZenodoPublisherServiceAsync {
|
||||||
|
|
||||||
void convertToZenodoItem(CatalogueItem item, AsyncCallback<ZenodoItem> callback);
|
void convertToZenodoItem(CatalogueItem item, AsyncCallback<ZenodoItem> callback);
|
||||||
|
|
||||||
void publishOnZenodo(ZenodoItem zenodoItem, AsyncCallback<DOI_dv> 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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,8 +259,6 @@ public class BasicInformationView extends Composite implements FormValidator {
|
||||||
InfoTextAndLabels.addTooltipForFieldKey("description", cl_description);
|
InfoTextAndLabels.addTooltipForFieldKey("description", cl_description);
|
||||||
field_doi.setValue(zenodoItem.getDoi());
|
field_doi.setValue(zenodoItem.getDoi());
|
||||||
|
|
||||||
GWT.log("Filling form with: "+zenodoItem.getMetadata());
|
|
||||||
|
|
||||||
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
||||||
if (zMeta != null) {
|
if (zMeta != null) {
|
||||||
|
|
||||||
|
@ -329,19 +327,20 @@ public class BasicInformationView extends Composite implements FormValidator {
|
||||||
InfoTextAndLabels.addTooltipForFieldKey("access_conditions", cl_access_conditions);
|
InfoTextAndLabels.addTooltipForFieldKey("access_conditions", cl_access_conditions);
|
||||||
|
|
||||||
// License
|
// License
|
||||||
if (zMeta.getLicenseIDs() != null) {
|
if (zMeta.getLicenses() != null) {
|
||||||
//List<String> listLicensesIds = null;
|
List<String> listLicensesIds = null;
|
||||||
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenseIDs());
|
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectedValues());
|
||||||
if(selectedLicensesId!=null) {
|
if(zMeta.getLicenses().getSelectableValues()!=null) {
|
||||||
FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
listLicensesIds = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectableValues());
|
||||||
|
FieldUtil.addValuesToListBox(field_license, listLicensesIds);
|
||||||
field_license.setEnabled(true);
|
field_license.setEnabled(true);
|
||||||
}else {
|
}else {
|
||||||
//Exception case on missing list of selectable license ids
|
//Exception case on missing list of selectable license ids
|
||||||
//FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
||||||
field_license.setEnabled(false); //only one license id is available
|
field_license.setEnabled(false); //only one license id is available
|
||||||
|
|
||||||
}
|
}
|
||||||
//FieldUtil.selectValueToListBox(field_license, selectedLicensesId);
|
FieldUtil.selectValueToListBox(field_license, selectedLicensesId);
|
||||||
}else
|
}else
|
||||||
field_license.setEnabled(false);
|
field_license.setEnabled(false);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||||
|
@ -123,9 +124,6 @@ public class Ckan2ZenodoViewManager {
|
||||||
meta.setDescription(basicForm.getField_description().getValue());
|
meta.setDescription(basicForm.getField_description().getValue());
|
||||||
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
||||||
|
|
||||||
//Setting publication date fxing #26166
|
|
||||||
meta.setPublication_date(basicForm.getField_publication_date().getValue());
|
|
||||||
|
|
||||||
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
||||||
GWT.log("Read creators from FORM: "+creators);
|
GWT.log("Read creators from FORM: "+creators);
|
||||||
meta.setCreators(creators);
|
meta.setCreators(creators);
|
||||||
|
@ -164,11 +162,8 @@ public class Ckan2ZenodoViewManager {
|
||||||
//license
|
//license
|
||||||
String licenseId = basicForm.getField_license().getSelectedValue();
|
String licenseId = basicForm.getField_license().getSelectedValue();
|
||||||
if(licenseId!=null) {
|
if(licenseId!=null) {
|
||||||
//LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null);
|
LicenseBean licenseBean = new LicenseBean(licenseId, null, null);
|
||||||
List<String> licenses = new ArrayList<String>();
|
meta.setLicenses(new SerializableEnum<LicenseBean>(Arrays.asList(licenseBean),null));
|
||||||
licenses.add(licenseId);
|
|
||||||
meta.setLicenseIDs(licenses);
|
|
||||||
//meta.setLicenses(Arrays.asList(licenseBean));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//embargo date
|
//embargo date
|
||||||
|
|
|
@ -3,6 +3,9 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoLicense;
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
@ -95,18 +98,17 @@ public class FieldUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo ids.
|
* To zenodo ids.
|
||||||
* TODO Must passed an object License
|
|
||||||
*
|
*
|
||||||
* @param listLicenses the list licenses
|
* @param listLicenses the list licenses
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public static List<String> toZenodoIds(List<String> listLicenses){
|
public static List<String> toZenodoIds(List<LicenseBean> listLicenses){
|
||||||
if(listLicenses==null)
|
if(listLicenses==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<String> licenses = new ArrayList<String>(listLicenses.size());
|
List<String> licenses = new ArrayList<String>(listLicenses.size());
|
||||||
for (String zenodoLicense : listLicenses) {
|
for (ZenodoLicense zenodoLicense : listLicenses) {
|
||||||
licenses.add(zenodoLicense);
|
licenses.add(zenodoLicense.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return licenses;
|
return licenses;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -16,7 +15,6 @@ 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;
|
||||||
|
@ -26,7 +24,6 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ItemTranslateError;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ItemTranslateError;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ItemTranslateError.ERROR_TYPE;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ItemTranslateError.ERROR_TYPE;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoError;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoError;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.DOI_dv;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMetadata;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMetadata;
|
||||||
|
@ -48,16 +45,13 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(CkanToZenodoPublisherServiceImpl.class);
|
private static Logger LOG = LoggerFactory.getLogger(CkanToZenodoPublisherServiceImpl.class);
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
*
|
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#publishOnZenodo(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem)
|
||||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
|
||||||
* CkanToZenodoPublisherService#publishOnZenodo(org.gcube.portlets.widgets.
|
|
||||||
* ckan2zenodopublisher.shared.wrapped.ZenodoItem)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DOI_dv publishOnZenodo(ZenodoItem zenodoItem) throws Exception {
|
public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception {
|
||||||
LOG.info("publishOnZenodo called");
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(isOutFromPortal()) {
|
if(isOutFromPortal()) {
|
||||||
|
@ -65,7 +59,6 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("publishOnZenodo called with metadata: "+zenodoItem.getMetadata());
|
|
||||||
|
|
||||||
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
||||||
// Get the item representation
|
// Get the item representation
|
||||||
|
@ -86,8 +79,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
//Updating Deposition Metadata potentially changed on client-side
|
//Updating Deposition Metadata potentially changed on client-side
|
||||||
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
||||||
DepositionMetadata depositionMetadata = zenodoDepositionPreview.getMetadata();
|
DepositionMetadata depositionMetadata = zenodoDepositionPreview.getMetadata();
|
||||||
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata,
|
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata, depositionMetadata);
|
||||||
depositionMetadata);
|
|
||||||
zenodoDepositionPreview.setMetadata(depositionMetadata);
|
zenodoDepositionPreview.setMetadata(depositionMetadata);
|
||||||
|
|
||||||
//Loading Filtered resources according to VRE policies
|
//Loading Filtered resources according to VRE policies
|
||||||
|
@ -101,8 +93,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
for (CkanResource ckanResource : filteredResources) {
|
for (CkanResource ckanResource : filteredResources) {
|
||||||
if(zf.getId().compareTo(ckanResource.getId())==0 && zf.getIsAlreadyPublished()==false) {
|
if(zf.getId().compareTo(ckanResource.getId())==0 && zf.getIsAlreadyPublished()==false) {
|
||||||
if(CkanToZenodoUtil.isNotEmpty(zf.getFilename())) {
|
if(CkanToZenodoUtil.isNotEmpty(zf.getFilename())) {
|
||||||
ckanResource.setName(zf.getFilename()); // only the filename can be changed on
|
ckanResource.setName(zf.getFilename()); //only the filename can be changed on clien-side
|
||||||
// clien-side
|
|
||||||
toUpload.add(ckanResource);
|
toUpload.add(ckanResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,22 +105,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
// Step 1 : metadata
|
// Step 1 : metadata
|
||||||
client= new Ckan2ZenodoImpl();
|
client= new Ckan2ZenodoImpl();
|
||||||
LOG.debug("Calling updatedMetadata for: "+zenodoDepositionPreview);
|
LOG.debug("Calling updatedMetadata for: "+zenodoDepositionPreview);
|
||||||
|
|
||||||
//fixing issue #26166
|
|
||||||
Date thePublicationDate = zenodoDepositionPreview.getMetadata().getPublication_date();
|
|
||||||
LOG.debug("Publication_Date before update is: " + thePublicationDate);
|
|
||||||
|
|
||||||
zenodoDepositionPreview = client.updatedMetadata(zenodoDepositionPreview);
|
zenodoDepositionPreview = client.updatedMetadata(zenodoDepositionPreview);
|
||||||
|
|
||||||
//Step 2 : publish Resources
|
//Step 2 : publish Resources
|
||||||
if(toUpload.size()>0) {
|
if(toUpload.size()>0) {
|
||||||
LOG.debug("Trying to publish the set of CKAN resources: "+toUpload.toString());
|
LOG.debug("Trying to publish the set of CKAN resources: "+toUpload.toString());
|
||||||
|
|
||||||
//fixing issue #26166
|
|
||||||
zenodoDepositionPreview.getMetadata().setPublication_date(thePublicationDate);
|
|
||||||
LOG.debug("Publication_Date before uploadFiles is: " + zenodoDepositionPreview.getMetadata().getPublication_date());
|
|
||||||
Future<ZenodoDeposition> future_Dep=client.uploadFiles(toUpload, zenodoDepositionPreview);
|
Future<ZenodoDeposition> future_Dep=client.uploadFiles(toUpload, zenodoDepositionPreview);
|
||||||
|
|
||||||
while(!future_Dep.isDone()) {
|
while(!future_Dep.isDone()) {
|
||||||
LOG.debug("Waiting for completed future computation (publishing of resources on Zenodo)...");
|
LOG.debug("Waiting for completed future computation (publishing of resources on Zenodo)...");
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
@ -139,15 +120,10 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
// Get the item representation
|
// Get the item representation
|
||||||
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
||||||
|
|
||||||
//fixing issue #26166
|
|
||||||
LOG.debug("Publication_Date before publish is: " + thePublicationDate);
|
|
||||||
zenodoDepositionPreview.getMetadata().setPublication_date(thePublicationDate);
|
|
||||||
|
|
||||||
//Finalize
|
//Finalize
|
||||||
LOG.debug("Calling publish on Zenodo for: "+zenodoDepositionPreview);
|
LOG.debug("Calling publish on Zenodo for: "+zenodoDepositionPreview);
|
||||||
zenodoDepositionPreview = client.publish(zenodoDepositionPreview, item);
|
zenodoDepositionPreview = client.publish(zenodoDepositionPreview, item);
|
||||||
return new DOI_dv(zenodoDepositionPreview.getDoi(), zenodoDepositionPreview.getDoi_url());
|
return zenodoDepositionPreview.getDoi();
|
||||||
|
|
||||||
//throw new ZenodoException();
|
//throw new ZenodoException();
|
||||||
|
|
||||||
|
@ -157,8 +133,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
String clientError = String.format("%s", error);
|
String clientError = String.format("%s", error);
|
||||||
throw new Exception(clientError);
|
throw new Exception(clientError);
|
||||||
} catch (ZenodoException e) {
|
} catch (ZenodoException e) {
|
||||||
String error = ZenodoException.class.getName() + " during upload to Zenodo the catalogue item: "
|
String error = ZenodoException.class.getName()+" during upload to Zenodo the catalogue item: "+zenodoItem.getName();
|
||||||
+ zenodoItem.getName();
|
|
||||||
LOG.error(error, e);
|
LOG.error(error, e);
|
||||||
//String clientError = String.format("%s", e.getRemoteMessage());
|
//String clientError = String.format("%s", e.getRemoteMessage());
|
||||||
ZenodoError zenodoError = new ZenodoError(e);
|
ZenodoError zenodoError = new ZenodoError(e);
|
||||||
|
@ -174,16 +149,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* (non-Javadoc)
|
||||||
* (non-Javadoc)
|
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
|
||||||
*
|
|
||||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
|
||||||
* CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.
|
|
||||||
* ckan2zenodopublisher.shared.CatalogueItem)
|
|
||||||
*/
|
*/
|
||||||
@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()) {
|
||||||
|
@ -199,14 +170,16 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
ItemTranslateError itemTrError = null;
|
ItemTranslateError itemTrError = null;
|
||||||
try {
|
try {
|
||||||
zdDeposition = client.translate(itemDescr);
|
zdDeposition = client.translate(itemDescr);
|
||||||
} catch (ConfigurationException | TransformationException e) {
|
} catch (ConfigurationException e) {
|
||||||
LOG.info(ConfigurationException.class.getSimpleName() + " thrown, trying to use forceTranslation for: "
|
LOG.info(ConfigurationException.class.getSimpleName() + " thrown, trying to use forceTranslation for: "
|
||||||
+ itemDescr.getName());
|
+ itemDescr.getName());
|
||||||
itemTrError = new ItemTranslateError(e.getMessage(), ERROR_TYPE.INFO);
|
itemTrError = new ItemTranslateError(e.getMessage(), ERROR_TYPE.INFO);
|
||||||
zdDeposition = client.forceTranslation(itemDescr);
|
zdDeposition = client.forceTranslation(itemDescr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Loading Filtered resources according to VRE policies
|
||||||
List<CkanResource> filteredResources = loadFilterResources(item.getItemId());
|
List<CkanResource> filteredResources = loadFilterResources(item.getItemId());
|
||||||
|
|
||||||
LOG.debug("Loaded filtered resources: "+filteredResources);
|
LOG.debug("Loaded filtered resources: "+filteredResources);
|
||||||
|
|
||||||
//Converting ZenodoDeposition to ZenodoItem
|
//Converting ZenodoDeposition to ZenodoItem
|
||||||
|
@ -219,22 +192,16 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
List<ZenodoFile> resources = ItemToZenodoConverter.toZenodoFiles(filteredResources, false);
|
List<ZenodoFile> resources = ItemToZenodoConverter.toZenodoFiles(filteredResources, false);
|
||||||
zenodoItem.addFiles(resources);
|
zenodoItem.addFiles(resources);
|
||||||
|
|
||||||
// I'M SETTING THE ID BECAUSE THE NAME IS NULL INTO BEAN PASSED FROM PORTLET
|
//I'M SETTING THE ID BECAUSE THE NAME IS NULL INTO BEAN PASSED FROM PORTLET SIDE
|
||||||
// SIDE
|
|
||||||
//TODO I'M WAITING FOR itemName retrieved from ckan2zenodo library
|
//TODO I'M WAITING FOR itemName retrieved from ckan2zenodo library
|
||||||
zenodoItem.setName(item.getItemId());
|
zenodoItem.setName(item.getItemId());
|
||||||
|
|
||||||
LOG.debug("zenodoItem getLicenses as list: " + zenodoItem.getMetadata().getLicenseIDs());
|
|
||||||
//LOG.debug("setting licenses at null");
|
|
||||||
//zenodoItem.getMetadata().setLicenseIDs(null);
|
|
||||||
|
|
||||||
LOG.debug("Returning item: "+zenodoItem);
|
LOG.debug("Returning item: "+zenodoItem);
|
||||||
|
|
||||||
return zenodoItem;
|
return zenodoItem;
|
||||||
|
|
||||||
} catch (ZenodoException e) {
|
} catch (ZenodoException e) {
|
||||||
String error = ZenodoException.class.getName() + " on converting the catalogue item with id: "
|
String error = ZenodoException.class.getName()+" on converting the catalogue item with id: "+item.getItemId();
|
||||||
+ item.getItemId();
|
|
||||||
LOG.error(error, e);
|
LOG.error(error, e);
|
||||||
//String clientError = String.format("%s. %s", error, e.getRemoteMessage());
|
//String clientError = String.format("%s. %s", error, e.getRemoteMessage());
|
||||||
ZenodoError zenodoError = new ZenodoError(e);
|
ZenodoError zenodoError = new ZenodoError(e);
|
||||||
|
@ -251,16 +218,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* (non-Javadoc)
|
||||||
* (non-Javadoc)
|
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
|
||||||
*
|
|
||||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
|
||||||
* CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.
|
|
||||||
* ckan2zenodopublisher.shared.CatalogueItem)
|
|
||||||
*/
|
*/
|
||||||
@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()) {
|
||||||
|
@ -279,31 +242,6 @@ 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.
|
||||||
*
|
*
|
||||||
|
@ -313,8 +251,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
* @throws ConfigurationException the configuration exception
|
* @throws ConfigurationException the configuration exception
|
||||||
* @throws TransformationException the transformation exception
|
* @throws TransformationException the transformation exception
|
||||||
*/
|
*/
|
||||||
private List<CkanResource> loadFilterResources(String itemName)
|
private List<CkanResource> loadFilterResources(String itemName) throws GcatException, ConfigurationException, TransformationException {
|
||||||
throws GcatException, ConfigurationException, TransformationException {
|
|
||||||
|
|
||||||
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
||||||
// Get the item representation
|
// Get the item representation
|
||||||
|
@ -332,10 +269,10 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
try {
|
try {
|
||||||
UserLocalServiceUtil.getService();
|
UserLocalServiceUtil.getService();
|
||||||
return false;
|
return false;
|
||||||
} catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
}
|
||||||
|
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||||
LOG.debug("Development Mode ON");
|
LOG.debug("Development Mode ON");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoLicense;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +48,20 @@ public class CkanToZenodoUtil {
|
||||||
return new SerializableEnum<String>(selectedValues, values);
|
return new SerializableEnum<String>(selectedValues, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To serializable enum.
|
||||||
|
*
|
||||||
|
* @param <E> the element type
|
||||||
|
* @param selectedLicense the selected license
|
||||||
|
* @param allLicenses the all licenses
|
||||||
|
* @return the serializable enum
|
||||||
|
*/
|
||||||
|
public static <E extends ZenodoLicense> SerializableEnum<E> toSerializableEnum(List<E> selectedLicense, List<E> allLicenses) {
|
||||||
|
|
||||||
|
return new SerializableEnum<E>(selectedLicense, allLicenses);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is not empty.
|
* Checks if is not empty.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Subject;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
||||||
|
@ -35,6 +37,8 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoSubj
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ItemToZenodoConverter.
|
* The Class ItemToZenodoConverter.
|
||||||
*
|
*
|
||||||
|
@ -45,7 +49,6 @@ import org.slf4j.LoggerFactory;
|
||||||
public class ItemToZenodoConverter {
|
public class ItemToZenodoConverter {
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(ItemToZenodoConverter.class);
|
private static Logger LOG = LoggerFactory.getLogger(ItemToZenodoConverter.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **
|
* **
|
||||||
*
|
*
|
||||||
|
@ -56,6 +59,7 @@ public class ItemToZenodoConverter {
|
||||||
* @return the zenodo item
|
* @return the zenodo item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo item.
|
* To zenodo item.
|
||||||
*
|
*
|
||||||
|
@ -93,6 +97,7 @@ public class ItemToZenodoConverter {
|
||||||
return zi;
|
return zi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the files.
|
* Adds the files.
|
||||||
*
|
*
|
||||||
|
@ -132,6 +137,8 @@ public class ItemToZenodoConverter {
|
||||||
return listOfFiles;
|
return listOfFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo file.
|
* To zenodo file.
|
||||||
*
|
*
|
||||||
|
@ -153,6 +160,7 @@ public class ItemToZenodoConverter {
|
||||||
return zf;
|
return zf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo file.
|
* To zenodo file.
|
||||||
*
|
*
|
||||||
|
@ -177,6 +185,7 @@ public class ItemToZenodoConverter {
|
||||||
return zf;
|
return zf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo metadata.
|
* To zenodo metadata.
|
||||||
*
|
*
|
||||||
|
@ -192,9 +201,6 @@ public class ItemToZenodoConverter {
|
||||||
zm.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
zm.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
||||||
zm.setDescription(depositionMetadata.getDescription());
|
zm.setDescription(depositionMetadata.getDescription());
|
||||||
|
|
||||||
// fixing bug #26165 on publication_date = null
|
|
||||||
zm.setPublication_date(depositionMetadata.getPublication_date());
|
|
||||||
|
|
||||||
//Access Type
|
//Access Type
|
||||||
AccessRights[] accessRight = null;
|
AccessRights[] accessRight = null;
|
||||||
if(depositionMetadata.getAccess_right()!=null) {
|
if(depositionMetadata.getAccess_right()!=null) {
|
||||||
|
@ -229,14 +235,11 @@ public class ItemToZenodoConverter {
|
||||||
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
||||||
|
|
||||||
//Licenses
|
//Licenses
|
||||||
List<String> selectedLicenses = null;
|
List<LicenseBean> selectedLicenses = null;
|
||||||
if(depositionMetadata.getLicense()!=null) {
|
if(depositionMetadata.getLicense()!=null) {
|
||||||
selectedLicenses = new ArrayList<String>();
|
selectedLicenses = Arrays.asList(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null));
|
||||||
selectedLicenses.add(depositionMetadata.getLicense()); // NEED TO ADD ALL LICENSES
|
|
||||||
}
|
|
||||||
if (selectedLicenses != null) {
|
|
||||||
zm.setLicenseIDs(selectedLicenses);
|
|
||||||
}
|
}
|
||||||
|
zm.setLicenses(CkanToZenodoUtil.toSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
|
||||||
|
|
||||||
if(depositionMetadata.getEmbargo_date()!=null) {
|
if(depositionMetadata.getEmbargo_date()!=null) {
|
||||||
|
|
||||||
|
@ -271,6 +274,7 @@ public class ItemToZenodoConverter {
|
||||||
return zm;
|
return zm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo subjects.
|
* To zenodo subjects.
|
||||||
*
|
*
|
||||||
|
@ -312,6 +316,7 @@ public class ItemToZenodoConverter {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo date intervals.
|
* To zenodo date intervals.
|
||||||
*
|
*
|
||||||
|
@ -331,8 +336,7 @@ public class ItemToZenodoConverter {
|
||||||
types = CkanToZenodoUtil.toSerializableEnum(rel, DateInterval.Type.values());
|
types = CkanToZenodoUtil.toSerializableEnum(rel, DateInterval.Type.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types,
|
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types, dateInterval.getDescription()));
|
||||||
dateInterval.getDescription()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -411,6 +415,7 @@ public class ItemToZenodoConverter {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To service file deposition.
|
* To service file deposition.
|
||||||
*
|
*
|
||||||
|
@ -434,6 +439,7 @@ public class ItemToZenodoConverter {
|
||||||
return fileDep;
|
return fileDep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update metadata info of deposition metadata.
|
* Update metadata info of deposition metadata.
|
||||||
*
|
*
|
||||||
|
@ -441,8 +447,7 @@ public class ItemToZenodoConverter {
|
||||||
* @param depositionMetadata the deposition metadata
|
* @param depositionMetadata the deposition metadata
|
||||||
* @return the deposition metadata
|
* @return the deposition metadata
|
||||||
*/
|
*/
|
||||||
public static DepositionMetadata updateMetadataInfoOfDepositionMetadata(ZenodoMetadata metadata,
|
public static DepositionMetadata updateMetadataInfoOfDepositionMetadata(ZenodoMetadata metadata, DepositionMetadata depositionMetadata) {
|
||||||
DepositionMetadata depositionMetadata) {
|
|
||||||
|
|
||||||
//description
|
//description
|
||||||
String description = metadata.getDescription();
|
String description = metadata.getDescription();
|
||||||
|
@ -520,13 +525,13 @@ public class ItemToZenodoConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
//license
|
//license
|
||||||
List<String> licenses = metadata.getLicenseIDs();
|
SerializableEnum<LicenseBean> licenses = metadata.getLicenses();
|
||||||
LOG.debug("Read licenses: "+licenses);
|
LOG.debug("Read licenses: "+licenses);
|
||||||
if (licenses != null && licenses.size() > 0) {
|
if(licenses!=null) {
|
||||||
try {
|
try {
|
||||||
String lB = licenses.get(0);
|
LicenseBean lB = licenses.getSelectedValues().get(0);
|
||||||
LOG.debug("Set license: "+lB);
|
LOG.debug("Set license: "+lB);
|
||||||
depositionMetadata.setLicense(lB);
|
depositionMetadata.setLicense(lB.getId());
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
LOG.warn("Set license error: ",e);
|
LOG.warn("Set license error: ",e);
|
||||||
}
|
}
|
||||||
|
@ -563,6 +568,7 @@ public class ItemToZenodoConverter {
|
||||||
return depositionMetadata;
|
return depositionMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To creators.
|
* To creators.
|
||||||
*
|
*
|
||||||
|
@ -632,4 +638,6 @@ public class ItemToZenodoConverter {
|
||||||
return listOfContributors;
|
return listOfContributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ItemTranslateError implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new zenodo translate error.
|
* Instantiates a new zenodo translate error.
|
||||||
*/
|
*/
|
||||||
public ItemTranslateError() {
|
ItemTranslateError() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface ZenodoLicense.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jan 21, 2020
|
||||||
|
*/
|
||||||
|
public interface ZenodoLicense {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
String getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the title.
|
||||||
|
*
|
||||||
|
* @return the title
|
||||||
|
*/
|
||||||
|
String getTitle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the url.
|
||||||
|
*
|
||||||
|
* @return the url
|
||||||
|
*/
|
||||||
|
String getUrl();
|
||||||
|
|
||||||
|
}
|
|
@ -1,92 +0,0 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class DOI_dv.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
||||||
*
|
|
||||||
* Jul 28, 2023
|
|
||||||
*/
|
|
||||||
public class DOI_dv implements Serializable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private String doi;
|
|
||||||
private String doi_url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new DO I dv.
|
|
||||||
*/
|
|
||||||
public DOI_dv() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new DO I dv.
|
|
||||||
*
|
|
||||||
* @param doi the doi
|
|
||||||
* @param doi_url the doi url
|
|
||||||
*/
|
|
||||||
public DOI_dv(String doi, String doi_url) {
|
|
||||||
super();
|
|
||||||
this.doi = doi;
|
|
||||||
this.doi_url = doi_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the doi.
|
|
||||||
*
|
|
||||||
* @return the doi
|
|
||||||
*/
|
|
||||||
public String getDoi() {
|
|
||||||
return doi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the doi url.
|
|
||||||
*
|
|
||||||
* @return the doi url
|
|
||||||
*/
|
|
||||||
public String getDoi_url() {
|
|
||||||
return doi_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the doi.
|
|
||||||
*
|
|
||||||
* @param doi the new doi
|
|
||||||
*/
|
|
||||||
public void setDoi(String doi) {
|
|
||||||
this.doi = doi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the doi url.
|
|
||||||
*
|
|
||||||
* @param doi_url the new doi url
|
|
||||||
*/
|
|
||||||
public void setDoi_url(String doi_url) {
|
|
||||||
this.doi_url = doi_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To string.
|
|
||||||
*
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("DOI_dv [doi=");
|
|
||||||
builder.append(doi);
|
|
||||||
builder.append(", doi_url=");
|
|
||||||
builder.append(doi_url);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.ZenodoLicense;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A license bean like the ckan's one.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jan 13, 2020
|
||||||
|
*/
|
||||||
|
public class LicenseBean implements Serializable, ZenodoLicense{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 6618784269251750489L;
|
||||||
|
private String id;
|
||||||
|
private String title;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new license bean.
|
||||||
|
*/
|
||||||
|
public LicenseBean() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new license bean.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param title the title
|
||||||
|
* @param url the url
|
||||||
|
*/
|
||||||
|
public LicenseBean(String id, String title, String url) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj.getClass().equals(this.getClass()) && ((LicenseBean)obj).getTitle().equals(this.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("LicenseBean [id=");
|
||||||
|
builder.append(id);
|
||||||
|
builder.append(", title=");
|
||||||
|
builder.append(title);
|
||||||
|
builder.append(", url=");
|
||||||
|
builder.append(url);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,71 +0,0 @@
|
||||||
//package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
|
||||||
//
|
|
||||||
//import java.io.Serializable;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * A license bean like the ckan's one.
|
|
||||||
// *
|
|
||||||
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
||||||
// *
|
|
||||||
// * Jan 13, 2020
|
|
||||||
// */
|
|
||||||
//public class LicenseDTO implements Serializable {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
// private static final long serialVersionUID = 8796338619448833841L;
|
|
||||||
// private String id;
|
|
||||||
// private String title;
|
|
||||||
// private String url;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Instantiates a new license bean.
|
|
||||||
// */
|
|
||||||
// public LicenseDTO() {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public LicenseDTO(String id, String title, String url) {
|
|
||||||
// this.id = id;
|
|
||||||
// this.title = title;
|
|
||||||
// this.url = url;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getId() {
|
|
||||||
// return id;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getTitle() {
|
|
||||||
// return title;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getUrl() {
|
|
||||||
// return url;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setId(String id) {
|
|
||||||
// this.id = id;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setTitle(String title) {
|
|
||||||
// this.title = title;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setUrl(String url) {
|
|
||||||
// this.url = url;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String toString() {
|
|
||||||
// StringBuilder builder = new StringBuilder();
|
|
||||||
// builder.append("LicenseDTO [id=");
|
|
||||||
// builder.append(id);
|
|
||||||
// builder.append(", title=");
|
|
||||||
// builder.append(title);
|
|
||||||
// builder.append(", url=");
|
|
||||||
// builder.append(url);
|
|
||||||
// builder.append("]");
|
|
||||||
// return builder.toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +10,7 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
*
|
*
|
||||||
* Jan 15, 2020
|
* Jan 15, 2020
|
||||||
*/
|
*/
|
||||||
public class ZenodoContributor extends ZenodoCreator implements Serializable {
|
public class ZenodoContributor extends ZenodoCreator{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ZenodoDateInterval implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Instantiates a new zenodo date interval.
|
* Instantiates a new zenodo date interval.
|
||||||
*/
|
*/
|
||||||
public ZenodoDateInterval() {
|
ZenodoDateInterval() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
//package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * The Interface ZenodoLicense.
|
|
||||||
// *
|
|
||||||
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
||||||
// *
|
|
||||||
// * Jan 21, 2020
|
|
||||||
// */
|
|
||||||
//public interface ZenodoLicense {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the id.
|
|
||||||
// *
|
|
||||||
// * @return the id
|
|
||||||
// */
|
|
||||||
// String getId();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the title.
|
|
||||||
// *
|
|
||||||
// * @return the title
|
|
||||||
// */
|
|
||||||
// String getTitle();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the url.
|
|
||||||
// *
|
|
||||||
// * @return the url
|
|
||||||
// */
|
|
||||||
// String getUrl();
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -77,9 +77,7 @@ public class ZenodoMetadata implements Serializable {
|
||||||
private List<ZenodoDateInterval> dates;
|
private List<ZenodoDateInterval> dates;
|
||||||
private String method; // TODO html
|
private String method; // TODO html
|
||||||
|
|
||||||
// private SerializableEnum<String> licenseIDs;
|
private SerializableEnum<LicenseBean> licenses;
|
||||||
|
|
||||||
private List<String> licenseIDs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new zenodo metadata.
|
* Instantiates a new zenodo metadata.
|
||||||
|
@ -105,20 +103,10 @@ public class ZenodoMetadata implements Serializable {
|
||||||
this.upload_type = upload_type;
|
this.upload_type = upload_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the contributors types.
|
|
||||||
*
|
|
||||||
* @return the contributors types
|
|
||||||
*/
|
|
||||||
public SerializableEnum<String> getContributorsTypes() {
|
public SerializableEnum<String> getContributorsTypes() {
|
||||||
return contributorsTypes;
|
return contributorsTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the contributors types.
|
|
||||||
*
|
|
||||||
* @param contributorsTypes the new contributors types
|
|
||||||
*/
|
|
||||||
public void setContributorsTypes(SerializableEnum<String> contributorsTypes) {
|
public void setContributorsTypes(SerializableEnum<String> contributorsTypes) {
|
||||||
this.contributorsTypes = contributorsTypes;
|
this.contributorsTypes = contributorsTypes;
|
||||||
}
|
}
|
||||||
|
@ -880,28 +868,23 @@ public class ZenodoMetadata implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the license IDs.
|
* Sets the licenses.
|
||||||
*
|
*
|
||||||
* @param licensesIDs the new license IDs
|
* @param licenses the new licenses
|
||||||
*/
|
*/
|
||||||
public void setLicenseIDs(List<String> licensesIDs) {
|
public void setLicenses(SerializableEnum<LicenseBean> licenses) {
|
||||||
this.licenseIDs = licensesIDs;
|
this.licenses = licenses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the license IDs.
|
* Gets the licenses.
|
||||||
*
|
*
|
||||||
* @return the license IDs
|
* @return the licenses
|
||||||
*/
|
*/
|
||||||
public List<String> getLicenseIDs() {
|
public SerializableEnum<LicenseBean> getLicenses() {
|
||||||
return licenseIDs;
|
return licenses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To string.
|
|
||||||
*
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -991,8 +974,8 @@ public class ZenodoMetadata implements Serializable {
|
||||||
builder.append(dates);
|
builder.append(dates);
|
||||||
builder.append(", method=");
|
builder.append(", method=");
|
||||||
builder.append(method);
|
builder.append(method);
|
||||||
builder.append(", licenseIDs=");
|
builder.append(", licenses=");
|
||||||
builder.append(licenseIDs);
|
builder.append(licenses);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,19 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.util.regex.Matcher;
|
||||||
import java.util.Date;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.ws.rs.client.Entity;
|
|
||||||
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.Fixer;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
|
|
||||||
public class Tester {
|
public class Tester {
|
||||||
|
|
||||||
public static String expression = "^\\/dataset(\\?([a-zA-Z0-9_.-]*.+))*";
|
public static String expression = "^\\/dataset(\\?([a-zA-Z0-9_.-]*.+))*";
|
||||||
public static String toMatch = "/dataset?systemtype=E39_Actor&groups=huma_num___nakala";
|
public static String toMatch = "/dataset?systemtype=E39_Actor&groups=huma_num___nakala";
|
||||||
|
|
||||||
private static ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
static {
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
|
|
||||||
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
|
|
||||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
|
||||||
// mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// Pattern p = Pattern.compile(expression);
|
|
||||||
// Matcher m = p.matcher(toMatch);
|
|
||||||
// boolean b = m.matches();
|
|
||||||
//
|
|
||||||
// System.out.println(b);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Pattern p = Pattern.compile(expression);
|
||||||
|
Matcher m = p.matcher(toMatch);
|
||||||
|
boolean b = m.matches();
|
||||||
|
|
||||||
//ObjectMapper mapper = new ObjectMapper();
|
System.out.println(b);
|
||||||
ZenodoDeposition zed = new ZenodoDeposition();
|
|
||||||
DepositionMetadata metadata = new DepositionMetadata();
|
|
||||||
metadata.setPublication_date(Date.from(Instant.now()));
|
|
||||||
//zed.setMetadata(metadata);
|
|
||||||
|
|
||||||
String serialized;
|
|
||||||
try {
|
|
||||||
System.out.println("init json: "+mapper.writeValueAsString(metadata));
|
|
||||||
|
|
||||||
serialized = "{\"metadata\":"+Fixer.fixIncoming(mapper.writeValueAsString(metadata))+"}";
|
|
||||||
System.out.println("serialized: "+serialized);
|
|
||||||
|
|
||||||
Entity<String> JSON = Entity.json(serialized);
|
|
||||||
System.out.println("JSON: "+JSON);
|
|
||||||
ZenodoDeposition object = mapper.readValue(Fixer.fixIncoming(serialized), ZenodoDeposition.class);
|
|
||||||
System.out.println("ZenodoDeposition: "+object);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println(metadata.getPublication_date());
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// updateMetadata(metadata);
|
|
||||||
// } catch (ZenodoException e) {
|
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ZenodoDeposition updateMetadata(DepositionMetadata meta) throws ZenodoException {
|
|
||||||
try{
|
|
||||||
String serialized="{\"metadata\":"+Fixer.fixIncoming(mapper.writeValueAsString(meta))+"}";
|
|
||||||
System.out.println("serialized: "+serialized);
|
|
||||||
try {
|
|
||||||
// Response resp = getWebClient().target(credentials.getBaseUrl()).
|
|
||||||
// path(DEPOSITION_BASE_URL).path(depositionId+"").
|
|
||||||
// queryParam(ACCESS_TOKEN, credentials.getKey()).request(CONTENT_TYPE)
|
|
||||||
// .put(Entity.json(serialized));
|
|
||||||
// return check(resp,ZenodoDeposition.class);
|
|
||||||
|
|
||||||
Entity<String> JSON = Entity.json(serialized);
|
|
||||||
System.out.println("JSON: "+JSON);
|
|
||||||
return mapper.readValue(Fixer.fixIncoming(serialized), ZenodoDeposition.class);
|
|
||||||
}catch(Throwable t) {
|
|
||||||
System.out.println("Error while tryin to update "+serialized);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}catch(JsonProcessingException e) {
|
|
||||||
System.out.println("Error while parsing "+meta + " " +e);
|
|
||||||
throw new ZenodoException("Internal error.",e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue