diff --git a/src/main/java/nl/knaw/dans/dvingest/DdDataverseIngestApplication.java b/src/main/java/nl/knaw/dans/dvingest/DdDataverseIngestApplication.java index f8534a2..f2716d6 100644 --- a/src/main/java/nl/knaw/dans/dvingest/DdDataverseIngestApplication.java +++ b/src/main/java/nl/knaw/dans/dvingest/DdDataverseIngestApplication.java @@ -28,6 +28,7 @@ import nl.knaw.dans.dvingest.core.dansbag.DansBagMappingService; import nl.knaw.dans.dvingest.core.dansbag.DansBagMappingServiceImpl; import nl.knaw.dans.dvingest.core.dansbag.SupportedLicenses; +import nl.knaw.dans.dvingest.core.dansbag.mapper.DepositToDvDatasetMetadataMapper; import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.dvingest.core.service.DataverseServiceImpl; import nl.knaw.dans.dvingest.core.service.UtilityServicesImpl; @@ -35,7 +36,6 @@ import nl.knaw.dans.dvingest.resources.DefaultApiResource; import nl.knaw.dans.dvingest.resources.IllegalArgumentExceptionMapper; import nl.knaw.dans.dvingest.resources.IngestApiResource; -import nl.knaw.dans.dvingest.core.dansbag.mapper.DepositToDvDatasetMetadataMapper; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.util.MappingLoader; import org.apache.commons.io.FileUtils; diff --git a/src/main/java/nl/knaw/dans/dvingest/client/ValidateDansBagService.java b/src/main/java/nl/knaw/dans/dvingest/client/ValidateDansBagService.java index 02c0cb4..39d5a46 100644 --- a/src/main/java/nl/knaw/dans/dvingest/client/ValidateDansBagService.java +++ b/src/main/java/nl/knaw/dans/dvingest/client/ValidateDansBagService.java @@ -15,9 +15,7 @@ */ package nl.knaw.dans.dvingest.client; -import nl.knaw.dans.ingest.core.exception.RejectedDepositException; import nl.knaw.dans.validatedansbag.client.api.ValidateOkDto; -import nl.knaw.dans.validatedansbag.client.api.ValidateOkDto.InformationPackageTypeEnum; import java.nio.file.Path; diff --git a/src/main/java/nl/knaw/dans/dvingest/config/DansDepositConversionConfig.java b/src/main/java/nl/knaw/dans/dvingest/config/DansDepositConversionConfig.java index 343529c..52a0f37 100644 --- a/src/main/java/nl/knaw/dans/dvingest/config/DansDepositConversionConfig.java +++ b/src/main/java/nl/knaw/dans/dvingest/config/DansDepositConversionConfig.java @@ -16,7 +16,6 @@ package nl.knaw.dans.dvingest.config; import lombok.Data; -import lombok.NonNull; import javax.validation.Valid; import javax.validation.constraints.NotNull; diff --git a/src/main/java/nl/knaw/dans/dvingest/config/IngestConfig.java b/src/main/java/nl/knaw/dans/dvingest/config/IngestConfig.java index aa5d5e5..bffce7b 100644 --- a/src/main/java/nl/knaw/dans/dvingest/config/IngestConfig.java +++ b/src/main/java/nl/knaw/dans/dvingest/config/IngestConfig.java @@ -16,8 +16,8 @@ package nl.knaw.dans.dvingest.config; import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; import io.dropwizard.util.DataSize; +import lombok.Data; import javax.validation.Valid; import javax.validation.constraints.NotNull; diff --git a/src/main/java/nl/knaw/dans/dvingest/config/ValidateDansBagConfig.java b/src/main/java/nl/knaw/dans/dvingest/config/ValidateDansBagConfig.java index 226d55e..f45f16c 100644 --- a/src/main/java/nl/knaw/dans/dvingest/config/ValidateDansBagConfig.java +++ b/src/main/java/nl/knaw/dans/dvingest/config/ValidateDansBagConfig.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvingest.config; -import io.dropwizard.client.HttpClientConfiguration; import io.dropwizard.client.JerseyClientConfiguration; import lombok.Data; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/DepositTask.java b/src/main/java/nl/knaw/dans/dvingest/core/DepositTask.java index e0db73c..d27b432 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/DepositTask.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/DepositTask.java @@ -21,10 +21,10 @@ import nl.knaw.dans.dvingest.core.bagprocessor.BagProcessor; import nl.knaw.dans.dvingest.core.dansbag.DansBagMappingService; import nl.knaw.dans.dvingest.core.dansbag.DansDepositSupport; +import nl.knaw.dans.dvingest.core.dansbag.exception.RejectedDepositException; import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.dvingest.core.service.UtilityServices; import nl.knaw.dans.dvingest.core.service.YamlService; -import nl.knaw.dans.ingest.core.exception.RejectedDepositException; import java.io.IOException; import java.nio.file.Path; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/IngestArea.java b/src/main/java/nl/knaw/dans/dvingest/core/IngestArea.java index a1f9e54..b10a4cf 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/IngestArea.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/IngestArea.java @@ -15,7 +15,6 @@ */ package nl.knaw.dans.dvingest.core; -import io.dropwizard.lifecycle.Managed; import lombok.Builder; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @@ -27,8 +26,6 @@ import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.dvingest.core.service.UtilityServices; import nl.knaw.dans.dvingest.core.service.YamlService; -import nl.knaw.dans.dvingest.core.service.YamlServiceImpl; -import nl.knaw.dans.lib.util.inbox.Inbox; import java.nio.file.Path; import java.util.List; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingService.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingService.java index 29939cb..22348b7 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingService.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingService.java @@ -15,10 +15,10 @@ */ package nl.knaw.dans.dvingest.core.dansbag; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; import nl.knaw.dans.dvingest.core.yaml.EditFiles; import nl.knaw.dans.dvingest.core.yaml.EditPermissions; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.exception.InvalidDepositException; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.dataset.Dataset; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingServiceImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingServiceImpl.java index b6c5b99..ab45b3b 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingServiceImpl.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansBagMappingServiceImpl.java @@ -17,32 +17,29 @@ import gov.loc.repository.bagit.reader.BagReader; import lombok.extern.slf4j.Slf4j; +import nl.knaw.dans.dvingest.core.dansbag.deposit.BagDirResolver; +import nl.knaw.dans.dvingest.core.dansbag.deposit.BagDirResolverImpl; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositFileLister; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositFileListerImpl; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositReader; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositReaderImpl; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManager; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManagerImpl; +import nl.knaw.dans.dvingest.core.dansbag.io.FileService; +import nl.knaw.dans.dvingest.core.dansbag.io.FileServiceImpl; +import nl.knaw.dans.dvingest.core.dansbag.mapper.DepositToDvDatasetMetadataMapper; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelper; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelperImpl; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReader; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReaderImpl; import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.dvingest.core.yaml.EditFiles; import nl.knaw.dans.dvingest.core.yaml.EditPermissions; -import nl.knaw.dans.ingest.core.deposit.BagDirResolver; -import nl.knaw.dans.ingest.core.deposit.BagDirResolverImpl; -import nl.knaw.dans.ingest.core.deposit.DepositFileLister; -import nl.knaw.dans.ingest.core.deposit.DepositFileListerImpl; -import nl.knaw.dans.ingest.core.deposit.DepositReader; -import nl.knaw.dans.ingest.core.deposit.DepositReaderImpl; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.domain.FileInfo; -import nl.knaw.dans.ingest.core.exception.InvalidDepositException; -import nl.knaw.dans.ingest.core.io.BagDataManager; -import nl.knaw.dans.ingest.core.io.BagDataManagerImpl; -import nl.knaw.dans.ingest.core.io.FileService; -import nl.knaw.dans.ingest.core.io.FileServiceImpl; -import nl.knaw.dans.ingest.core.service.ManifestHelper; -import nl.knaw.dans.ingest.core.service.ManifestHelperImpl; -import nl.knaw.dans.ingest.core.service.XmlReader; -import nl.knaw.dans.ingest.core.service.XmlReaderImpl; -import nl.knaw.dans.dvingest.core.dansbag.mapper.DepositToDvDatasetMetadataMapper; -import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.FileElement; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.RoleAssignment; import nl.knaw.dans.lib.dataverse.model.dataset.Dataset; -import nl.knaw.dans.lib.dataverse.model.file.FileMeta; import nl.knaw.dans.lib.dataverse.model.user.AuthenticatedUser; import nl.knaw.dans.lib.util.ZipUtil; import org.apache.commons.lang3.StringUtils; @@ -55,10 +52,8 @@ import java.nio.file.Path; import java.text.SimpleDateFormat; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.regex.Pattern; -import java.util.stream.Collectors; @Slf4j public class DansBagMappingServiceImpl implements DansBagMappingService { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositConverter.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositConverter.java index d6d5859..0001431 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositConverter.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositConverter.java @@ -16,11 +16,11 @@ package nl.knaw.dans.dvingest.core.dansbag; import lombok.AllArgsConstructor; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; import nl.knaw.dans.dvingest.core.service.YamlService; import nl.knaw.dans.dvingest.core.yaml.EditFilesRoot; import nl.knaw.dans.dvingest.core.yaml.EditPermissionsRoot; import nl.knaw.dans.dvingest.core.yaml.UpdateState; -import nl.knaw.dans.ingest.core.domain.Deposit; import java.io.IOException; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositSupport.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositSupport.java index 3184280..edc3a08 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositSupport.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/DansDepositSupport.java @@ -23,9 +23,9 @@ import nl.knaw.dans.dvingest.core.DataverseIngestBag; import nl.knaw.dans.dvingest.core.DataverseIngestDeposit; import nl.knaw.dans.dvingest.core.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.exception.RejectedDepositException; import nl.knaw.dans.dvingest.core.service.YamlService; -import nl.knaw.dans.ingest.core.exception.InvalidDepositException; -import nl.knaw.dans.ingest.core.exception.RejectedDepositException; import nl.knaw.dans.lib.dataverse.DataverseException; import java.io.IOException; @@ -44,7 +44,7 @@ public class DansDepositSupport implements Deposit { private final DataverseIngestDeposit ingestDataverseIngestDeposit; private final boolean isDansDeposit; - private nl.knaw.dans.ingest.core.domain.Deposit dansDeposit; + private nl.knaw.dans.dvingest.core.dansbag.domain.Deposit dansDeposit; public DansDepositSupport(DataverseIngestDeposit dataverseIngestDeposit, ValidateDansBagService validateDansBagService, DansBagMappingService dansBagMappingService, YamlService yamlService) { this.validateDansBagService = validateDansBagService; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposer.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposer.java index f4c3c82..8963672 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposer.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposer.java @@ -18,17 +18,15 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.dvingest.core.bagprocessor.DataversePath; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.FileInfo; import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.FileElement; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import nl.knaw.dans.dvingest.core.yaml.AddEmbargo; import nl.knaw.dans.dvingest.core.yaml.EditFiles; import nl.knaw.dans.dvingest.core.yaml.FromTo; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.domain.FileInfo; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; -import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; -import java.io.IOException; import java.nio.file.Path; import java.text.SimpleDateFormat; import java.time.Instant; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposerForUpdate.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposerForUpdate.java index ddbfbff..857ce79 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposerForUpdate.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/EditFilesComposerForUpdate.java @@ -17,10 +17,10 @@ import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.dvingest.core.bagprocessor.FilesInDatasetCache; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.FileInfo; import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.dvingest.core.yaml.FromTo; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.domain.FileInfo; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/SupportedLicenses.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/SupportedLicenses.java index 9c65b10..6e85c2c 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/SupportedLicenses.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/SupportedLicenses.java @@ -15,11 +15,11 @@ */ package nl.knaw.dans.dvingest.core.dansbag; -import nl.knaw.dans.dvingest.core.service.DataverseService; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.exception.RejectedDepositException; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.RejectedDepositException; import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.LicenseElem; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.service.DataverseService; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.model.dataset.License; @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; -import static nl.knaw.dans.ingest.core.service.XPathConstants.DDM_DCMI_METADATA; +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.DDM_DCMI_METADATA; public class SupportedLicenses { private final Map supportedLicenses; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolver.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolver.java new file mode 100644 index 0000000..30a5a81 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolver.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.io.IOException; +import java.nio.file.Path; + +public interface BagDirResolver { + + /** + * Returns the first subdirectory of the provided path if it looks like a bag. It will not check if the bag is valid and only do a very superficial check. It will throw an exception if + * + * + * @param depositDir The deposit directory + * @return The path to the first subdirectory + * @throws InvalidDepositException If any of the checks above fail + * @throws IOException Propagated from underlying systems to indicate an IO error + */ + Path getBagDir(Path depositDir) throws InvalidDepositException, IOException; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolverImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolverImpl.java new file mode 100644 index 0000000..11975bd --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolverImpl.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.io.FileService; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.stream.Collectors; + +public class BagDirResolverImpl implements BagDirResolver { + private final FileService fileService; + + public BagDirResolverImpl(FileService fileService) { + this.fileService = fileService; + } + + @Override + public Path getBagDir(Path depositDir) throws InvalidDepositException, IOException { + if (!fileService.isDirectory(depositDir)) { + throw new InvalidDepositException(String.format("%s is not a directory", depositDir)); + } + + try (var substream = fileService.listDirectories(depositDir)) { + var directories = substream.collect(Collectors.toList()); + + // only 1 directory allowed, not 0 or more than 1 + if (directories.size() != 1) { + throw new InvalidDepositException(String.format( + "%s has more or fewer than one subdirectory", depositDir + )); + } + + // check for the presence of deposit.properties and bagit.txt + if (!fileService.fileExists(depositDir.resolve("deposit.properties"))) { + throw new InvalidDepositException(String.format( + "%s does not contain a deposit.properties file", depositDir + )); + } + + var bagDir = directories.get(0); + + if (!fileService.fileExists(bagDir.resolve("bagit.txt"))) { + throw new InvalidDepositException(String.format( + "%s does not contain a bag", depositDir + )); + } + + return bagDir; + } + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileLister.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileLister.java new file mode 100644 index 0000000..6984578 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileLister.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositFile; + +import java.io.IOException; +import java.util.List; + +public interface DepositFileLister { + List getDepositFiles(Deposit deposit) throws IOException; + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileListerImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileListerImpl.java new file mode 100644 index 0000000..82fd811 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileListerImpl.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositFile; +import nl.knaw.dans.dvingest.core.dansbag.domain.OriginalFilePathMapping; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelperImpl; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; +import org.w3c.dom.Node; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.FILES_FILE; + +public class DepositFileListerImpl implements DepositFileLister { + @Override + public List getDepositFiles(Deposit deposit) throws IOException { + var bag = deposit.getBag(); + var bagDir = bag.getRootDir(); + var filePathToSha1 = ManifestHelperImpl.getFilePathToSha1(bag); + var originalFilePathMappings = getOriginalFilePathMapping(bagDir); + + return XPathEvaluator.nodes(deposit.getFilesXml(), FILES_FILE) + .map(node -> { + var filePath = Optional.ofNullable(node.getAttributes().getNamedItem("filepath")) + .map(Node::getTextContent) + .map(Path::of) + .orElseThrow(() -> new IllegalArgumentException("File element without filepath attribute")); + + var physicalFile = originalFilePathMappings.getPhysicalPath(filePath); + var sha1 = filePathToSha1.get(physicalFile); + + return new DepositFile(filePath, physicalFile, sha1, node); + }) + .collect(Collectors.toList()); + } + + private OriginalFilePathMapping getOriginalFilePathMapping(Path bagDir) throws IOException { + var originalFilepathsFile = bagDir.resolve("original-filepaths.txt"); + + if (Files.exists(originalFilepathsFile)) { + var lines = Files.readAllLines(originalFilepathsFile); + var mappings = lines.stream().map(line -> { + var parts = line.split("\\s+", 2); + + if (parts.length == 2) { + return new OriginalFilePathMapping.Mapping( + Path.of(parts[0].trim()), + Path.of(parts[1].trim()) + ); + } + + return null; + }) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + return new OriginalFilePathMapping(mappings); + } + else { + return new OriginalFilePathMapping(Set.of()); + } + } +} \ No newline at end of file diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReader.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReader.java new file mode 100644 index 0000000..09603b0 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReader.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.io.IOException; +import java.nio.file.Path; + +public interface DepositLocationReader { + + DepositLocation readDepositLocation(Path depositDir) throws InvalidDepositException, IOException; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReaderImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReaderImpl.java new file mode 100644 index 0000000..cc90faa --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositLocationReaderImpl.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import lombok.AllArgsConstructor; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.exception.MissingTargetException; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManager; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.nio.file.Path; +import java.time.OffsetDateTime; +import java.time.format.DateTimeParseException; +import java.util.UUID; + +@AllArgsConstructor +public class DepositLocationReaderImpl implements DepositLocationReader { + private final BagDataManager bagDataManager; + + @Override + public DepositLocation readDepositLocation(Path depositDir) throws InvalidDepositException, IOException { + try { + var properties = bagDataManager.readDepositProperties(depositDir); + var depositId = getDepositId(depositDir); + var target = getTarget(properties); + var created = getCreated(properties); + + return new DepositLocation(depositDir, target, depositId.toString(), created); + } + catch (ConfigurationException e) { + throw new InvalidDepositException("Deposit.properties file could not be read", e); + } + catch (MissingTargetException e) { + throw new InvalidDepositException(e.getMessage(), e); + } + } + + String getTarget(Configuration properties) throws MissingTargetException { + // the logic for the target should be + // 1. if there is a dataverse.sword-token, use that + // 2. otherwise, use identifier.doi + var target = properties.getString("dataverse.sword-token"); + + if (StringUtils.isBlank(target)) { + target = properties.getString("identifier.doi"); + } + + if (StringUtils.isBlank(target)) { + throw new MissingTargetException("No viable target found in deposit"); + } + + return target; + } + + UUID getDepositId(Path path) throws InvalidDepositException { + try { + return UUID.fromString(path.getFileName().toString()); + } + catch (IllegalArgumentException e) { + throw new InvalidDepositException(String.format( + "Deposit dir must be an UUID; found '%s'", + path.getFileName() + ), e); + } + } + + OffsetDateTime getCreated(Configuration properties) throws InvalidDepositException { + try { + var created = properties.getString("creation.timestamp"); + if (StringUtils.isBlank(created)) { + throw new InvalidDepositException("No creation timestamp found in deposit"); + } + + return OffsetDateTime.parse(created); + } + catch (DateTimeParseException e) { + throw new InvalidDepositException("Error while parsing date", e); + } + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManager.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManager.java new file mode 100644 index 0000000..d8ef303 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManager.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.io.IOException; +import java.nio.file.Path; + +// an adapter around DepositReader and DepositWriter + +/** + * An adapter class around several functionalities regarding deposit reading, writing and moving. + */ +public interface DepositManager { + void saveBagInfo(Deposit deposit) throws IOException; + + /** + * Reads a Deposit object given the data found in a DepositLocation's dir property. + * + * @param location The DepositLocation that refers to a deposit directory + * @return A fully read Deposit + * @throws InvalidDepositException + */ + Deposit readDeposit(DepositLocation location) throws InvalidDepositException; + + /** + * Reads a DepositLocation from the provided path. This is different from a regular Deposit in that it only contains the minimal amount of data required to sort and group tasks. This data is: + *
+     *     - A path
+     *     - The created date
+     *     - The target, either a sword token or a DOI
+     *     - The ID of the deposit
+     * 
+ * + * @param path + * @return A DepositLocation object + * @throws InvalidDepositException + * @throws IOException + */ + DepositLocation readDepositLocation(Path path) throws InvalidDepositException, IOException; + + /** + * Update the deposit.properties file with the data found in this Deposit, and move it to the target path. The path should NOT include the deposit ID. + * + * @param deposit The Deposit that should be written. + * @param outbox The path that this deposit should move to after saving the properties. This path should NOT include the deposit ID. + * @throws IOException + * @throws InvalidDepositException + */ + void updateAndMoveDeposit(Deposit deposit, Path outbox) throws IOException, InvalidDepositException; + + /** + * Move the first path to the target path. The target path should NOT include the deposit ID. This method should only be used if an exception occurred while reading the deposit, making it + * impossible to read/write to the deposit.properties file. + * + * @param depositDir The deposit dir that was attempted to be read + * @param outbox The path to which the deposit dir should be moved + * @throws IOException + */ + void moveDeposit(Path depositDir, Path outbox) throws IOException; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManagerImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManagerImpl.java new file mode 100644 index 0000000..ecbfecd --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositManagerImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.io.IOException; +import java.nio.file.Path; + +public class DepositManagerImpl implements DepositManager { + private final DepositReader depositReader; + private final DepositLocationReader depositLocationReader; + private final DepositWriter depositWriter; + + public DepositManagerImpl(DepositReader depositReader, DepositLocationReader depositLocationReader, DepositWriter depositWriter) { + this.depositReader = depositReader; + this.depositLocationReader = depositLocationReader; + this.depositWriter = depositWriter; + } + + @Override + public void saveBagInfo(Deposit deposit) throws IOException { + depositWriter.saveBagInfo(deposit); + } + + @Override + public Deposit readDeposit(DepositLocation location) throws InvalidDepositException { + return depositReader.readDeposit(location); + } + + @Override + public DepositLocation readDepositLocation(Path path) throws InvalidDepositException, IOException { + return depositLocationReader.readDepositLocation(path); + } + + @Override + public void updateAndMoveDeposit(Deposit deposit, Path outbox) throws IOException, InvalidDepositException { + depositWriter.saveDeposit(deposit); + depositWriter.moveDeposit(deposit, outbox); + } + + @Override + public void moveDeposit(Path depositDir, Path outbox) throws IOException { + depositWriter.moveDeposit(depositDir, outbox); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReader.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReader.java new file mode 100644 index 0000000..63076c7 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReader.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.nio.file.Path; + +public interface DepositReader { + + Deposit readDeposit(DepositLocation location) throws InvalidDepositException; + + Deposit readDeposit(Path depositDir) throws InvalidDepositException; + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReaderImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReaderImpl.java new file mode 100644 index 0000000..5a38d02 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositReaderImpl.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import gov.loc.repository.bagit.domain.Bag; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.DepositLocation; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManager; +import nl.knaw.dans.dvingest.core.dansbag.io.FileService; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelper; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReader; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.lang3.StringUtils; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.nio.file.Path; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Optional; + +public class DepositReaderImpl implements DepositReader { + private final XmlReader xmlReader; + private final BagDirResolver bagDirResolver; + private final FileService fileService; + private final BagDataManager bagDataManager; + private final DepositFileLister depositFileLister; + + private final ManifestHelper manifestHelper; + + public DepositReaderImpl(XmlReader xmlReader, BagDirResolver bagDirResolver, FileService fileService, BagDataManager bagDataManager, DepositFileLister depositFileLister, ManifestHelper manifestHelper) { + this.xmlReader = xmlReader; + this.bagDirResolver = bagDirResolver; + this.fileService = fileService; + this.bagDataManager = bagDataManager; + this.depositFileLister = depositFileLister; + this.manifestHelper = manifestHelper; + } + + @Override + public synchronized Deposit readDeposit(DepositLocation location) throws InvalidDepositException { + return readDeposit(location.getDir()); + } + + @Override + public Deposit readDeposit(Path depositDir) throws InvalidDepositException { + try { + var bagDir = bagDirResolver.getBagDir(depositDir); + + var config = bagDataManager.readDepositProperties(depositDir); + var bag = bagDataManager.readBag(bagDir); + manifestHelper.ensureSha1ManifestPresent(bag); + + var deposit = mapToDeposit(depositDir, bagDir, config, bag); + + deposit.setBag(bag); + deposit.setDdm(readOptionalXmlFile(deposit.getDdmPath())); + deposit.setFilesXml(readOptionalXmlFile(deposit.getFilesXmlPath())); + deposit.setAmd(readOptionalXmlFile(deposit.getAmdPath())); + + deposit.setFiles(depositFileLister.getDepositFiles(deposit)); + + return deposit; + } + catch (Throwable cex) { + throw new InvalidDepositException(cex.getMessage(), cex); + } + } + + Document readOptionalXmlFile(Path path) throws ParserConfigurationException, IOException, SAXException { + if (fileService.fileExists(path)) { + return xmlReader.readXmlFile(path); + } + + return null; + } + + Deposit mapToDeposit(Path path, Path bagDir, Configuration config, Bag bag) { + var deposit = new Deposit(); + deposit.setBagDir(bagDir); + deposit.setDir(path); + deposit.setDoi(config.getString("identifier.doi", "")); + deposit.setUrn(config.getString("identifier.urn")); + deposit.setCreated(Optional.ofNullable(config.getString("creation.timestamp")).map(OffsetDateTime::parse).orElse(null)); + deposit.setDepositorUserId(config.getString("depositor.userId")); + + deposit.setDataverseIdProtocol(config.getString("dataverse.id-protocol", "")); + deposit.setDataverseIdAuthority(config.getString("dataverse.id-authority", "")); + deposit.setDataverseId(config.getString("dataverse.id-identifier", "")); + deposit.setDataverseBagId(config.getString("dataverse.bag-id", "")); + deposit.setDataverseNbn(config.getString("dataverse.nbn", "")); + deposit.setDataverseOtherId(config.getString("dataverse.other-id", "")); + deposit.setDataverseOtherIdVersion(config.getString("dataverse.other-id-version", "")); + deposit.setDataverseSwordToken(config.getString("dataverse.sword-token", "")); + deposit.setHasOrganizationalIdentifier(getFirstValue(bag.getMetadata().get("Has-Organizational-Identifier"))); + + var isVersionOf = bag.getMetadata().get("Is-Version-Of"); + + if (isVersionOf != null) { + isVersionOf.stream() + .filter(StringUtils::isNotBlank) + .findFirst() + .ifPresent(item -> { + deposit.setUpdate(true); + deposit.setIsVersionOf(item); + }); + } + + return deposit; + } + + private String getFirstValue(List value) { + if (value == null) { + return null; + } + + return value.stream() + .filter(StringUtils::isNotBlank) + .findFirst() + .orElse(null); + } + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriter.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriter.java new file mode 100644 index 0000000..19d6ae6 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriter.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; + +import java.io.IOException; +import java.nio.file.Path; + +public interface DepositWriter { + + void saveDeposit(Deposit deposit) throws InvalidDepositException; + + void moveDeposit(Deposit deposit, Path outbox) throws IOException; + + void moveDeposit(Path source, Path outbox) throws IOException; + + void saveBagInfo(Deposit deposit) throws IOException; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriterImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriterImpl.java new file mode 100644 index 0000000..aee59aa --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositWriterImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.deposit; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.exception.InvalidDepositException; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManager; +import org.apache.commons.configuration2.ex.ConfigurationException; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; + +public class DepositWriterImpl implements DepositWriter { + private final BagDataManager bagDataManager; + + public DepositWriterImpl(BagDataManager bagDataManager) { + this.bagDataManager = bagDataManager; + } + + @Override + public void saveDeposit(Deposit deposit) throws InvalidDepositException { + var config = new HashMap(); + config.put("state.label", deposit.getState().toString()); + config.put("state.description", deposit.getStateDescription()); + config.put("identifier.doi", deposit.getDoi()); + config.put("identifier.urn", deposit.getUrn()); + + try { + bagDataManager.saveDepositProperties(deposit.getDir(), config); + } + catch (ConfigurationException cex) { + throw new InvalidDepositException("Unable to save deposit properties", cex); + } + } + + @Override + public void moveDeposit(Deposit deposit, Path outbox) throws IOException { + moveDeposit(deposit.getDir(), outbox); + } + + @Override + public void moveDeposit(Path source, Path outbox) throws IOException { + Files.move(source, outbox.resolve(source.getFileName())); + } + + @Override + public void saveBagInfo(Deposit deposit) throws IOException { + bagDataManager.writeBagMetadata(deposit.getBag()); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetAuthor.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetAuthor.java new file mode 100644 index 0000000..f39c6f7 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetAuthor.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class DatasetAuthor { + private String titles; + private String initials; + private String insertions; + private String surname; + private String dai; + private String isni; + private String orcid; + private String role; + private String organization; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetOrganization.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetOrganization.java new file mode 100644 index 0000000..1581420 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DatasetOrganization.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.Builder; +import lombok.Data; +import lombok.ToString; + +@Data +@Builder +@ToString +public class DatasetOrganization { + private String name; + private String role; + private String isni; + private String viaf; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/Deposit.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/Deposit.java new file mode 100644 index 0000000..7e86951 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/Deposit.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import gov.loc.repository.bagit.domain.Bag; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; +import org.apache.commons.lang3.StringUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import java.nio.file.Path; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.util.List; + +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.DDM_PROFILE; +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.FILES_FILE; +import static nl.knaw.dans.dvingest.core.dansbag.service.XmlNamespaces.NAMESPACE_XSI; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Deposit { + + private Path dir; + private Path bagDir; + + private String doi; + private String urn; + private String dataverseDoi; + private String depositorUserId; + private OffsetDateTime created; + private DepositState state; + private String stateDescription; + private boolean update; + + private String dataverseIdProtocol; + private String dataverseIdAuthority; + private String dataverseId; + private String dataverseBagId; + private String dataverseNbn; + private String dataverseOtherId; + private String dataverseOtherIdVersion; + private String dataverseSwordToken; + private String hasOrganizationalIdentifier; + private String hasOrganizationalIdentifierVersion; + + private String isVersionOf; + + private Instant bagCreated; + + private Document ddm; + private Document filesXml; + private Document amd; + private Bag bag; + + private List files; + + public VaultMetadata getVaultMetadata() { + return new VaultMetadata(getDataversePid(), getDataverseBagId(), getDataverseNbn(), getDataverseOtherId(), getDataverseSwordToken()); + } + + private static boolean hasTypeDoi(Node n) { + Node type = n.getAttributes().getNamedItemNS(NAMESPACE_XSI, "type"); + return type != null && type.getTextContent().contains("DOI"); + } + + public String getDataversePid() { + return String.format("%s:%s/%s", dataverseIdProtocol, dataverseIdAuthority, dataverseId); + } + + public String getOtherDoiId() { + // prevent "doi:null" values + if (StringUtils.isBlank(doi)) { + return null; + } + + var otherDoi = String.format("doi:%s", doi); + if (StringUtils.equals(otherDoi, getDataversePid())) { + // The same, so no "other DOI" + return null; + } + else { + return otherDoi; + } + } + + /** + * Are access requests allowed according to this deposit. Note that if this is an update-deposit, the result from this method should be combined with the current setting. If the dataset has access + * requests disabled this overrules a true value returned from this method. + * + * @return whether this deposit allows access requests + */ + public boolean allowAccessRequests() { + var accessRightsNode = XPathEvaluator.nodes(ddm, DDM_PROFILE + "/ddm:accessRights") + .findFirst() + .orElseThrow(); + + var isNoAccessDataset = "NO_ACCESS".equals(accessRightsNode.getTextContent().trim()); + var accessibleToNoneFilesPresent = XPathEvaluator + .strings(filesXml, FILES_FILE + "/files:accessibleToRights") + .map(String::trim) + .anyMatch("NONE"::equals); + + return !(isNoAccessDataset || accessibleToNoneFilesPresent); + } + + public boolean restrictedFilesPresent() { + var numberOfFiles = files.size(); + var explicitAccessibleToValues = XPathEvaluator + .strings(filesXml, FILES_FILE + "/files:accessibleToRights") + .map(String::trim).toList(); + var explicitlyRestrictedFilesPresent = explicitAccessibleToValues.stream() + .anyMatch(a -> !"ANONYMOUS".equals(a)); + var accessRights = XPathEvaluator.nodes(ddm, "/ddm:DDM/ddm:profile/ddm:accessRights") + .findFirst() + .orElseThrow() + .getTextContent().trim(); + var implicitFilesAreRestricted = !"OPEN_ACCESS".equals(accessRights); + var implicitFilesPresent = numberOfFiles > explicitAccessibleToValues.size(); + return explicitlyRestrictedFilesPresent || (implicitFilesPresent && implicitFilesAreRestricted); + } + + public String getDepositId() { + return this.dir.getFileName().toString(); + } + + public Path getDdmPath() { + return bagDir.resolve("metadata/dataset.xml"); + } + + public Path getFilesXmlPath() { + return bagDir.resolve("metadata/files.xml"); + } + + public Path getAgreementsXmlPath() { + return bagDir.resolve("metadata/depositor-info/agreements.xml"); + } + + public Path getAmdPath() { + return bagDir.resolve("metadata/amd.xml"); + } + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositFile.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositFile.java new file mode 100644 index 0000000..0e13b38 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositFile.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import org.w3c.dom.Node; + +import java.nio.file.Path; + +@Data +@AllArgsConstructor +public class DepositFile { + private Path path; + private Path physicalPath; + private String checksum; + private Node xmlNode; + + public Path getPhysicalPath() { + if (this.physicalPath != null) { + return physicalPath; + } + + return path; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositLocation.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositLocation.java new file mode 100644 index 0000000..5d49e67 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositLocation.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.nio.file.Path; +import java.time.OffsetDateTime; + +/** + * This class represents the location of a deposit that was done in one of the inboxes. It is intended to be a lightweight pointer to the deposit to be used for enqueuing a large number of deposits + * without incurring the overhead of loading all the deposit metadata into memory. + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DepositLocation { + private Path dir; + private String target; + private String depositId; + private OffsetDateTime created; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositState.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositState.java new file mode 100644 index 0000000..46616f5 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositState.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +public enum DepositState { + ARCHIVED, DRAFT, FAILED, FINALIZING, INVALID, REJECTED, SUBMITTED, UPLOADED, PUBLISHED, ACCEPTED +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/FileInfo.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/FileInfo.java new file mode 100644 index 0000000..6f5c108 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/FileInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.ToString; +import nl.knaw.dans.lib.dataverse.model.file.FileMeta; + +import java.nio.file.Path; + +@Data +@ToString +@AllArgsConstructor +public class FileInfo { + private Path path; + private Path physicalPath; + private String checksum; + private boolean sanitized; + private FileMeta metadata; + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OriginalFilePathMapping.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OriginalFilePathMapping.java new file mode 100644 index 0000000..c7e69eb --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OriginalFilePathMapping.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.nio.file.Path; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class OriginalFilePathMapping { + // the first entry is the logical (original) name, as provided by the deposit + // the second entry is the physical path, renamed to solve filesystem limitations + private final Map mappings = new HashMap<>(); + + public OriginalFilePathMapping(Collection mappings) { + for (var mapping: mappings) { + this.mappings.put(mapping.getOriginalPath(), mapping.getPhysicalPath()); + } + } + + public boolean hasMapping(Path path) { + return this.mappings.containsKey(path); + } + + public Path getPhysicalPath(Path path) { + return this.mappings.getOrDefault(path, path); + } + + @Data + @AllArgsConstructor + public static class Mapping { + private Path physicalPath; + private Path originalPath; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OutboxSubDir.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OutboxSubDir.java new file mode 100644 index 0000000..2b42cb8 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OutboxSubDir.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +public enum OutboxSubDir { + PROCESSED("processed"), + REJECTED("rejected"), + FAILED("failed"); + + private final String value; + + OutboxSubDir(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/VaultMetadata.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/VaultMetadata.java new file mode 100644 index 0000000..a78d691 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/VaultMetadata.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class VaultMetadata { + private String pid; + private String bagId; + private String nbn; + private String otherId; + private String swordToken; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/CannotUpdateDraftDatasetException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/CannotUpdateDraftDatasetException.java new file mode 100644 index 0000000..6c30987 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/CannotUpdateDraftDatasetException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; + +public class CannotUpdateDraftDatasetException extends RuntimeException { + + public CannotUpdateDraftDatasetException(Deposit deposit) { + super("Latest version must be published before update-deposit can be processed"); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/DepositorValidatorException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/DepositorValidatorException.java new file mode 100644 index 0000000..e64185a --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/DepositorValidatorException.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class DepositorValidatorException extends Exception { + public DepositorValidatorException(Throwable e) { + super(e); + } + + public DepositorValidatorException(String message) { + super(message); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/FailedDepositException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/FailedDepositException.java new file mode 100644 index 0000000..ffbe05f --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/FailedDepositException.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; + +public class FailedDepositException extends RuntimeException { + public FailedDepositException(Deposit deposit, String message) { + super(String.format("Failed %s: %s", deposit.getDir(), message)); + } + + public FailedDepositException(Deposit deposit, String message, Throwable e) { + super(String.format("Failed %s: %s", deposit.getDir(), message), e); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDatasetStateException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDatasetStateException.java new file mode 100644 index 0000000..5035b57 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDatasetStateException.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class InvalidDatasetStateException extends Throwable { + public InvalidDatasetStateException(String msg) { + super(msg); + } + + public InvalidDatasetStateException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositException.java new file mode 100644 index 0000000..6a68511 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositException.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class InvalidDepositException extends Exception { + public InvalidDepositException(String msg) { + super(msg); + } + + public InvalidDepositException(String msg, Throwable cause) { + super(msg, cause); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositorRoleException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositorRoleException.java new file mode 100644 index 0000000..3e18ca2 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/InvalidDepositorRoleException.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class InvalidDepositorRoleException extends Exception { + public InvalidDepositorRoleException(String msg) { + super(msg); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingRequiredFieldException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingRequiredFieldException.java new file mode 100644 index 0000000..e612e66 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingRequiredFieldException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class MissingRequiredFieldException extends RuntimeException { + private final String title; + + public MissingRequiredFieldException(String title) { + super(String.format("Required metadata field '%s' is missing", title)); + this.title = title; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingTargetException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingTargetException.java new file mode 100644 index 0000000..f1f67d0 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/MissingTargetException.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class MissingTargetException extends Exception { + public MissingTargetException(String message) { + super(message); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/RejectedDepositException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/RejectedDepositException.java new file mode 100644 index 0000000..48e1873 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/RejectedDepositException.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; + +public class RejectedDepositException extends RuntimeException { + public RejectedDepositException(Deposit deposit, String message) { + super(String.format("Rejected %s: %s", deposit.getDir(), message)); + } + + public RejectedDepositException(nl.knaw.dans.dvingest.core.Deposit deposit, String message) { + super(String.format("Rejected %s: %s", deposit.getLocation(), message)); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetBlockedException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetBlockedException.java new file mode 100644 index 0000000..5b80c83 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetBlockedException.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class TargetBlockedException extends Exception { + public TargetBlockedException(String msg) { + super(msg); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetNotFoundException.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetNotFoundException.java new file mode 100644 index 0000000..af76a4a --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/exception/TargetNotFoundException.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.exception; + +public class TargetNotFoundException extends Exception { + public TargetNotFoundException(String msg) { + super(msg); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManager.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManager.java new file mode 100644 index 0000000..fcbbd3c --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManager.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.io; + +import gov.loc.repository.bagit.domain.Bag; +import gov.loc.repository.bagit.domain.Metadata; +import gov.loc.repository.bagit.exceptions.InvalidBagitFileFormatException; +import gov.loc.repository.bagit.exceptions.MaliciousPathException; +import gov.loc.repository.bagit.exceptions.UnparsableVersionException; +import gov.loc.repository.bagit.exceptions.UnsupportedAlgorithmException; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.ex.ConfigurationException; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Map; + +public interface BagDataManager { + + /** + * Reads the bag metadata on the path that contains bag-info.txt and bagit.txt, among other files + * + * @param bagDir the path that contains bag-info.txt and bagit.txt + * @return The Metadata object + * @throws UnparsableVersionException + * @throws InvalidBagitFileFormatException + * @throws IOException + */ + Metadata readBagMetadata(Path bagDir) throws UnparsableVersionException, InvalidBagitFileFormatException, IOException; + + /** + * Writes the current bag metadata to disk and updates the entry for bag-info.txt in all existing tag manifests, so that the bag stays valid. + * + * @param bag the bag object + * @throws IOException + */ + void writeBagMetadata(Bag bag) throws IOException; + + /** + * Reads the bag on the path that contains bag-info.txt and bagit.txt, among other files + * + * @param bagDir the path that contains bag-info.txt and bagit.txt + * @return The bag object + * @throws UnparsableVersionException + * @throws InvalidBagitFileFormatException + * @throws IOException + * @throws MaliciousPathException + * @throws UnsupportedAlgorithmException + */ + Bag readBag(Path bagDir) throws UnparsableVersionException, InvalidBagitFileFormatException, IOException, MaliciousPathException, UnsupportedAlgorithmException; + + /** + * Reads the deposit.properties file found inside the folder provided. The path should NOT reference deposit.properties directly + * + * @param depositDir The directory that contains a deposit.properties file + * @return + * @throws ConfigurationException + */ + Configuration readDepositProperties(Path depositDir) throws ConfigurationException; + + /** + * Saves the provided configuration to the deposit.properties file in the provided path. The path should NOT reference deposit.properties directly + * + * @param depositDir The directory that should contain the deposit.properties file + * @param configuration + * @throws ConfigurationException + */ + void saveDepositProperties(Path depositDir, Map configuration) throws ConfigurationException; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManagerImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManagerImpl.java new file mode 100644 index 0000000..46ab119 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/BagDataManagerImpl.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.io; + +import gov.loc.repository.bagit.domain.Bag; +import gov.loc.repository.bagit.domain.Metadata; +import gov.loc.repository.bagit.domain.Version; +import gov.loc.repository.bagit.exceptions.InvalidBagitFileFormatException; +import gov.loc.repository.bagit.exceptions.MaliciousPathException; +import gov.loc.repository.bagit.exceptions.UnparsableVersionException; +import gov.loc.repository.bagit.exceptions.UnsupportedAlgorithmException; +import gov.loc.repository.bagit.reader.BagReader; +import gov.loc.repository.bagit.reader.BagitTextFileReader; +import gov.loc.repository.bagit.reader.KeyValueReader; +import gov.loc.repository.bagit.writer.ManifestWriter; +import gov.loc.repository.bagit.writer.MetadataWriter; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.FileBasedConfiguration; +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; +import org.apache.commons.configuration2.builder.fluent.Parameters; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.io.FileUtils; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Map; + +public class BagDataManagerImpl implements BagDataManager { + private final String DEPOSIT_PROPERTIES_FILENAME = "deposit.properties"; + private final BagReader bagReader; + + public BagDataManagerImpl(BagReader bagReader) { + this.bagReader = bagReader; + } + + @Override + public Metadata readBagMetadata(Path bagDir) throws UnparsableVersionException, InvalidBagitFileFormatException, IOException { + var bagitInfo = BagitTextFileReader.readBagitTextFile(bagDir.resolve("bagit.txt")); + var encoding = bagitInfo.getValue(); + + var values = KeyValueReader.readKeyValuesFromFile(bagDir.resolve("bag-info.txt"), ":", encoding); + var metadata = new Metadata(); + metadata.addAll(values); + + return metadata; + } + + public void writeBagMetadata(Bag bag) throws IOException { + MetadataWriter.writeBagMetadata(bag.getMetadata(), Version.LATEST_BAGIT_VERSION(), bag.getRootDir(), StandardCharsets.UTF_8); + try { + for (var m : bag.getTagManifests()) { + var messageDigest = MessageDigest.getInstance(m.getAlgorithm().getMessageDigestName()); + try (var is = FileUtils.openInputStream(bag.getRootDir().resolve("bag-info.txt").toFile())) { + var hash = Hex.encodeHexString(DigestUtils.digest(messageDigest, is)); + m.getFileToChecksumMap().put(bag.getRootDir().resolve("bag-info.txt"), hash); + } + } + ManifestWriter.writeTagManifests(bag.getTagManifests(), bag.getRootDir(), bag.getRootDir(), StandardCharsets.UTF_8); + } + catch (NoSuchAlgorithmException e) { + throw new IllegalStateException("Bag declared to have a tagmanifest with an algorithm but the algorithm does not exist ???", e); + } + } + + @Override + public Bag readBag(Path bagDir) throws UnparsableVersionException, InvalidBagitFileFormatException, IOException, MaliciousPathException, UnsupportedAlgorithmException { + return bagReader.read(bagDir); + } + + @Override + public Configuration readDepositProperties(Path depositDir) throws ConfigurationException { + var propertiesFile = depositDir.resolve(DEPOSIT_PROPERTIES_FILENAME); + var params = new Parameters(); + var paramConfig = params.properties() + .setFileName(propertiesFile.toString()); + + var builder = new FileBasedConfigurationBuilder + (PropertiesConfiguration.class, null, true) + .configure(paramConfig); + + return builder.getConfiguration(); + } + + @Override + public void saveDepositProperties(Path depositDir, Map configuration) throws ConfigurationException { + var params = new Parameters(); + var paramConfig = params.properties() + .setFileName(depositDir.resolve(DEPOSIT_PROPERTIES_FILENAME).toString()); + + var builder = new FileBasedConfigurationBuilder( + PropertiesConfiguration.class, null, true + ).configure(paramConfig); + + var config = builder.getConfiguration(); + + for (var entry : configuration.entrySet()) { + // setProperty overwrites existing values, so no clearing is needed + config.setProperty(entry.getKey(), entry.getValue()); + } + + builder.save(); + } +} \ No newline at end of file diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileService.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileService.java new file mode 100644 index 0000000..9d1ee8d --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileService.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.io; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.stream.Stream; + +public interface FileService { + + boolean isDirectory(Path path); + + Stream listDirectories(Path path) throws IOException; + + boolean fileExists(Path path); +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileServiceImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileServiceImpl.java new file mode 100644 index 0000000..4541779 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/io/FileServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.io; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Stream; + +public class FileServiceImpl implements FileService { + @Override + public boolean isDirectory(Path path) { + return Files.isDirectory(path); + } + + @Override + public Stream listDirectories(Path path) throws IOException { + return Files.list(path).filter(Files::isDirectory); + } + + @Override + public boolean fileExists(Path path) { + return Files.exists(path); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/DepositToDvDatasetMetadataMapper.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/DepositToDvDatasetMetadataMapper.java index 0a3e11c..0821a02 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/DepositToDvDatasetMetadataMapper.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/DepositToDvDatasetMetadataMapper.java @@ -20,9 +20,8 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.domain.VaultMetadata; -import nl.knaw.dans.ingest.core.exception.MissingRequiredFieldException; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.domain.VaultMetadata; +import nl.knaw.dans.dvingest.core.dansbag.exception.MissingRequiredFieldException; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.ArchaeologyFieldBuilder; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CitationFieldBuilder; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.DataVaultFieldBuilder; @@ -56,6 +55,7 @@ import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.Subject; import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.SubjectAbr; import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.TemporalAbr; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import nl.knaw.dans.lib.dataverse.CompoundFieldBuilder; import nl.knaw.dans.lib.dataverse.model.dataset.Dataset; import nl.knaw.dans.lib.dataverse.model.dataset.DatasetVersion; @@ -77,11 +77,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RIGHTS_HOLDER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SUBJECT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.TITLE; -import static nl.knaw.dans.ingest.core.service.XPathConstants.DDM_DCMI_METADATA; -import static nl.knaw.dans.ingest.core.service.XPathConstants.DDM_PROFILE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RIGHTS_HOLDER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SUBJECT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.TITLE; +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.DDM_DCMI_METADATA; +import static nl.knaw.dans.dvingest.core.dansbag.service.XPathConstants.DDM_PROFILE; @Slf4j @RequiredArgsConstructor diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/ArchaeologyFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/ArchaeologyFieldBuilder.java index 69bd1fa..7054b70 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/ArchaeologyFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/ArchaeologyFieldBuilder.java @@ -19,14 +19,14 @@ import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_ARTIFACT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_COMPLEX; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_PERIOD; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_RAPPORT_NUMMER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_RAPPORT_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_VERWERVINGSWIJZE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ARCHIS_NUMBER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ARCHIS_ZAAK_ID; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_ARTIFACT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_COMPLEX; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_PERIOD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_RAPPORT_NUMMER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_RAPPORT_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_VERWERVINGSWIJZE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ARCHIS_NUMBER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ARCHIS_ZAAK_ID; public class ArchaeologyFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/CitationFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/CitationFieldBuilder.java index 32bd454..0afaf94 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/CitationFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/CitationFieldBuilder.java @@ -22,26 +22,26 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ALTERNATIVE_TITLE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATASET_CONTACT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATA_SOURCES; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATE_OF_COLLECTION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATE_OF_DEPOSIT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DESCRIPTION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTION_DATE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.LANGUAGE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.NOTES_TEXT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PRODUCTION_DATE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PUBLICATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SERIES; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SUBJECT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.TITLE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ALTERNATIVE_TITLE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATASET_CONTACT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATA_SOURCES; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATE_OF_COLLECTION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATE_OF_DEPOSIT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DESCRIPTION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTION_DATE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.LANGUAGE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.NOTES_TEXT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PRODUCTION_DATE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PUBLICATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SERIES; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SUBJECT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.TITLE; public class CitationFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/DataVaultFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/DataVaultFieldBuilder.java index 54186fe..6cb8ebc 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/DataVaultFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/DataVaultFieldBuilder.java @@ -17,12 +17,12 @@ import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.BAG_ID; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DANS_OTHER_ID; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DANS_OTHER_ID_VERSION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATA_SUPPLIER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.NBN; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SWORD_TOKEN; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.BAG_ID; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DANS_OTHER_ID; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DANS_OTHER_ID_VERSION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATA_SUPPLIER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.NBN; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SWORD_TOKEN; public class DataVaultFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RelationFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RelationFieldBuilder.java index ad47aec..828faf4 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RelationFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RelationFieldBuilder.java @@ -19,9 +19,9 @@ import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUDIENCE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.COLLECTION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RELATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUDIENCE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.COLLECTION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RELATION; public class RelationFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RightsFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RightsFieldBuilder.java index 54718c4..4d128ef 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RightsFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/RightsFieldBuilder.java @@ -18,9 +18,9 @@ import java.util.Objects; import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.LANGUAGE_OF_METADATA; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PERSONAL_DATA_PRESENT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RIGHTS_HOLDER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.LANGUAGE_OF_METADATA; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PERSONAL_DATA_PRESENT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RIGHTS_HOLDER; public class RightsFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/TemporalSpatialFieldBuilder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/TemporalSpatialFieldBuilder.java index e343798..5a56a3a 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/TemporalSpatialFieldBuilder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/builder/TemporalSpatialFieldBuilder.java @@ -19,11 +19,11 @@ import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_COVERAGE_CONTROLLED; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_COVERAGE_UNCONTROLLED; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_POINT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.TEMPORAL_COVERAGE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_COVERAGE_CONTROLLED; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_COVERAGE_UNCONTROLLED; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_POINT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.TEMPORAL_COVERAGE; public class TemporalSpatialFieldBuilder extends FieldBuilder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrAcquisitionMethod.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrAcquisitionMethod.java index e37448b..1f7bdde 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrAcquisitionMethod.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrAcquisitionMethod.java @@ -20,8 +20,8 @@ import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_VERWERVINGSWIJZE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_VERWERVINGSWIJZE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_VERWERVINGSWIJZE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_VERWERVINGSWIJZE; @Slf4j public class AbrAcquisitionMethod extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrReport.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrReport.java index f313fa6..805bde9 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrReport.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AbrReport.java @@ -20,8 +20,8 @@ import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_RAPPORT_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_RAPPORT_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_RAPPORT_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_RAPPORT_TYPE; @Slf4j public class AbrReport extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AccessRights.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AccessRights.java index 8d435f1..211d0a6 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AccessRights.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/AccessRights.java @@ -16,7 +16,7 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.w3c.dom.Node; import java.util.Map; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Amd.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Amd.java index 553602b..a167d10 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Amd.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Amd.java @@ -16,14 +16,14 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; import java.util.Optional; -import static nl.knaw.dans.ingest.core.domain.DepositState.PUBLISHED; -import static nl.knaw.dans.ingest.core.domain.DepositState.SUBMITTED; +import static nl.knaw.dans.dvingest.core.dansbag.domain.DepositState.PUBLISHED; +import static nl.knaw.dans.dvingest.core.dansbag.domain.DepositState.SUBMITTED; @Slf4j public class Amd extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Base.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Base.java index 5019f34..df338c5 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Base.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Base.java @@ -16,7 +16,7 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; @@ -29,7 +29,7 @@ import java.util.Optional; import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.XmlReader.NAMESPACE_XSI; +import static nl.knaw.dans.dvingest.core.dansbag.service.XmlReader.NAMESPACE_XSI; @Slf4j public class Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contact.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contact.java index 4c8eefb..871e221 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contact.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contact.java @@ -19,9 +19,9 @@ import nl.knaw.dans.lib.dataverse.model.user.AuthenticatedUser; import org.apache.commons.lang3.StringUtils; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATASET_CONTACT_AFFILIATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATASET_CONTACT_EMAIL; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATASET_CONTACT_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATASET_CONTACT_AFFILIATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATASET_CONTACT_EMAIL; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATASET_CONTACT_NAME; public class Contact { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contributor.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contributor.java index f3e8c64..b686191 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contributor.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Contributor.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; @Slf4j public final class Contributor extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Creator.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Creator.java index f5caa6f..36535e6 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Creator.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Creator.java @@ -19,7 +19,7 @@ import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; import org.w3c.dom.Node; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_NAME; @Slf4j public final class Creator extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DatesOfCollection.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DatesOfCollection.java index b7ac383..0fe3ff2 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DatesOfCollection.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DatesOfCollection.java @@ -21,8 +21,8 @@ import java.util.regex.Pattern; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATE_OF_COLLECTION_END; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DATE_OF_COLLECTION_START; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATE_OF_COLLECTION_END; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DATE_OF_COLLECTION_START; @Slf4j public class DatesOfCollection extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiAuthor.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiAuthor.java index 44bb8c5..0bec01a 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiAuthor.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiAuthor.java @@ -16,24 +16,24 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.domain.DatasetAuthor; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.domain.DatasetAuthor; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; import java.util.List; import java.util.Optional; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_AFFILIATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER_SCHEME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_NAME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR_TYPE; import static nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.Contributor.contributorRoleToContributorType; import static nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.IdUriHelper.reduceUriToId; import static nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.IdUriHelper.reduceUriToOrcidId; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_AFFILIATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER_SCHEME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR_TYPE; @Slf4j public final class DcxDaiAuthor extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiOrganization.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiOrganization.java index 0453ce9..34d29ff 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiOrganization.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DcxDaiOrganization.java @@ -16,22 +16,22 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.domain.DatasetOrganization; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.domain.DatasetOrganization; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; import java.util.Set; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER_SCHEME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.AUTHOR_NAME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.CONTRIBUTOR_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; import static nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.IdUriHelper.reduceUriToId; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_IDENTIFIER_SCHEME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.AUTHOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.CONTRIBUTOR_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; @Slf4j public final class DcxDaiOrganization { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesOtherDoi.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesOtherDoi.java index 59aecf7..0b654b7 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesOtherDoi.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesOtherDoi.java @@ -17,8 +17,8 @@ import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_VALUE; public class DepositPropertiesOtherDoi extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesVaultMetadata.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesVaultMetadata.java index a9bdffc..68da42d 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesVaultMetadata.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/DepositPropertiesVaultMetadata.java @@ -18,8 +18,8 @@ import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; import org.apache.commons.lang3.StringUtils; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_VALUE; public class DepositPropertiesVaultMetadata extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Description.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Description.java index f941cbd..e100b8d 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Description.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Description.java @@ -24,8 +24,8 @@ import java.util.Map; import java.util.stream.Collectors; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DESCRIPTION_VALUE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SERIES_INFORMATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DESCRIPTION_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SERIES_INFORMATION; public class Description extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/FileElement.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/FileElement.java index 4963ec2..f126a82 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/FileElement.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/FileElement.java @@ -17,9 +17,9 @@ import lombok.Value; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.domain.Deposit; -import nl.knaw.dans.ingest.core.domain.FileInfo; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; +import nl.knaw.dans.dvingest.core.dansbag.domain.Deposit; +import nl.knaw.dans.dvingest.core.dansbag.domain.FileInfo; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Funder.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Funder.java index 5c02d15..9152a19 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Funder.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Funder.java @@ -17,16 +17,16 @@ import lombok.Builder; import lombok.Data; -import nl.knaw.dans.ingest.core.service.XPathEvaluator; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; +import nl.knaw.dans.dvingest.core.dansbag.service.XPathEvaluator; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; import java.util.stream.Collectors; import java.util.stream.Stream; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; public class Funder { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/HasOrganizationalIdentifier.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/HasOrganizationalIdentifier.java index 72aa8d7..1dfb347 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/HasOrganizationalIdentifier.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/HasOrganizationalIdentifier.java @@ -18,8 +18,8 @@ import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; import org.apache.commons.lang3.StringUtils; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_VALUE; public class HasOrganizationalIdentifier { public static CompoundFieldGenerator toOtherIdValue = (builder, value) -> { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Identifier.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Identifier.java index 3da6f0a..a412ddc 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Identifier.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Identifier.java @@ -15,24 +15,24 @@ */ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; -import nl.knaw.dans.ingest.core.service.XmlReader; import nl.knaw.dans.dvingest.core.dansbag.mapper.builder.CompoundFieldGenerator; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReader; import org.w3c.dom.Node; import java.util.Map; import java.util.Optional; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ARCHIS_NUMBER_ID; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ARCHIS_NUMBER_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.OTHER_ID_VALUE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PUBLICATION_CITATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PUBLICATION_ID_NUMBER; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PUBLICATION_ID_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.PUBLICATION_URL; -import static nl.knaw.dans.ingest.core.service.XmlReader.NAMESPACE_XSI; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ARCHIS_NUMBER_ID; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ARCHIS_NUMBER_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.GRANT_NUMBER_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_AGENCY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.OTHER_ID_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PUBLICATION_CITATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PUBLICATION_ID_NUMBER; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PUBLICATION_ID_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.PUBLICATION_URL; +import static nl.knaw.dans.dvingest.core.dansbag.service.XmlReader.NAMESPACE_XSI; public class Identifier extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Language.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Language.java index 2e49e50..f9bb534 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Language.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Language.java @@ -22,9 +22,9 @@ import java.util.Optional; import java.util.Set; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VALUE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY_URI; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY_URI; public class Language extends Base { public static CompoundFieldGenerator toKeywordValue = (builder, value) -> { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/LicenseElem.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/LicenseElem.java index be1ef0c..4e6a021 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/LicenseElem.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/LicenseElem.java @@ -16,7 +16,7 @@ package nl.knaw.dans.dvingest.core.dansbag.mapper.mapping; import lombok.extern.slf4j.Slf4j; -import nl.knaw.dans.ingest.core.service.XmlReader; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReader; import org.w3c.dom.Node; import java.net.URI; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Publisher.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Publisher.java index c92366a..be059a3 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Publisher.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Publisher.java @@ -21,11 +21,11 @@ import java.util.Set; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR_ABBREVIATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR_AFFILIATION; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR_LOGO_URL; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR_NAME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.DISTRIBUTOR_URL; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR_ABBREVIATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR_AFFILIATION; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR_LOGO_URL; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR_NAME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.DISTRIBUTOR_URL; @Slf4j public class Publisher extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Relation.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Relation.java index 7cac7f2..12d0ef2 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Relation.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Relation.java @@ -21,9 +21,9 @@ import java.util.HashMap; import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RELATION_TEXT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RELATION_TYPE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.RELATION_URI; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RELATION_TEXT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RELATION_TYPE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.RELATION_URI; public class Relation extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialBox.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialBox.java index 78d80cd..ad094d2 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialBox.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialBox.java @@ -20,11 +20,11 @@ import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX_EAST; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX_NORTH; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX_SCHEME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX_SOUTH; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_BOX_WEST; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX_EAST; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX_NORTH; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX_SCHEME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX_SOUTH; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_BOX_WEST; @Slf4j public class SpatialBox extends Spatial { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialPoint.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialPoint.java index 5fc190a..2c537ee 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialPoint.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SpatialPoint.java @@ -20,9 +20,9 @@ import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_POINT_SCHEME; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_POINT_X; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SPATIAL_POINT_Y; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_POINT_SCHEME; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_POINT_X; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SPATIAL_POINT_Y; @Slf4j public class SpatialPoint extends Spatial { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Subject.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Subject.java index 85a3e5f..81140e5 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Subject.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/Subject.java @@ -21,9 +21,9 @@ import java.util.regex.Pattern; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VALUE; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY_URI; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VALUE; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.KEYWORD_VOCABULARY_URI; @Slf4j public class Subject extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SubjectAbr.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SubjectAbr.java index b36f93a..a8f8880 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SubjectAbr.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/SubjectAbr.java @@ -23,13 +23,13 @@ import java.nio.file.Paths; import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.ABR_BASE_URL; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_ARTIFACT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_COMPLEX; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_OLD; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_ARTIFACT; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_COMPLEX; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_OLD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.ABR_BASE_URL; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_ARTIFACT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_COMPLEX; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_OLD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_ARTIFACT; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_COMPLEX; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_OLD; @Slf4j public class SubjectAbr extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/TemporalAbr.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/TemporalAbr.java index 411087e..0f85c6d 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/TemporalAbr.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/mapper/mapping/TemporalAbr.java @@ -20,10 +20,10 @@ import java.util.Map; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_PERIOD; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_ABR_PLUS; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_PERIOD; -import static nl.knaw.dans.ingest.core.service.DepositDatasetFieldNames.SCHEME_URI_ABR_PLUS; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_PERIOD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_ABR_PLUS; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_PERIOD; +import static nl.knaw.dans.dvingest.core.dansbag.service.DepositDatasetFieldNames.SCHEME_URI_ABR_PLUS; @Slf4j public class TemporalAbr extends Base { diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/DepositDatasetFieldNames.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/DepositDatasetFieldNames.java new file mode 100644 index 0000000..e3d0060 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/DepositDatasetFieldNames.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +public interface DepositDatasetFieldNames { + String TITLE = "title"; + String SUBTITLE = "subtitle"; + String ALTERNATIVE_TITLE = "alternativeTitle"; + String ALTERNATIVE_URL = "alternativeURL"; + String OTHER_ID = "otherId"; + String OTHER_ID_AGENCY = "otherIdAgency"; + String OTHER_ID_VALUE = "otherIdValue"; + String AUTHOR = "author"; + String AUTHOR_NAME = "authorName"; + String AUTHOR_AFFILIATION = "authorAffiliation"; + String AUTHOR_IDENTIFIER_SCHEME = "authorIdentifierScheme"; + String AUTHOR_IDENTIFIER = "authorIdentifier"; + String DATASET_CONTACT = "datasetContact"; + String DATASET_CONTACT_NAME = "datasetContactName"; + String DATASET_CONTACT_AFFILIATION = "datasetContactAffiliation"; + String DATASET_CONTACT_EMAIL = "datasetContactEmail"; + String DESCRIPTION = "dsDescription"; + String DESCRIPTION_VALUE = "dsDescriptionValue"; + String DESCRIPTION_DATE = "dsDescriptionDate"; + String SUBJECT = "subject"; + String KEYWORD = "keyword"; + String KEYWORD_VALUE = "keywordValue"; + String KEYWORD_VOCABULARY = "keywordVocabulary"; + String KEYWORD_VOCABULARY_URI = "keywordVocabularyURI"; + String TOPIC_CLASSIFICATION = "topicClassification"; + String TOPIC_CLASSVALUE = "topicClassValue"; + String TOPIC_CLASSVOCAB = "topicClassVocab"; + String TOPIC_CLASSVOCAB_URI = "topicClassVocabURI"; + String PUBLICATION = "publication"; + String PUBLICATION_CITATION = "publicationCitation"; + String PUBLICATION_ID_TYPE = "publicationIDType"; + String PUBLICATION_ID_NUMBER = "publicationIDNumber"; + String PUBLICATION_URL = "publicationURL"; + String NOTES_TEXT = "notesText"; + String LANGUAGE = "language"; + String PRODUCER = "producer"; + String PRODUCER_NAME = "producerName"; + String PRODUCER_AFFILIATION = "producerAffiliation"; + String PRODUCER_ABBREVIATION = "producerAbbreviation"; + String PRODUCER_URL = "producerURL"; + String PRODUCER_LOGO_URL = "producerLogoURL"; + String PRODUCTION_DATE = "productionDate"; + String PRODUCTION_PLACE = "productionPlace"; + String CONTRIBUTOR = "contributor"; + String CONTRIBUTOR_TYPE = "contributorType"; + String CONTRIBUTOR_NAME = "contributorName"; + String GRANT_NUMBER = "grantNumber"; + String GRANT_NUMBER_AGENCY = "grantNumberAgency"; + String GRANT_NUMBER_VALUE = "grantNumberValue"; + String DISTRIBUTOR = "distributor"; + String DISTRIBUTOR_NAME = "distributorName"; + String DISTRIBUTOR_AFFILIATION = "distributorAffiliation"; + String DISTRIBUTOR_ABBREVIATION = "distributorAbbreviation"; + String DISTRIBUTOR_URL = "distributorURL"; + String DISTRIBUTOR_LOGO_URL = "distributorLogoURL"; + String DISTRIBUTION_DATE = "distributionDate"; + String DEPOSITOR = "depositor"; + String DATE_OF_DEPOSIT = "dateOfDeposit"; + String TIME_PERIOD_COVERED = "timePeriodCovered"; + String TIME_PERIOD_COVERED_START = "timePeriodCoveredStart"; + String TIME_PERIOD_COVERED_END = "timePeriodCoveredEnd"; + String DATE_OF_COLLECTION = "dateOfCollection"; + String DATE_OF_COLLECTION_START = "dateOfCollectionStart"; + String DATE_OF_COLLECTION_END = "dateOfCollectionEnd"; + String KIND_OF_DATA = "kindOfData"; + String SERIES = "series"; + String SERIES_NAME = "seriesName"; + String SERIES_INFORMATION = "seriesInformation"; + String SOFTWARE = "software"; + String SOFTWARE_NAME = "softwareName"; + String SOFTWARE_VERSION = "softwareVersion"; + String RELATED_MATERIAL = "relatedMaterial"; + String RELATED_DATASETS = "relatedDatasets"; + String OTHER_REFERENCES = "otherReferences"; + String DATA_SOURCES = "dataSources"; + String ORIGIN_OF_SOURCES = "originOfSources"; + String CHARACTERISTICS_OF_SOURCES = "characteristicOfSources"; + String ACCESS_TO_SOURCES = "accessToSources"; + + String RIGHTS_HOLDER = "dansRightsHolder"; + String PERSONAL_DATA_PRESENT = "dansPersonalDataPresent"; + String LANGUAGE_OF_METADATA = "dansMetadataLanguage"; + String AUDIENCE = "dansAudience"; + + String COLLECTION = "dansCollection"; + + String RELATION = "dansRelation"; + String RELATION_TYPE = "dansRelationType"; + String RELATION_URI = "dansRelationURI"; + String RELATION_TEXT = "dansRelationText"; + + String ARCHIS_ZAAK_ID = "dansArchisZaakId"; + String ARCHIS_NUMBER = "dansArchisNumber"; + String ARCHIS_NUMBER_TYPE = "dansArchisNumberType"; + String ARCHIS_NUMBER_ID = "dansArchisNumberId"; + String ABR_RAPPORT_TYPE = "dansAbrRapportType"; + String ABR_RAPPORT_NUMMER = "dansAbrRapportNummer"; + String ABR_VERWERVINGSWIJZE = "dansAbrVerwervingswijze"; + String ABR_COMPLEX = "dansAbrComplex"; + String ABR_ARTIFACT = "dansAbrArtifact"; + String ABR_PERIOD = "dansAbrPeriod"; + + String ABR_BASE_URL = "https://data.cultureelerfgoed.nl/term/id/abr"; + String SCHEME_ABR_OLD = "Archeologisch Basis Register"; + String SCHEME_URI_ABR_OLD = "https://data.cultureelerfgoed.nl/term/id/rn/a4a7933c-e096-4bcf-a921-4f70a78749fe"; + String SCHEME_ABR_PLUS = "Archeologisch Basis Register"; + String SCHEME_URI_ABR_PLUS = "https://data.cultureelerfgoed.nl/term/id/abr/b6df7840-67bf-48bd-aa56-7ee39435d2ed"; + + String SCHEME_ABR_COMPLEX = "ABR Complextypen"; + String SCHEME_URI_ABR_COMPLEX = "https://data.cultureelerfgoed.nl/term/id/abr/e9546020-4b28-4819-b0c2-29e7c864c5c0"; + + String SCHEME_ABR_ARTIFACT = "ABR Artefacten"; + String SCHEME_URI_ABR_ARTIFACT = "https://data.cultureelerfgoed.nl/term/id/abr/22cbb070-6542-48f0-8afe-7d98d398cc0b"; + + String SCHEME_ABR_PERIOD = "ABR Periodes"; + String SCHEME_URI_ABR_PERIOD = "https://data.cultureelerfgoed.nl/term/id/abr/9b688754-1315-484b-9c89-8817e87c1e84"; + + String SCHEME_ABR_RAPPORT_TYPE = "ABR Rapporten"; + String SCHEME_URI_ABR_RAPPORT_TYPE = "https://data.cultureelerfgoed.nl/term/id/abr/7a99aaba-c1e7-49a4-9dd8-d295dbcc870e"; + + String SCHEME_ABR_VERWERVINGSWIJZE = "ABR verwervingswijzen"; + String SCHEME_URI_ABR_VERWERVINGSWIJZE = "https://data.cultureelerfgoed.nl/term/id/abr/554ca1ec-3ed8-42d3-ae4b-47bcb848b238"; + + String TEMPORAL_COVERAGE = "dansTemporalCoverage"; + String SPATIAL_POINT = "dansSpatialPoint"; + String SPATIAL_POINT_SCHEME = "dansSpatialPointScheme"; + String SPATIAL_POINT_X = "dansSpatialPointX"; + String SPATIAL_POINT_Y = "dansSpatialPointY"; + String SPATIAL_BOX = "dansSpatialBox"; + String SPATIAL_BOX_SCHEME = "dansSpatialBoxScheme"; + String SPATIAL_BOX_NORTH = "dansSpatialBoxNorth"; + String SPATIAL_BOX_EAST = "dansSpatialBoxEast"; + String SPATIAL_BOX_SOUTH = "dansSpatialBoxSouth"; + String SPATIAL_BOX_WEST = "dansSpatialBoxWest"; + String SPATIAL_COVERAGE_CONTROLLED = "dansSpatialCoverageControlled"; + String SPATIAL_COVERAGE_UNCONTROLLED = "dansSpatialCoverageText"; + String DATAVERSE_PID = "dansDataversePid"; + String DATAVERSE_PID_VERSION = "dansDataversePidVersion"; + String BAG_ID = "dansBagId"; + String NBN = "dansNbn"; + String DANS_OTHER_ID = "dansOtherId"; + String DANS_OTHER_ID_VERSION = "dansOtherIdVersion"; + String SWORD_TOKEN = "dansSwordToken"; + String DATA_SUPPLIER = "dansDataSupplier"; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelper.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelper.java new file mode 100644 index 0000000..ca1f18b --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelper.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import gov.loc.repository.bagit.domain.Bag; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; + +public interface ManifestHelper { + void ensureSha1ManifestPresent(Bag bag) throws NoSuchAlgorithmException, IOException; + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelperImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelperImpl.java new file mode 100644 index 0000000..0d5c03b --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelperImpl.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import gov.loc.repository.bagit.creator.CreatePayloadManifestsVistor; +import gov.loc.repository.bagit.creator.CreateTagManifestsVistor; +import gov.loc.repository.bagit.domain.Bag; +import gov.loc.repository.bagit.domain.Manifest; +import gov.loc.repository.bagit.hash.Hasher; +import gov.loc.repository.bagit.hash.StandardSupportedAlgorithms; +import gov.loc.repository.bagit.util.PathUtils; +import gov.loc.repository.bagit.writer.ManifestWriter; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static gov.loc.repository.bagit.hash.StandardSupportedAlgorithms.SHA1; + +public class ManifestHelperImpl implements ManifestHelper { + + @Override + public void ensureSha1ManifestPresent(Bag bag) throws NoSuchAlgorithmException, IOException { + var manifests = bag.getPayLoadManifests(); + var algorithms = manifests.stream().map(Manifest::getAlgorithm); + + if (algorithms.anyMatch(SHA1::equals)) { + return; + } + + var payloadFilesMap = Hasher.createManifestToMessageDigestMap(List.of(SHA1)); + var payloadVisitor = new CreatePayloadManifestsVistor(payloadFilesMap, true); + Files.walkFileTree(PathUtils.getDataDir(bag), payloadVisitor); + manifests.addAll(payloadFilesMap.keySet()); + ManifestWriter.writePayloadManifests(manifests, PathUtils.getBagitDir(bag), bag.getRootDir(), bag.getFileEncoding()); + + updateTagManifests(bag); + } + + private static void updateTagManifests(Bag bag) throws NoSuchAlgorithmException, IOException { + var algorithms = bag.getTagManifests().stream() + .map(Manifest::getAlgorithm) + .collect(Collectors.toList()); + var tagFilesMap = Hasher.createManifestToMessageDigestMap(algorithms); + var bagRootDir = bag.getRootDir(); + var tagVisitor = new CreateTagManifestsVistor(tagFilesMap, true) { + + @Override + public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { + /* + * Fix for EASY-1306: a tag manifest must not contain an entry for itself, as this is practically + * impossible to calculate. It could in theory contain entries for other tag manifests. However, + * the CreateTagManifestsVistor, once it finds an entry for a tag file in ONE of the tag manifests, + * will add an entry in ALL tag manifests. + * + * Therefore, we adopt the strategy NOT to calculate any checksums for the tag manifests themselves. + * + * Update: this is actually required in V1.0: https://tools.ietf.org/html/rfc8493#section-2.2.1 + */ + var isTagManifest = bagRootDir.relativize(path).getNameCount() == 1 && + path.getFileName().toString().startsWith("tagmanifest-"); + + if (isTagManifest) { + return FileVisitResult.CONTINUE; + } + else { + return super.visitFile(path, attrs); + } + } + }; + + Files.walkFileTree(bagRootDir, tagVisitor); + bag.getTagManifests().clear(); + bag.getTagManifests().addAll(tagFilesMap.keySet()); + ManifestWriter.writeTagManifests(bag.getTagManifests(), PathUtils.getBagitDir(bag), bagRootDir, bag.getFileEncoding()); + } + + static public Map getFilePathToSha1(Bag bag) { + var result = new HashMap(); + var manifest = bag.getPayLoadManifests().stream() + .filter(item -> item.getAlgorithm().equals(StandardSupportedAlgorithms.SHA1)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("Deposit bag does not have SHA-1 payload manifest")); + + for (var entry : manifest.getFileToChecksumMap().entrySet()) { + result.put(bag.getRootDir().relativize(entry.getKey()), entry.getValue()); + } + + return result; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathConstants.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathConstants.java new file mode 100644 index 0000000..1ae81f5 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathConstants.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +public interface XPathConstants { + String DDM_PROFILE = "/ddm:DDM/ddm:profile"; + String DDM_DCMI_METADATA = "/ddm:DDM/ddm:dcmiMetadata"; + String FILES_FILE = "/files:files/files:file"; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathEvaluator.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathEvaluator.java new file mode 100644 index 0000000..7ebe260 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XPathEvaluator.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public final class XPathEvaluator implements XmlNamespaces { + + private static XPath xpath; + + private static XPath getXpath() { + if (xpath == null) { + xpath = XPathFactory + .newInstance() + .newXPath(); + + final var namespaceMap = new HashMap(); + namespaceMap.put("xml", XmlNamespaces.NAMESPACE_XML); + namespaceMap.put("dc", XmlNamespaces.NAMESPACE_DC); + namespaceMap.put("dcx-dai", XmlNamespaces.NAMESPACE_DCX_DAI); + namespaceMap.put("ddm", XmlNamespaces.NAMESPACE_DDM); + namespaceMap.put("dcterms", XmlNamespaces.NAMESPACE_DCTERMS); + namespaceMap.put("xsi", XmlNamespaces.NAMESPACE_XSI); + namespaceMap.put("id-type", XmlNamespaces.NAMESPACE_ID_TYPE); + namespaceMap.put("dcx-gml", XmlNamespaces.NAMESPACE_DCX_GML); + namespaceMap.put("files", XmlNamespaces.NAMESPACE_FILES_XML); + namespaceMap.put("afm", XmlNamespaces.NAMESPACE_AFM_XML); + namespaceMap.put("gml", XmlNamespaces.NAMESPACE_OPEN_GIS); + namespaceMap.put("wfs", XmlNamespaces.NAMESPACE_EASY_WORKFLOW); + namespaceMap.put("damd", XmlNamespaces.NAMESPACE_DAMD); + namespaceMap.put("agreements", XmlNamespaces.NAMESPACE_AGREEMENTS); + + xpath.setNamespaceContext(new NamespaceContext() { + + @Override + public String getNamespaceURI(String s) { + return namespaceMap.get(s); + } + + @Override + public String getPrefix(String s) { + return null; + } + + @Override + public Iterator getPrefixes(String s) { + return null; + } + }); + } + + return xpath; + } + + public static Stream nodes(Node node, String... expressions) { + try { + return xpathsToStream(node, expressions); + } + catch (XPathExpressionException e) { + // TODO add actual expression to error message + throw new RuntimeException("Error evaluating xpath", e); + } + } + + public static Stream strings(Node node, String... expressions) { + try { + return xpathsToStreamOfStrings(node, expressions); + } + catch (XPathExpressionException e) { + // TODO add actual expression to error message + throw new RuntimeException("Error evaluating xpath", e); + } + } + + private static synchronized Object evaluateXpath(Node node, String expr) throws XPathExpressionException { + return getXpath().compile(expr).evaluate(node, XPathConstants.NODESET); + } + + private static Stream xpathToStream(Node node, String expression) throws XPathExpressionException { + var nodes = (NodeList) evaluateXpath(node, expression); + + return IntStream.range(0, nodes.getLength()) + .mapToObj(nodes::item); + } + + private static Stream xpathsToStream(Node node, String... expressions) throws XPathExpressionException { + var items = new ArrayList>(); + + for (var expr : expressions) { + var item = xpathToStream(node, expr); + items.add(item); + } + + return items.stream().flatMap(i -> i); + } + + private static Stream xpathsToStreamOfStrings(Node node, String... expressions) throws XPathExpressionException { + return xpathsToStream(node, expressions).map(Node::getTextContent); + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlNamespaces.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlNamespaces.java new file mode 100644 index 0000000..228f7dc --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlNamespaces.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +public interface XmlNamespaces { + String NAMESPACE_XML = "http://www.w3.org/XML/1998/namespace"; + String NAMESPACE_DC = "http://purl.org/dc/elements/1.1/"; + String NAMESPACE_DCX_DAI = "http://easy.dans.knaw.nl/schemas/dcx/dai/"; + String NAMESPACE_DDM = "http://schemas.dans.knaw.nl/dataset/ddm-v2/"; + String NAMESPACE_DCTERMS = "http://purl.org/dc/terms/"; + String NAMESPACE_XSI = "http://www.w3.org/2001/XMLSchema-instance"; + String NAMESPACE_ID_TYPE = "http://easy.dans.knaw.nl/schemas/vocab/identifier-type/"; + String NAMESPACE_DCX_GML = "http://easy.dans.knaw.nl/schemas/dcx/gml/"; + String NAMESPACE_FILES_XML = "http://easy.dans.knaw.nl/schemas/bag/metadata/files/"; + String NAMESPACE_AFM_XML = "http://easy.dans.knaw.nl/schemas/bag/metadata/afm/"; + String NAMESPACE_OPEN_GIS = "http://www.opengis.net/gml"; + String NAMESPACE_EASY_WORKFLOW = "http://easy.dans.knaw.nl/easy/workflow/"; + String NAMESPACE_DAMD = "http://easy.dans.knaw.nl/easy/dataset-administrative-metadata/"; + String NAMESPACE_AGREEMENTS = "http://easy.dans.knaw.nl/schemas/bag/metadata/agreements/"; +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReader.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReader.java new file mode 100644 index 0000000..afc9f26 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReader.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.nio.file.Path; + +public interface XmlReader extends XmlNamespaces { + + Document readXmlFile(Path path) throws ParserConfigurationException, IOException, SAXException; + + Document readXmlString(String str) throws ParserConfigurationException, IOException, SAXException; + +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReaderImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReaderImpl.java new file mode 100644 index 0000000..bbcd146 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/XmlReaderImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathFactory; +import java.io.IOException; +import java.io.StringReader; +import java.nio.file.Path; +import java.util.Iterator; +import java.util.Map; + +public class XmlReaderImpl implements XmlReader { + + private final XPath xpath; + + public XmlReaderImpl() { + this.xpath = XPathFactory + .newInstance() + .newXPath(); + + final var namespaceMap = Map.of( + "xml", NAMESPACE_XML, + "dc", NAMESPACE_DC, + "dcx-dai", NAMESPACE_DCX_DAI, + "ddm", NAMESPACE_DDM, + "dcterms", NAMESPACE_DCTERMS, + "xsi", NAMESPACE_XSI, + "id-type", NAMESPACE_ID_TYPE, + "dcx-gml", NAMESPACE_DCX_GML, + "files", NAMESPACE_FILES_XML, + "gml", NAMESPACE_OPEN_GIS + ); + + xpath.setNamespaceContext(new NamespaceContext() { + + @Override + public String getNamespaceURI(String s) { + return namespaceMap.get(s); + } + + @Override + public String getPrefix(String s) { + return null; + } + + @Override + public Iterator getPrefixes(String s) { + return null; + } + }); + + } + + @Override + public Document readXmlFile(Path path) throws ParserConfigurationException, IOException, SAXException { + var factory = getFactory(); + + return factory + .newDocumentBuilder() + .parse(path.toFile()); + } + + @Override + public Document readXmlString(String str) throws ParserConfigurationException, IOException, SAXException { + var factory = getFactory(); + + return factory + .newDocumentBuilder() + .parse(new InputSource(new StringReader(str))); + } + + public DocumentBuilderFactory getFactory() throws ParserConfigurationException { + var factory = DocumentBuilderFactory.newInstance(); + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + factory.setNamespaceAware(true); + return factory; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ZipFileHandler.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ZipFileHandler.java new file mode 100644 index 0000000..a07c0f5 --- /dev/null +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ZipFileHandler.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nl.knaw.dans.dvingest.core.dansbag.service; + +import lombok.extern.slf4j.Slf4j; +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.CompressionMethod; +import org.apache.tika.Tika; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; + +@Slf4j +public class ZipFileHandler { + + private final Tika tika = new Tika(); + private final Path tempDir; + + private final Set needToBeZipWrapped = Set.of( + "application/zip", + "application/zipped-shapefile", + "application/fits-gzipped" + ); + + public Path zipOriginalMetadata(Path... xml) throws IOException { + + var tempFilePath = tempDir.resolve(String.format("original-metadata-%s.zip", UUID.randomUUID())); + + try (var zip = new ZipFile(tempFilePath.toFile())) { + for(var path: xml){ + zip.addFile(path.toFile(), zipWithoutCompressing()); + } + } + return tempFilePath; + } + + public ZipFileHandler(Path tempDir) { + this.tempDir = tempDir; + } + + public Optional wrapIfZipFile(Path path) throws IOException { + if (!needsToBeWrapped(path)) { + return Optional.empty(); + } + + var filename = Optional.ofNullable(path.getFileName()) + .map(Path::toString) + .orElse(""); + + var randomName = String.format("zip-wrapped-%s-%s.zip", + filename, UUID.randomUUID()); + + var tempFile = tempDir.resolve(randomName); + + try (var zip = new ZipFile(tempFile.toFile())) { + zip.addFile(path.toFile(), zipWithoutCompressing()); + } + + return Optional.of(tempFile); + } + + private ZipParameters zipWithoutCompressing() { + var params = new ZipParameters(); + params.setCompressionMethod(CompressionMethod.STORE); + return params; + } + + boolean needsToBeWrapped(Path path) throws IOException { + var endsWithZip = Optional.ofNullable(path.getFileName()) + .map(Path::toString) + .map(x -> x.endsWith(".zip")) + .orElse(false); + + log.trace("Checking if path {} needs to be wrapped: endsWithZip={}", path, endsWithZip); + + return endsWithZip || needToBeZipWrapped.contains(getMimeType(path)); + } + + String getMimeType(Path path) throws IOException { + String result = tika.detect(path); + log.trace("MimeType of path {} is {}", path, result); + return result; + } +} diff --git a/src/main/java/nl/knaw/dans/dvingest/core/service/DataverseService.java b/src/main/java/nl/knaw/dans/dvingest/core/service/DataverseService.java index 557be28..c7995ca 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/service/DataverseService.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/service/DataverseService.java @@ -26,10 +26,8 @@ import nl.knaw.dans.lib.dataverse.model.dataset.UpdateType; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; import nl.knaw.dans.lib.dataverse.model.user.AuthenticatedUser; -import org.checkerframework.checker.nullness.qual.NonNull; import java.io.IOException; -import java.net.URI; import java.nio.file.Path; import java.util.List; import java.util.Optional; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/service/YamlServiceImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/service/YamlServiceImpl.java index bc188dd..dfaed55 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/service/YamlServiceImpl.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/service/YamlServiceImpl.java @@ -31,7 +31,6 @@ import nl.knaw.dans.dvingest.core.yaml.UpdateState; import nl.knaw.dans.lib.dataverse.MetadataFieldDeserializer; import nl.knaw.dans.lib.dataverse.model.dataset.Dataset; -import nl.knaw.dans.lib.dataverse.model.dataset.MetadataBlockSummary; import nl.knaw.dans.lib.dataverse.model.dataset.MetadataField; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/yaml/AddEmbargo.java b/src/main/java/nl/knaw/dans/dvingest/core/yaml/AddEmbargo.java index 81c8cb0..9590e8a 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/yaml/AddEmbargo.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/yaml/AddEmbargo.java @@ -16,7 +16,6 @@ package nl.knaw.dans.dvingest.core.yaml; import lombok.Data; -import nl.knaw.dans.lib.dataverse.model.dataset.Embargo; import java.util.List; diff --git a/src/main/java/nl/knaw/dans/dvingest/core/yaml/EditFilesRoot.java b/src/main/java/nl/knaw/dans/dvingest/core/yaml/EditFilesRoot.java index 0bf2c00..68e8704 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/yaml/EditFilesRoot.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/yaml/EditFilesRoot.java @@ -18,7 +18,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.checkerframework.checker.units.qual.A; @Data @AllArgsConstructor diff --git a/src/main/java/nl/knaw/dans/ingest/core/service/DatasetEditor.java b/src/main/java/nl/knaw/dans/ingest/core/service/DatasetEditor.java index d2cdf97..31758f3 100644 --- a/src/main/java/nl/knaw/dans/ingest/core/service/DatasetEditor.java +++ b/src/main/java/nl/knaw/dans/ingest/core/service/DatasetEditor.java @@ -21,7 +21,6 @@ import nl.knaw.dans.ingest.core.dataverse.DatasetService; import nl.knaw.dans.ingest.core.domain.Deposit; import nl.knaw.dans.ingest.core.domain.FileInfo; -import nl.knaw.dans.dvingest.core.dansbag.mapper.mapping.FileElement; import nl.knaw.dans.lib.dataverse.DataverseClient; import nl.knaw.dans.lib.dataverse.DataverseException; import nl.knaw.dans.lib.dataverse.Version; @@ -177,24 +176,25 @@ protected String toJson(Map input) throws JsonProcessingExceptio } Map getFileInfo() { - var files = FileElement.pathToFileInfo(deposit, isMigration); - - return files.entrySet().stream() - .map(entry -> { - // relativize the path - var bagPath = entry.getKey(); - var fileInfo = entry.getValue(); - var newKey = Path.of("data").relativize(bagPath); - - return Map.entry(newKey, fileInfo); - }) - .filter(entry -> { - // remove entries that match the file exclusion pattern - var path = entry.getKey().toString(); - - return (fileExclusionPattern == null || !fileExclusionPattern.matcher(path).matches()); - }) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); +// var files = FileElement.pathToFileInfo(deposit, isMigration); +// +// return files.entrySet().stream() +// .map(entry -> { +// // relativize the path +// var bagPath = entry.getKey(); +// var fileInfo = entry.getValue(); +// var newKey = Path.of("data").relativize(bagPath); +// +// return Map.entry(newKey, fileInfo); +// }) +// .filter(entry -> { +// // remove entries that match the file exclusion pattern +// var path = entry.getKey().toString(); +// +// return (fileExclusionPattern == null || !fileExclusionPattern.matcher(path).matches()); +// }) +// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + return null; } // FIL008, FIL009 diff --git a/src/test/java/nl/knaw/dans/dvingest/core/dansbag/DansConversionFixture.java b/src/test/java/nl/knaw/dans/dvingest/core/dansbag/DansConversionFixture.java index dd950b8..a49c1bc 100644 --- a/src/test/java/nl/knaw/dans/dvingest/core/dansbag/DansConversionFixture.java +++ b/src/test/java/nl/knaw/dans/dvingest/core/dansbag/DansConversionFixture.java @@ -18,20 +18,20 @@ import gov.loc.repository.bagit.reader.BagReader; import nl.knaw.dans.dvingest.core.TestDirFixture; import nl.knaw.dans.dvingest.core.service.DataverseService; -import nl.knaw.dans.ingest.core.deposit.BagDirResolver; -import nl.knaw.dans.ingest.core.deposit.BagDirResolverImpl; -import nl.knaw.dans.ingest.core.deposit.DepositFileLister; -import nl.knaw.dans.ingest.core.deposit.DepositFileListerImpl; -import nl.knaw.dans.ingest.core.deposit.DepositReader; -import nl.knaw.dans.ingest.core.deposit.DepositReaderImpl; -import nl.knaw.dans.ingest.core.io.BagDataManager; -import nl.knaw.dans.ingest.core.io.BagDataManagerImpl; -import nl.knaw.dans.ingest.core.io.FileService; -import nl.knaw.dans.ingest.core.io.FileServiceImpl; -import nl.knaw.dans.ingest.core.service.ManifestHelper; -import nl.knaw.dans.ingest.core.service.ManifestHelperImpl; -import nl.knaw.dans.ingest.core.service.XmlReader; -import nl.knaw.dans.ingest.core.service.XmlReaderImpl; +import nl.knaw.dans.dvingest.core.dansbag.deposit.BagDirResolver; +import nl.knaw.dans.dvingest.core.dansbag.deposit.BagDirResolverImpl; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositFileLister; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositFileListerImpl; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositReader; +import nl.knaw.dans.dvingest.core.dansbag.deposit.DepositReaderImpl; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManager; +import nl.knaw.dans.dvingest.core.dansbag.io.BagDataManagerImpl; +import nl.knaw.dans.dvingest.core.dansbag.io.FileService; +import nl.knaw.dans.dvingest.core.dansbag.io.FileServiceImpl; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelper; +import nl.knaw.dans.dvingest.core.dansbag.service.ManifestHelperImpl; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReader; +import nl.knaw.dans.dvingest.core.dansbag.service.XmlReaderImpl; import nl.knaw.dans.dvingest.core.dansbag.mapper.DepositToDvDatasetMetadataMapper; import nl.knaw.dans.lib.dataverse.model.dataset.License; import nl.knaw.dans.lib.util.MappingLoader;