Skip to content

Instantly share code, notes, and snippets.

View bbpennel's full-sized avatar

Ben Pennell bbpennel

  • UNC Chapel Hill Libraries
View GitHub Profile
@bbpennel
bbpennel / prefer-header-resolution.txt
Last active January 23, 2018 14:15
Draft proposal for Prefer header to suggest how a server should store and provide access to
o Preference: content-resolution
o Value: copy, proxy, redirect
o Optional Parameters: "content-type", it allows a client to indicate a preferred mimetype for the server to
provide in responses for this resource. To be used when the client is unable to provide type information for
the message content in the "Content-Type" header. Values defined as in
https://tools.ietf.org/html/rfc7231#section-3.1.1.5
o Description: Indicates the client's preference for how the server will store and provide access to the content
@bbpennel
bbpennel / addressing_binary_timemaps.md
Last active March 14, 2018 13:38
Planning for providing separate timemaps for a binary resource and its description.

Sibling timemaps

External Uri => Node Path

  • /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353 (binary)
    • => /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353/jcr:content
  • /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353/fcr:metadata (description)
    • => /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353
  • /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353/fcr:versions (binary timemap)
    • => /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353/fedora:binaryTimemap
  • /5bc56ed8-aa1c-44c7-a7fa-43d02e54e353/fcr:metadata/fcr:versions (description timemap)
@bbpennel
bbpennel / gist:a8d8b02b646a98b8c7a37ef40a9d362b
Created February 14, 2019 17:54
OCFL with file moved between versions mapped to Fcrepo
[object root]
├── 0=ocfl_object_1.0
├── inventory.json ( “id”: “obj1” )
├── inventory.json.sha512
└── v1
├── inventory.json
├── inventory.json.sha512
└── content
└── file.txt
└── subdir
@bbpennel
bbpennel / gist:343b950d5d3a33af64019ebb36e40c5c
Created February 14, 2019 19:01
Flat mapping of Fcrepo to OCFL
Fedora structure:
obj1 -> LDPC
└── file.txt -> LDPNR -> reference to memento 20190130120000
└── subdir -> LDPC
└── file1.txt -> LDPNR
└── file2.txt -> LDPNR
...
└── file1000000.txt -> LDPNR
[storage root]
@bbpennel
bbpennel / replace_non_ascii.sh
Last active September 24, 2019 13:37
Bash script which replaces all non-ASCII characters with another character in filenames for all files and directories contained within the target directory.
#!/usr/bin/env bash
USAGE="$(basename "$0") [-h] [-d] [-e] target_dir
Replaces all non-ASCII characters with another character in filenames
for all files and directories contained within the target directory.
where:
-h, --help Show this help text
-d, --dry-run Display the expected changes, but do not perform them. If

Example structure

  • my_book - AG
    • pages - folder with no user supplied triples
      • page1.png - internal binary with user supplied triples
      • page2.png - internal binary, no user triples
    • original_scan.pdf - external binary, no user triples

Sidecar fcrepo dir

.fcrepo/ # sidecar files containing fcrepo server managed triples

Example Persistence Layout for FSDB

In this example, there is:

  • an object, my_book, which is an AG
    • It has been assigned a fedora id info:fedora/91f6d9c2-dc27-4ab5-b626-df0a45e4519e
  • a head version contains a folder containing two binaries
  • one previous version, which contained only one binary
  • an active transaction that adds another folder and binary, and deletes a binary

File system representation

Example structure

  • my_book - AG
    • pages - Direct container, defining pcdm:hasFile
      • page1.png - internal binary with user supplied triples
      • page2.png - internal binary, no user triples
    • originals - container, no user triples
      • original_scan.pdf - external binary, no user triples

Persisted structure

File names are path components from fedora identifiers relative to the identifier of the AG.

// snippet from FedoraTransactionsIT
@Test
public void testConcurrentPutsAndCommits() throws Exception {
final String baseId = getRandomUniqueId();
final HttpPut putBase = new HttpPut(serverAddress + "/" + baseId);
try (final CloseableHttpResponse response = execute(putBase)) {
assertEquals(CREATED.getStatusCode(), getStatus(response));
} catch (IOException e) {
e.printStackTrace();