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 index e743b1a..ecf0180 100644 --- 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 @@ -17,18 +17,14 @@ import nl.knaw.dans.dvingest.core.dansbag.domain.DansBagDeposit; 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; @@ -37,9 +33,7 @@ public class DepositFileListerImpl implements DepositFileLister { @Override public List getDepositFiles(DansBagDeposit dansBagDeposit) throws IOException { var bag = dansBagDeposit.getBag(); - var bagDir = bag.getRootDir(); var filePathToSha1 = ManifestHelperImpl.getFilePathToSha1(bag); - var originalFilePathMappings = getOriginalFilePathMapping(bagDir); return XPathEvaluator.nodes(dansBagDeposit.getFilesXml(), FILES_FILE) .map(node -> { @@ -48,38 +42,10 @@ public List getDepositFiles(DansBagDeposit dansBagDeposit) throws I .map(Path::of) .orElseThrow(() -> new IllegalArgumentException("File element without filepath attribute")); - var physicalFile = originalFilePathMappings.getPhysicalPath(filePath); - var sha1 = filePathToSha1.get(physicalFile); + var sha1 = filePathToSha1.get(filePath); - return new DepositFile(filePath, physicalFile, sha1, node); + return new DepositFile(filePath, 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/domain/DansBagDeposit.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DansBagDeposit.java index 3141c67..74a318d 100644 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DansBagDeposit.java +++ b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DansBagDeposit.java @@ -22,7 +22,6 @@ 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; @@ -31,7 +30,6 @@ 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 @@ -76,11 +74,6 @@ 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); } 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 index 2d5ca26..146e61c 100644 --- 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 @@ -25,7 +25,6 @@ @AllArgsConstructor public class DepositFile { Path path; - Path physicalPath; String checksum; Node xmlNode; } 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 deleted file mode 100644 index 5d49e67..0000000 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/DepositLocation.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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/OriginalFilePathMapping.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OriginalFilePathMapping.java deleted file mode 100644 index c7e69eb..0000000 --- a/src/main/java/nl/knaw/dans/dvingest/core/dansbag/domain/OriginalFilePathMapping.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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/service/ManifestHelperImpl.java b/src/main/java/nl/knaw/dans/dvingest/core/dansbag/service/ManifestHelperImpl.java index 0d5c03b..150bd7b 100644 --- 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 @@ -70,7 +70,7 @@ public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IO /* * 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, + * the CreateTagManifestsVisitor, 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.