Skip to content

Commit

Permalink
Merge pull request #155 from bcail/mark_foxml_deleted
Browse files Browse the repository at this point in the history
migrate FOXML file as deleted
  • Loading branch information
bbpennel authored Feb 23, 2021
2 parents 9d4bc6f + 4a70b6a commit 9059048
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,23 @@ Usage: migration-utils [-chrVx] [--debug] -a=<targetDir>
-a, --target-dir=<targetDir>
Directory where OCFL storage root and supporting
state will be written
-i, --working-dir=<workingDir>
Directory where supporting state will be written
(cached index of datastreams, ...)
-I, --delete-inactive Migrate objects and datastreams in the Inactive
state as deleted. Default: false.
-m, --migration-type=<migrationType>
Type of OCFL objects to migrate to. Choices:
FEDORA_OCFL | PLAIN_OCFL
Default: FEDORA_OCFL
--id-prefix=<idPrefix> Only use this for PLAIN_OCFL migrations: Prefix to
add to PIDs for OCFL object IDs - defaults to
info:fedora/, like Fedora3
Default: info:fedora/
--foxml-file Migrate FOXML file as a whole file, instead of
creating property files. FOXML file will be
migrated, then marked as deleted so it doesn't
show up as an active file.
-l, --limit=<objectLimit> Limit number of objects to be processed.
Default: no limit
-r, --resume Resume from last successfully migrated Fedora 3
Expand All @@ -72,8 +83,6 @@ Usage: migration-utils [-chrVx] [--debug] -a=<targetDir>
of exiting). Disabled by default.
Default: false
-p, --pid-file=<pidFile> PID file listing which Fedora 3 objects to migrate
-i, --index-dir=<indexDir> Directory where cached index of datastreams (will
reuse index if already exists)
-x, --extensions Add file extensions to migrated datastreams based
on mimetype recorded in FOXML
Default: false
Expand All @@ -87,6 +96,14 @@ Usage: migration-utils [-chrVx] [--debug] -a=<targetDir>
-U, --user-uri=<userUri> The username to associate with all of the migrated
resources.
Default: info:fedora/fedoraAdmin
--algorithm=<digestAlgorithm>
The digest algorithm to use in the OCFL objects
created. Either sha256 or sha512
Default: sha512
--no-checksum-validation
Disable validation that datastream content matches
Fedora 3 checksum.
Default: false
--debug Enables debug logging
```

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/fcrepo/migration/PicocliMigrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ static F3SourceTypes toType(final String v) {
private String idPrefix;

@Option(names = {"--foxml-file"}, defaultValue = "false", order = 21,
description = "Migrate foxml file as a whole file, instead of creating property files")
description = "Migrate FOXML file as a whole file, instead of creating property files. FOXML file will"
+ " be migrated, then marked as deleted so it doesn't show up as an active file.")
private boolean foxmlFile;

@Option(names = {"--limit", "-l"}, defaultValue = "-1", order = 22,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,14 @@ public void processObjectVersions(final Iterable<ObjectVersionReference> version
// Object properties are written only once (as fcrepo3 object properties were unversioned).
if (foxmlFile) {
try (InputStream is = Files.newInputStream(objectInfo.getFoxmlPath())) {
final var headers = createHeaders(f6ObjectId + "/FOXML", f6ObjectId,
final var foxmlDsId = f6ObjectId + "/FOXML";
final var headers = createHeaders(foxmlDsId, f6ObjectId,
InteractionModel.NON_RDF).build();
session.writeResource(headers, is);
//mark FOXML as a deleted datastream so it gets deleted in handleDeletedResources()
datastreamStates.put(foxmlDsId, DS_DELETED);
} catch (IOException io) {
LOGGER.error("error writing " + objectId + " foxml file to " + f6ObjectId + ": " + io);
LOGGER.error("error writing " + objectId + " FOXML file to " + f6ObjectId + ": " + io);
throw new UncheckedIOException(io);
}
} else {
Expand Down
15 changes: 14 additions & 1 deletion src/test/java/org/fcrepo/migration/PicocliIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import java.util.HashMap;
import java.util.Map;

import edu.wisc.library.ocfl.api.model.FileDetails;
import edu.wisc.library.ocfl.api.model.ObjectVersionId;
import edu.wisc.library.ocfl.api.model.VersionDetails;
import edu.wisc.library.ocfl.api.model.VersionInfo;
import edu.wisc.library.ocfl.core.extension.storage.layout.config.HashedNTupleLayoutConfig;
import org.apache.commons.codec.binary.Hex;
Expand Down Expand Up @@ -207,13 +209,24 @@ public void testMigrateFoxmlFileInsteadOfPropertyFiles() throws Exception {
}
final var expectedFiles = new ArrayList<String>();
expectedFiles.add("AUDIT");
expectedFiles.add("FOXML");
expectedFiles.add("DS2");
expectedFiles.add("DS1");
expectedFiles.add("DS4");
expectedFiles.add("DS3");
expectedFiles.add("DC");
assertEquals(expectedFiles, files);
//now check for a FOXML, which should show up in a previous version
final var versions = ocflRepo.describeObject("example:1").getVersionMap().values();
boolean foundFoxml = false;
for (VersionDetails v : versions) {
for (FileDetails f : v.getFiles()) {
if (f.getPath().equals("FOXML")) {
foundFoxml = true;
break;
}
}
}
assertTrue(foundFoxml);
}

@Test
Expand Down

0 comments on commit 9059048

Please sign in to comment.