-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copied old classes to new package before pruning
- Loading branch information
1 parent
06c80eb
commit 9c0da24
Showing
100 changed files
with
2,690 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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 | ||
* <ul> | ||
* <li>The path is not a directory</li> | ||
* <li>There is no deposit.properties file inside the path</li> | ||
* <li>There are no subdirectories in the path</li> | ||
* <li>There are more than 1 subdirectories in the path</li> | ||
* <li>The subdirectory does not contain a bagit.txt file</li> | ||
* </ul> | ||
* | ||
* @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; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/BagDirResolverImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/nl/knaw/dans/dvingest/core/dansbag/deposit/DepositFileLister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2024 DANS - Data Archiving and Networked Services ([email protected]) | ||
* | ||
* 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<DepositFile> getDepositFiles(Deposit deposit) throws IOException; | ||
|
||
} |
Oops, something went wrong.