Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple DOI servers #8098

Merged
merged 17 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ exception.doi.serverErrorDelete=Error deleting DOI
exception.doi.serverErrorDelete.description=Error deleting DOI: {0}
exception.doi.serverErrorUnregister=Error unregistering DOI
exception.doi.serverErrorUnregister.description=Error unregistering DOI: {0}
exception.doi.serverCanNotHandleRecord=DOI server can not handle the metadata
exception.doi.serverCanNotHandleRecord.description=DOI server ''{0}'' can not handle the metadata with UUID ''{1}''
exception.doi.configurationMissing=DOI server configuration is not complete
exception.doi.configurationMissing.description=DOI server configuration is not complete. Check the DOI server configuration to complete it
exception.doi.notSupportedOperationError=Operation not supported
exception.doi.notSupportedOperationError.description={0}
api.metadata.import.importedWithId=Metadata imported with ID '%s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ exception.doi.serverErrorDelete=Erreur lors de la suppression du DOI
exception.doi.serverErrorDelete.description=Erreur lors de la suppression du DOI : {0}
exception.doi.serverErrorUnregister=Erreur lors de la d\u00E9sinscription du DOI
exception.doi.serverErrorUnregister.description=Erreur lors de la d\u00E9sinscription du DOI {0}
exception.doi.serverCanNotHandleRecord=DOI server can not handle the metadata
exception.doi.serverCanNotHandleRecord.description=DOI server ''{0}'' can not handle the metadata with UUID ''{1}''
exception.doi.configurationMissing=DOI server configuration is not complete
exception.doi.configurationMissing.description=DOI server configuration is not complete. Check the DOI server configuration to complete it
exception.doi.notSupportedOperationError=Op\u00E9ration non prise en charge
exception.doi.notSupportedOperationError.description={0}
api.metadata.import.importedWithId=Fiche import\u00E9e avec l'ID '%s'
Expand Down
16 changes: 14 additions & 2 deletions docs/manual/docs/user-guide/associating-resources/doi.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ The catalogue support DOI creation using:
- [DataCite API](https://support.datacite.org/docs/mds-api-guide).
- EU publication office API <https://ra.publications.europa.eu/servlet/ws/doidata?api=medra.org>

Configure the API access point in the `admin console --> settings`:
Configure the DOI API access point to publish the metadata in the `Admin console --> Settings --> Doi servers`:

![](img/doi-admin-console.png)
![](img/doi-create-server.png)

Providing the following information:

- `Name`: A descriptive name for the server.
- `Description`: (Optional) A verbose description of the server.
- `DataCite API endpoint`: The API url, usually https://mds.datacite.org or https://mds.test.datacite.org for testing.
- `DataCite username` / `DataCite password`: Credentials required to publish the DOI resources.
- `Landing page URL template`: The URL to use to register the DOI. A good default for GeoNetwork is http://localhost:8080/geonetwork/srv/resources/records/{{uuid}}. The landing page URL MUST contains the UUID of the record.
- `Final DOI URL prefix`: (Optional) Keep it empty to use the default https://doi.org prefix. Use https://mds.test.datacite.org/doi when using the test API.
- `DOI pattern`: Default is `{{uuid}}` but the DOI structure can be customized with database id and/or record group eg. `example-{{groupOwner}}-{{id}}`.
- `DataCite prefix`: Usually looks like `10.xxxx`. You will be allowed to register DOI names only under the prefixes that have been assigned to you.
- `Publication groups`: (Optional) Select the groups which metadata should be published to the DOI server. If no groups are selected, the server will be provided to publish the metadata that has no other DOI servers related to the metadata owner group.

A record can be downloaded using the DataCite format from the API using: <http://localhost:8080/geonetwork/srv/api/records/da165110-88fd-11da-a88f-000d939bc5d8/formatters/datacite?output=xml>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
301 changes: 138 additions & 163 deletions doi/src/main/java/org/fao/geonet/doi/client/DoiManager.java

Large diffs are not rendered by default.

284 changes: 284 additions & 0 deletions domain/src/main/java/org/fao/geonet/domain/DoiServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/

package org.fao.geonet.domain;

import org.fao.geonet.entitylistener.DoiServerEntityListenerManager;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "Doiservers")
@Cacheable
@Access(AccessType.PROPERTY)
@EntityListeners(DoiServerEntityListenerManager.class)
@SequenceGenerator(name = DoiServer.ID_SEQ_NAME, initialValue = 100, allocationSize = 1)
public class DoiServer extends GeonetEntity {
static final String ID_SEQ_NAME = "doiserver_id_seq";

private int id;
private String name;
private String description;
private String url;
private String username;
private String password;
private String landingPageTemplate;
private String publicUrl;
private String pattern = "{{uuid}}";
private String prefix;
private Set<Group> publicationGroups = new HashSet<>();

/**
* Get the id of the DOI server. <p> This is autogenerated and when a new DOI server is created
* the DOI server will be assigned a new value. </p>
*
* @return the id of the DOI server.
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ID_SEQ_NAME)
@Column(nullable = false)
public int getId() {
return id;
}

/**
* Set the id of the DOI server. <p> If you want to update an existing DOI server then you should
* set this id to the DOI server you want to update and set the other values to the desired
* values. </p>
*
* @param id the id of the group.
* @return this DOI server object
*/
public DoiServer setId(int id) {
this.id = id;
return this;
}

/**
* Get the basic/default name of the DOI server. This is non-translated and can be used to look
* up the DOI server like an id can. <p> This is a required property. <p> There is a max length
* to the name allowed. See the annotation for the length value. </p>
*
* @return DOI server name
*/
@Column(nullable = false, length = 32)
public String getName() {
return name;
}

/**
* Set the basic/default name of the DOI server. This is non-translated and can be used to look
* up the DOI server like an id can. <p> This is a required property. <p> There is a max length
* to the name allowed. See the annotation on {@link #getName()} for the length value. </p>
*/
public DoiServer setName(String name) {
this.name = name;
return this;
}

/**
* Get a description of the DOI server.
*
* @return the description.
*/
@Column(length = 255)
public String getDescription() {
return description;
}

/**
* Set the DOI server description.
*
* @param description the description.
* @return this DOI server object.
*/
public DoiServer setDescription(String description) {
this.description = description;
return this;
}


/**
* Get the API URL for the DOI server.
*
* @return the DOI server API URL.
*/
@Column(nullable = false, length = 255)
public String getUrl() {
return url;
}

/**
* Set the REST API configuration URL for the DOI server.
*
* @param url the server URL.
* @return this DOI server object.
*/
public DoiServer setUrl(String url) {
this.url = url;
return this;
}

/**
* Get the username to use for connecting to the DOI server.
*
* @return the username.
*/
@Column(length = 128)
public String getUsername() {
return username;
}

public DoiServer setUsername(String username) {
this.username = username;
return this;
}

/**
* Get the password to use for connecting to the DOI server.
*
* @return the password.
*/
@Column(length = 128)
@Type(type="encryptedString")
public String getPassword() {
return password;
}

public DoiServer setPassword(String password) {
this.password = password;
return this;
}

/**
* Set the DOI landing page URL template.
*
* @param landingPageTemplate the landing page URL template.
* @return this DOI server object.
*/
public DoiServer setLandingPageTemplate(String landingPageTemplate) {
this.landingPageTemplate = landingPageTemplate;
return this;
}

/**
* Get the DOI landing page URL template.
*
* @return the landing page URL template.
*/
@Column(nullable = false, length = 255)
public String getLandingPageTemplate() {
return landingPageTemplate;
}

/**
* Set the DOI URL prefix.
*
* @param publicUrl the URL prefix.
* @return this DOI server object.
*/
public DoiServer setPublicUrl(String publicUrl) {
this.publicUrl = publicUrl;
return this;
}

/**
* Get the DOI URL prefix.
*
* @return the URL prefix.
*/
@Column(nullable = false, length = 255)
public String getPublicUrl() {
return publicUrl;
}

/**
* Set the DOI identifier pattern.
*
* @param pattern the identifier pattern.
* @return this DOI server object.
*/
public DoiServer setPattern(String pattern) {
this.pattern = pattern;
return this;
}

/**
* Get the DOI identifier pattern.
*
* @return the identifier pattern.
*/
@Column(nullable = false, length = 255)
public String getPattern() {
return pattern;
}


/**
* Set the DOI prefix.
*
* @param prefix the DOI prefix.
* @return this DOI server object.
*/
public DoiServer setPrefix(String prefix) {
this.prefix = prefix;
return this;
}

/**
* Get the DOI prefix.
*
* @return the DOI prefix.
*/
@Column(nullable = false, length = 15)
public String getPrefix() {
return prefix;
}

/**
* Sets the groups which metadata should be published to the DOI server.
*
* @param publicationGroups Publication groups.
* @return
*/
public void setPublicationGroups(Set<Group> publicationGroups) {
this.publicationGroups = publicationGroups;
}

/**
* Get the groups which metadata is published to the DOI server.
*
* @return Publication groups.
*/
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
@JoinTable(
name = "doiservers_group",
joinColumns = @JoinColumn(name = "doiserver_id"),
inverseJoinColumns = @JoinColumn(name = "group_id"))
public Set<Group> getPublicationGroups() {
return publicationGroups;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/

package org.fao.geonet.entitylistener;

import org.fao.geonet.domain.DoiServer;

import javax.persistence.*;

public class DoiServerEntityListenerManager extends AbstractEntityListenerManager<DoiServer> {
@PrePersist
public void prePresist(final DoiServer entity) {
handleEvent(PersistentEventType.PrePersist, entity);
}

@PreRemove
public void preRemove(final DoiServer entity) {
handleEvent(PersistentEventType.PreRemove, entity);
}

@PostPersist
public void postPersist(final DoiServer entity) {
handleEvent(PersistentEventType.PostPersist, entity);
}

@PostRemove
public void postRemove(final DoiServer entity) {
handleEvent(PersistentEventType.PostRemove, entity);
}

@PreUpdate
public void preUpdate(final DoiServer entity) {
handleEvent(PersistentEventType.PreUpdate, entity);
}

@PostUpdate
public void postUpdate(final DoiServer entity) {
handleEvent(PersistentEventType.PostUpdate, entity);
}

@PostLoad
public void postLoad(final DoiServer entity) {
handleEvent(PersistentEventType.PostLoad, entity);
}
}
Loading