Skip to content

Commit

Permalink
Merge pull request #6 from DiSSCo/feature/tombstoning
Browse files Browse the repository at this point in the history
add tombstoning event
  • Loading branch information
southeo authored Aug 29, 2024
2 parents aebbbf3 + b4e12d6 commit cf69c79
Show file tree
Hide file tree
Showing 33 changed files with 654 additions and 193 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<version>3.3.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>eu.dissco.core</groupId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/eu/dissco/core/datacitepublisher/Profiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Profiles {
private Profiles() {
}

public static final String TEST = "test";
public static final String SANDBOX = "sandbox";
public static final String PRODUCTION = "production";

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import eu.dissco.core.datacitepublisher.exceptions.InvalidFdoProfileRecievedException;
import eu.dissco.core.datacitepublisher.exceptions.InvalidFdoProfileReceivedException;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
Expand All @@ -22,7 +22,7 @@ public class XmlLocReader {
@Qualifier("xmlMapper")
private final XmlMapper xmlMapper;

public List<String> getLocationsFromXml(String xmlDoc) throws InvalidFdoProfileRecievedException {
public List<String> getLocationsFromXml(String xmlDoc) throws InvalidFdoProfileReceivedException {
if (xmlDoc == null) {
log.warn("No url provided");
return Collections.emptyList();
Expand All @@ -32,7 +32,7 @@ public List<String> getLocationsFromXml(String xmlDoc) throws InvalidFdoProfileR
return locations.getLocation().stream().map(LocationXml::getHref).toList();
} catch (JsonProcessingException e){
log.error("Unable to parse 10320/loc field for fdo", e);
throw new InvalidFdoProfileRecievedException();
throw new InvalidFdoProfileReceivedException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import lombok.RequiredArgsConstructor;
Expand All @@ -17,8 +18,8 @@ public class ApplicationConfig {

public static final DateTimeFormatter FDO_FORMATTER = DateTimeFormatter.ofPattern(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX").withZone(ZoneOffset.UTC);
public static final DateTimeFormatter DATACITE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

public static final DateTimeFormatter DATACITE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd")
.withZone(ZoneId.of("UTC"));

@Bean
public ObjectMapper objectMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ public WebClient dataciteClient() {

@Bean("handle")
public WebClient handleClient() {
ExchangeFilterFunction errorResponseFilter = ExchangeFilterFunction
.ofResponseProcessor(WebClientUtils::exchangeFilterResponseProcessor);
return WebClient.builder()
.baseUrl(handleProperties.getEndpoint())
.filter(errorResponseFilter)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package eu.dissco.core.datacitepublisher.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

public enum EventType {
@JsonProperty("create") CREATE,
@JsonPropertyOrder("update") UPDATE;
@JsonProperty("update") UPDATE,
@JsonProperty("tombstone") TOMBSTONE;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package eu.dissco.core.datacitepublisher.domain;

import eu.dissco.core.datacitepublisher.domain.datacite.DcRelatedIdentifiers;
import java.util.List;

public record TombstoneEvent(String handle, List<DcRelatedIdentifiers> dcRelatedIdentifiersTombstone) {


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
import static eu.dissco.core.datacitepublisher.domain.datacite.DataCiteConstants.DC_EVENT;
import static eu.dissco.core.datacitepublisher.domain.datacite.DataCiteConstants.PUBLISHER;
import static eu.dissco.core.datacitepublisher.domain.datacite.DataCiteConstants.SCHEMA_VERSION;
import static eu.dissco.core.datacitepublisher.properties.DoiProperties.DC_EVENT;
import static eu.dissco.core.datacitepublisher.properties.DoiProperties.SCHEMA_VERSION;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.jackson.Jacksonized;

@Builder
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@JsonInclude(NON_EMPTY)
@Jacksonized
@JsonIgnoreProperties(ignoreUnknown = true)
public class DcAttributes {

private String suffix;
Expand All @@ -33,7 +36,7 @@ public class DcAttributes {
private List<DcRelatedIdentifiers> relatedIdentifiers; // tombstone pids; primary specimenObjectId; primaryMediaId
private List<DcDescription> descriptions; // Specimen: Host + materialSampleType, Media: host + linked object type
private String url; // human readable landing page
private final DcPublisher publisher = PUBLISHER;
private DcPublisher publisher;
private final String schemaVersion = SCHEMA_VERSION;
private final String event = DC_EVENT;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -11,6 +12,7 @@
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class DcContributor {

private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -11,6 +12,7 @@
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class DcCreator {
private final String nameType= "Organizational";
private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -10,6 +11,7 @@
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class DcData {

private final String type = "dois";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
@NoArgsConstructor
public class DcDate {
private String date;
private final String dateType = "Issued";
private String dateType;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Builder
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@NoArgsConstructor
public class DcDescription {
private String description;
private final String descriptionType = "TechnicalInfo";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package eu.dissco.core.datacitepublisher.domain.datacite;


import lombok.Value;

@Value
public class DcPublisher {
String name = "Distributed System of Scientific Collections";
String publisherIdentifier = "https://ror.org/0566bfb96";
String publisherIdentifierScheme = UriScheme.ROR.getSchemeName();
String schemeUri = UriScheme.ROR.getUri();
String name;
String publisherIdentifier;
String publisherIdentifierScheme;
String schemeUri;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Setter(value = AccessLevel.PACKAGE)
@Getter
public class DcRelatedIdentifiers {
private String relationType;
private RelationType relationType;
private String relatedIdentifier;
private String relatedIdentifierType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Builder
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@NoArgsConstructor
public class DcTitle {
private String title;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import static eu.dissco.core.datacitepublisher.domain.datacite.DataCiteConstants.RESOURCE_TYPE_GENERAL;

import static eu.dissco.core.datacitepublisher.properties.DoiProperties.RESOURCE_TYPE_GENERAL;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Builder
@AllArgsConstructor
@Setter(value = AccessLevel.PACKAGE)
@Getter
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class DcType {

private String resourceType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package eu.dissco.core.datacitepublisher.domain.datacite;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum RelationType {
@JsonProperty("IsCitedBy") IS_CITED_BY,
@JsonProperty("Cites") CITES,
@JsonProperty("IsSupplementTo") IS_SUPPLEMENT_TO,
@JsonProperty("IsSupplementedBy") IS_SUPPLEMENTED_BY,
@JsonProperty("IsContinuedBy") IS_CONTINUED_BY,
@JsonProperty("Continues") CONTINUES,
@JsonProperty("IsDescribedBy") IS_DESCRIBED_BY,
@JsonProperty("Describes") DESCRIBES,
@JsonProperty("HasMetadata") HAS_METADATA,
@JsonProperty("IsMetadataFor") IS_METADATA_FOR,
@JsonProperty("HasVersion") HAS_VERSION,
@JsonProperty("IsVersionOf") IS_VERSION_OF,
@JsonProperty("IsNewVersionOf") IS_NEW_VERSION_OF,
@JsonProperty("IsPreviousVersionOf") IS_PREVIOUS_VERSION_OF,
@JsonProperty("IsPartOf") IS_PART_OF,
@JsonProperty("HasPart") HAS_PART,
@JsonProperty("IsPublishedIn") IS_PUBLISHED_IN,
@JsonProperty("IsReferencedBy") IS_REFERENCED_BY,
@JsonProperty("References") REFERENCES,
@JsonProperty("IsDocumentedBy") IS_DOCUMENTED_BY,
@JsonProperty("Documents") DOCUMENTS,
@JsonProperty("IsCompiledBy") IS_COMPILED_BY,
@JsonProperty("Compiles") COMPILES,
@JsonProperty("IsVariantFormOf") IS_VARIANT_FORM_OF,
@JsonProperty("IsOriginalFormOf") IS_ORIGINAL_FORM_OF,
@JsonProperty("IsIdenticalTo") IS_IDENTICAL_TO,
@JsonProperty("IsReviewedBy") IS_REVIEWED_BY,
@JsonProperty("Reviews") REVIEWS,
@JsonProperty("IsDerivedFrom") IS_DERIVED_FROM,
@JsonProperty("IsSourceOf") IS_SOURCE_OF,
@JsonProperty("IsRequiredBy") IS_REQUIRED_BY,
@JsonProperty("Requires") REQUIRES,
@JsonProperty("IsObsoletedBy") IS_OBSOLETED_BY,
@JsonProperty("Obsoletes") OBSOLETES;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package eu.dissco.core.datacitepublisher.exceptions;

public class InvalidFdoProfileReceivedException extends InvalidRequestException {

public InvalidFdoProfileReceivedException() {
super();
}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package eu.dissco.core.datacitepublisher.exceptions;

public class InvalidRequestException extends Exception {
public InvalidRequestException(){
super();
}

}
Loading

0 comments on commit cf69c79

Please sign in to comment.