Skip to content

Commit

Permalink
Hardcode fdo profiles (#83)
Browse files Browse the repository at this point in the history
* Hardcode fdo profiles

* Use type PID instead of resolved name

* DigitalObjectType no longer needed in request

* refactor

* remove fdoprofile from request

* update fdo profile

* Evict cache every 12 hours (#77)

* Hardcode fdo profiles

* Use type PID instead of resolved name

* DigitalObjectType no longer needed in request

* refactor

* remove fdoprofile from request

* update fdo profile

* code reivew

* code reivew

* soanr
  • Loading branch information
southeo authored May 21, 2024
1 parent 48b4416 commit 65ede79
Show file tree
Hide file tree
Showing 59 changed files with 3,819 additions and 4,352 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package eu.dissco.core.handlemanager.controller;


import static eu.dissco.core.handlemanager.domain.JsonApiFields.NODE_DATA;
import static eu.dissco.core.handlemanager.domain.JsonApiFields.NODE_ID;
import static eu.dissco.core.handlemanager.domain.jsonapi.JsonApiFields.NODE_DATA;
import static eu.dissco.core.handlemanager.domain.jsonapi.JsonApiFields.NODE_ID;

import com.fasterxml.jackson.databind.JsonNode;
import eu.dissco.core.handlemanager.domain.jsonapi.JsonApiWrapperRead;
import eu.dissco.core.handlemanager.domain.jsonapi.JsonApiWrapperReadSingle;
import eu.dissco.core.handlemanager.domain.jsonapi.JsonApiWrapperWrite;
import eu.dissco.core.handlemanager.domain.requests.RollbackRequest;
import eu.dissco.core.handlemanager.domain.requests.validation.JsonSchemaValidator;
import eu.dissco.core.handlemanager.domain.validation.JsonSchemaValidator;
import eu.dissco.core.handlemanager.exceptions.DatabaseCopyException;
import eu.dissco.core.handlemanager.exceptions.InvalidRequestException;
import eu.dissco.core.handlemanager.exceptions.PidCreationException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package eu.dissco.core.handlemanager.domain.requests.objects;
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonProperty;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.annotation.Motivation;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.annotation.Motivation;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import java.util.UUID;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -22,16 +22,14 @@ public class AnnotationRequest extends HandleRecordRequest {
private final UUID annotationHash;

public AnnotationRequest(
String fdoProfile,
String issuedForAgent,
String digitalObjectType,
String pidIssuer,
String[] locations,
String targetPid,
String targetType,
Motivation motivation,
UUID annotationHash) {
super(fdoProfile, issuedForAgent, digitalObjectType, pidIssuer, StructuralType.DIGITAL,
super(issuedForAgent, pidIssuer, StructuralType.DIGITAL,
locations);
this.targetPid = targetPid;
this.targetType = targetType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package eu.dissco.core.handlemanager.domain.requests.objects;
package eu.dissco.core.handlemanager.domain.fdo;

import static eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.PrimarySpecimenObjectIdType.LOCAL;
import static eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.PrimarySpecimenObjectIdType.LOCAL;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.BaseTypeOfSpecimen;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.InformationArtefactType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.LivingOrPreserved;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.MaterialOrDigitalEntity;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.MaterialSampleType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.ObjectType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.PrimarySpecimenObjectIdType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.TopicCategory;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.TopicDiscipline;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.TopicDomain;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.TopicOrigin;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.BaseTypeOfSpecimen;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.InformationArtefactType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.LivingOrPreserved;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.MaterialOrDigitalEntity;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.MaterialSampleType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.OtherSpecimenId;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.PrimarySpecimenObjectIdType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.TopicCategory;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.TopicDiscipline;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.TopicDomain;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.TopicOrigin;
import eu.dissco.core.handlemanager.exceptions.InvalidRequestException;
import java.util.List;
import lombok.EqualsAndHashCode;
Expand All @@ -36,10 +36,11 @@ public class DigitalSpecimenRequest extends DoiRecordRequest {
@JsonPropertyDescription("Local identifier for the given specimen")
@JsonProperty(required = true)
private final String primarySpecimenObjectId;
@JsonPropertyDescription("ID Type. Either combined or cetaf. Defaults to combined.")
@JsonPropertyDescription("ID Type: Global, Local, or Resolvable.")
private final PrimarySpecimenObjectIdType primarySpecimenObjectIdType;
@Nullable
private final String primarySpecimenObjectIdName;
@JsonProperty(required = true)
private final String normalisedPrimarySpecimenObjectId;
@Nullable
private final String primarySpecimenObjectIdAbsenceReason;
Expand Down Expand Up @@ -72,9 +73,7 @@ public class DigitalSpecimenRequest extends DoiRecordRequest {

public DigitalSpecimenRequest(
// Handle
String fdoProfile,
String issuedForAgent,
String digitalObjectTypePid,
String pidIssuer,
String[] locations,
// Doi
Expand All @@ -100,9 +99,9 @@ public DigitalSpecimenRequest(
MaterialOrDigitalEntity materialOrDigitalEntity,
Boolean markedAsType,
String derivedFromEntity, String catalogIdentifier) throws InvalidRequestException {
super(fdoProfile, issuedForAgent, digitalObjectTypePid, pidIssuer, StructuralType.DIGITAL,
super(issuedForAgent, pidIssuer, StructuralType.DIGITAL,
locations,
referentName, ObjectType.DIGITAL_SPECIMEN, primaryReferentType);
referentName, FdoType.DIGITAL_SPECIMEN.getDigitalObjectName(), primaryReferentType);
this.specimenHost = specimenHost;
this.specimenHostName = specimenHostName;
this.primarySpecimenObjectId = primarySpecimenObjectId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package eu.dissco.core.handlemanager.domain.requests.objects;
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.ObjectType;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
Expand All @@ -24,18 +23,16 @@ public class DoiRecordRequest extends HandleRecordRequest {

public DoiRecordRequest(
// Handle
String fdoProfile,
String issuedForAgent,
String digitalObjectType,
String pidIssuer,
StructuralType structuralType,
String[] locations,
// Doi
String referentName,
ObjectType referentType,
String referentType,
String primaryReferentType) {
super(fdoProfile, issuedForAgent, digitalObjectType, pidIssuer, structuralType, locations);
this.referentType = referentType.toString();
super(issuedForAgent, pidIssuer, structuralType, locations);
this.referentType = referentType;
this.referentName = referentName;
this.primaryReferentType = setDefault(primaryReferentType, "creation");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.dissco.core.handlemanager.domain;
package eu.dissco.core.handlemanager.domain.fdo;

import eu.dissco.core.handlemanager.exceptions.UnrecognizedFdoAttributeException;
import java.util.Arrays;
Expand Down Expand Up @@ -70,7 +70,7 @@ public enum FdoProfile {
RIGHTSHOLDER_NAME("rightsholderName", 416),
RIGHTSHOLDER_PID("rightsholderPid", 417),
RIGHTSHOLDER_PID_TYPE("rightsholderPidType", 418),
DC_TERMS_CONFORMS("dcterms:conforms", 419),
DC_TERMS_CONFORMS("dcterms:conformsTo", 419),

// Annotation
TARGET_PID("targetPid", 500),
Expand Down
76 changes: 76 additions & 0 deletions src/main/java/eu/dissco/core/handlemanager/domain/fdo/FdoType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Getter
public enum FdoType {
@JsonProperty("https://hdl.handle.net/21.T11148/532ce6796e2828dd2be6") HANDLE(
"Handle Kernel",
"https://hdl.handle.net/21.T11148/532ce6796e2828dd2be6",
"https://hdl.handle.net/21.T11148/532ce6796e2828dd2be6"),
@JsonProperty("https://hdl.handle.net/21.T11148/527856fd709ec8c5bc8c") DOI(
"DOI Kernel",
"https://hdl.handle.net/21.T11148/527856fd709ec8c5bc8c",
"https://hdl.handle.net/21.T11148/527856fd709ec8c5bc8c"),
@JsonProperty("https://hdl.handle.net/21.T11148/894b1e6cad57e921764e") DIGITAL_SPECIMEN(
"DigitalSpecimen",
"https://hdl.handle.net/21.T11148/894b1e6cad57e921764e",
"https://hdl.handle.net/21.T11148/894b1e6cad57e921764e"),
@JsonProperty("https://hdl.handle.net/21.T11148/bbad8c4e101e8af01115") MEDIA_OBJECT(
"MediaObject",
"https://hdl.handle.net/21.T11148/bbad8c4e101e8af01115",
"https://hdl.handle.net/21.T11148/bbad8c4e101e8af01115"),
@JsonProperty("https://hdl.handle.net/21.T11148/cf458ca9ee1d44a5608f") ANNOTATION(
"Annotation",
"https://hdl.handle.net/21.T11148/cf458ca9ee1d44a5608f",
"https://hdl.handle.net/21.T11148/cf458ca9ee1d44a5608f"),
@JsonProperty("https://hdl.handle.net/21.T11148/417a4f472f60f7974c12") SOURCE_SYSTEM(
"sourceSystem",
"https://hdl.handle.net/21.T11148/417a4f472f60f7974c12",
"https://hdl.handle.net/21.T11148/417a4f472f60f7974c12"),
@JsonProperty("https://hdl.handle.net/21.T11148/ce794a6f4df42eb7e77e") MAPPING(
"Mapping",
"https://hdl.handle.net/21.T11148/ce794a6f4df42eb7e77e",
"https://hdl.handle.net/21.T11148/ce794a6f4df42eb7e77e"),
@JsonProperty("https://hdl.handle.net/21.T11148/413c00cbd83ae33d1ac0") ORGANISATION(
"Organisation",
"https://hdl.handle.net/21.T11148/413c00cbd83ae33d1ac0",
"https://hdl.handle.net/21.T11148/413c00cbd83ae33d1ac0"),
@JsonProperty("https://hdl.handle.net/21.T11148/d7570227982f70256af3") TOMBSTONE(
"Tombstone",
"https://hdl.handle.net/21.T11148/d7570227982f70256af3",
"https://hdl.handle.net/21.T11148/d7570227982f70256af3"),
@JsonProperty("https://hdl.handle.net/21.T11148/22e71a0015cbcfba8ffa") MAS(
"Machine Annotation Service",
"https://hdl.handle.net/21.T11148/22e71a0015cbcfba8ffa",
"https://hdl.handle.net/21.T11148/22e71a0015cbcfba8ffa");

private final String digitalObjectName;
private final String digitalObjectType;
private final String fdoProfile;

FdoType(@JsonProperty("type") String digitalObjectName, String digitalObjectType,
String fdoProfile) {
this.digitalObjectName = digitalObjectName;
this.digitalObjectType = digitalObjectType;
this.fdoProfile = fdoProfile;
}

@Override
public String toString() {
return digitalObjectType;
}

public static FdoType fromString(String fdoTypePid) {
for (FdoType type : FdoType.values()) {
if (type.digitalObjectType.equalsIgnoreCase(fdoTypePid)) {
return type;
}
}
log.error("Unable to determine fdo type from {}, is it a PID?", fdoTypePid);
throw new IllegalArgumentException("No object type exists for " + fdoTypePid);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package eu.dissco.core.handlemanager.domain.requests.objects;
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -15,18 +15,10 @@
@EqualsAndHashCode
public class HandleRecordRequest {

@JsonProperty(required = true)
@JsonPropertyDescription("Handle of the FDO Profile")
private final String fdoProfile;

@JsonProperty(required = true)
@JsonPropertyDescription("ROR for the agent requesting the PID")
private final String issuedForAgent;

@JsonProperty(required = true)
@JsonPropertyDescription("PID for the Type of Digital Object")
private final String digitalObjectType;

@JsonPropertyDescription("ROR of the Registration Agency. Defaults to DataCite's ROR")
private final String pidIssuer;

Expand All @@ -42,16 +34,12 @@ public class HandleRecordRequest {
private static final String DATACITE_ROR = "https://ror.org/04wxnsj81";

public HandleRecordRequest(
String fdoProfile,
String issuedForAgent,
String digitalObjectType,
String pidIssuer,
StructuralType structuralType,
String[] locations
) {
this.fdoProfile = fdoProfile;
this.issuedForAgent = issuedForAgent;
this.digitalObjectType = digitalObjectType;
this.pidIssuer = setDefault(pidIssuer, DATACITE_ROR);
this.structuralType = structuralType == null ? StructuralType.DIGITAL : structuralType;
this.locations = locations;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.dissco.core.handlemanager.domain.requests.objects;
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonProperty;
import eu.dissco.core.handlemanager.domain.requests.vocabulary.specimen.StructuralType;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
Expand All @@ -14,9 +14,9 @@ public class MappingRequest extends HandleRecordRequest {
@JsonProperty(required = true)
private final String sourceDataStandard;

public MappingRequest(String fdoProfile, String issuedForAgent, String digitalObjectType,
public MappingRequest(String issuedForAgent,
String pidIssuer, String[] locations, String sourceDataStandard) {
super(fdoProfile, issuedForAgent, digitalObjectType, pidIssuer, StructuralType.DIGITAL,
super(issuedForAgent, pidIssuer, StructuralType.DIGITAL,
locations);
this.sourceDataStandard = sourceDataStandard;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package eu.dissco.core.handlemanager.domain.fdo;

import com.fasterxml.jackson.annotation.JsonProperty;
import eu.dissco.core.handlemanager.domain.fdo.vocabulary.specimen.StructuralType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
@EqualsAndHashCode(callSuper = true)
public class MasRequest extends HandleRecordRequest {

@JsonProperty(required = true)
private final String machineAnnotationServiceName;

public MasRequest(String issuedForAgent,
String pidIssuer, String[] locations, String masName) {
super(issuedForAgent, pidIssuer, StructuralType.DIGITAL,
locations);
this.machineAnnotationServiceName = masName;
}
}
Loading

0 comments on commit 65ede79

Please sign in to comment.