Skip to content

Commit

Permalink
add support for 0006-flat-omit-prefix-storage-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
pwinckles committed Jul 14, 2021
1 parent 695759a commit ae6feb5
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ them easy to interact with in a unix-like way.
- [0004-hashed-n-tuple-storage-layout](https://ocfl.github.io/extensions/0004-hashed-n-tuple-storage-layout.html)
- [0005-mutable-head](https://ocfl.github.io/extensions/0005-mutable-head.html):
Only read is supported; not write.
- [0006-flat-omit-prefix-storage-layout](https://ocfl.github.io/extensions/0006-flat-omit-prefix-storage-layout.html)

Additionally, it uses the following extensions for write support that
have not been specified:
Expand Down
141 changes: 141 additions & 0 deletions resources/main/specs/0006-flat-omit-prefix-storage-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# OCFL Community Extension 0006: Flat Omit Prefix Storage Layout

* **Extension Name:** 0006-flat-omit-prefix-storage-layout
* **Authors:** Andrew Woods
* **Minimum OCFL Version:** 1.0
* **OCFL Community Extensions Version:** 1.0
* **Obsoletes:** n/a
* **Obsoleted by:** n/a

## Overview

This storage root extension describes a flat OCFL storage layout. The OCFL object directories are direct children of
the OCFL storage root directory.
The OCFL object identifiers are expected to contain prefixes which are removed in the mapping to directory names. The
OCFL object identifier prefix is defined as all characters before and including a configurable delimiter.

The limitations of this layout are filesystem dependent, but are generally as follows:

* The size of object identifiers, minus the length of the prefix, cannot exceed the maximum allowed directory name size
(eg. 255 characters)
* Object identifiers cannot include characters that are illegal in directory names
* Performance may degrade as the size of a repository increases because every object is a direct child of the storage root

## Parameters

### Summary

* **Name:** `delimiter`
* **Description:** The case-insensitive, delimiter marking the end of the OCFL object identifier prefix; MUST consist
of a character string of length one or greater. If the delimiter is found multiple times in the OCFL object
identifier, its last occurence (right-most) will be used to select the termination of the prefix.
* **Type:** string
* **Constraints:** Must not be empty
* **Default:**

## Examples

### Example 1

This example demonstrates mappings where the single-character delimiter is found one or more times in the OCFL object
identifier.

#### Parameters

There is no default configuration; therefore, configuration parameters must be provided.

```json
{
"extensionName": "0006-flat-omit-prefix-storage-layout",
"delimiter": ":"
}
```

#### Mappings

| Object ID | Object Root Path |
| --- | --- |
| namespace:12887296 | `12887296` |
| urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 | `6e8bc430-9c3a-11d9-9669-0800200c9a66` |

#### Storage Hierarchy

```
[storage_root]/
├── 0=ocfl_1.0
├── ocfl_layout.json
├── 12887296/
│ ├── 0=ocfl_object_1.0
│ ├── inventory.json
│ ├── inventory.json.sha512
│ └── v1 [...]
└── 6e8bc430-9c3a-11d9-9669-0800200c9a66/
├── 0=ocfl_object_1.0
├── inventory.json
├── inventory.json.sha512
└── v1 [...]
```

### Example 2

This example demonstrates mappings where the multi-character delimiter is found one or more times in the OCFL object
identifier.

#### Parameters

There is no default configuration; therefore, configuration parameters must be provided.

```json
{
"extensionName": "0006-flat-omit-prefix-storage-layout",
"delimiter": "edu/"
}
```

#### Mappings

| Object ID | Object Root Path |
| --- | --- |
| https://institution.edu/3448793 | `3448793` |
| https://institution.edu/abc/edu/f8.05v | `f8.05v` |

#### Storage Hierarchy

```
[storage_root]/
├── 0=ocfl_1.0
├── ocfl_layout.json
├── 3448793/
│ ├── 0=ocfl_object_1.0
│ ├── inventory.json
│ ├── inventory.json.sha512
│ └── v1 [...]
└── f8.05v/
├── 0=ocfl_object_1.0
├── inventory.json
├── inventory.json.sha512
└── v1 [...]
```

### Example 3

This example demonstrates mappings that produce directory names that are invalid on unix filesystems; therefore this
layout cannot be used in a repository that needs to be able to store objects with identifiers like these.

#### Parameters

There is no default configuration; therefore, configuration parameters must be provided.

```json
{
"extensionName": "0006-flat-omit-prefix-storage-layout",
"delimiter": "info:"
}
```

#### Mappings

| Object ID | Object Root Path |
| --- | --- |
| info:fedora/object-01 | `fedora/object-01` |
| https://example.org/info:/12345/x54xz321/s3/f8.05v | `/12345/x54xz321/s3/f8.05v` |
4 changes: 4 additions & 0 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ fn create_layout(layout_name: Layout, config_file: Option<&Path>) -> Result<Opti
LayoutExtensionName::HashedNTupleObjectIdLayout,
config_bytes.as_deref(),
)?),
Layout::FlatOmitPrefix => Some(StorageLayout::new(
LayoutExtensionName::FlatOmitPrefixLayout,
config_bytes.as_deref(),
)?),
};

Ok(layout)
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ pub enum Layout {
HashedNTuple,
#[strum(serialize = "0003-hash-and-id-n-tuple-storage-layout")]
HashedNTupleObjectId,
#[strum(serialize = "0006-flat-omit-prefix-storage-layout")]
FlatOmitPrefix,
}

arg_enum! {
Expand Down
2 changes: 2 additions & 0 deletions src/ocfl/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub const HASHED_NTUPLE_OBJECT_ID_LAYOUT_EXTENSION: &str =
"0003-hash-and-id-n-tuple-storage-layout";
pub const HASHED_NTUPLE_LAYOUT_EXTENSION: &str = "0004-hashed-n-tuple-storage-layout";
pub const MUTABLE_HEAD_EXTENSION: &str = "0005-mutable-head";
pub const FLAT_OMIT_PREFIX_LAYOUT_EXTENSION: &str = "0006-flat-omit-prefix-storage-layout";
pub const ROCFL_STAGING_EXTENSION: &str = "rocfl-staging";
pub const ROCFL_LOCKS_EXTENSION: &str = "rocfl-locks";

Expand All @@ -32,6 +33,7 @@ pub static SUPPORTED_EXTENSIONS: Lazy<HashSet<&str>> = Lazy::new(|| {
set.insert(HASHED_NTUPLE_OBJECT_ID_LAYOUT_EXTENSION);
set.insert(HASHED_NTUPLE_LAYOUT_EXTENSION);
set.insert(MUTABLE_HEAD_EXTENSION);
set.insert(FLAT_OMIT_PREFIX_LAYOUT_EXTENSION);
set.insert(ROCFL_STAGING_EXTENSION);
set.insert(ROCFL_LOCKS_EXTENSION);
set
Expand Down
2 changes: 2 additions & 0 deletions src/ocfl/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ pub const EXT_0003_SPEC: &str =
include_str!("../../resources/main/specs/0003-hash-and-id-n-tuple-storage-layout.md");
pub const EXT_0004_SPEC: &str =
include_str!("../../resources/main/specs/0004-hashed-n-tuple-storage-layout.md");
pub const EXT_0006_SPEC: &str =
include_str!("../../resources/main/specs/0006-flat-omit-prefix-storage-layout.md");
1 change: 1 addition & 0 deletions src/ocfl/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ fn write_layout_config(root: impl AsRef<Path>, layout: &StorageLayout) -> Result
LayoutExtensionName::FlatDirectLayout => specs::EXT_0002_SPEC,
LayoutExtensionName::HashedNTupleObjectIdLayout => specs::EXT_0003_SPEC,
LayoutExtensionName::HashedNTupleLayout => specs::EXT_0004_SPEC,
LayoutExtensionName::FlatOmitPrefixLayout => specs::EXT_0006_SPEC,
};

write!(
Expand Down
Loading

0 comments on commit ae6feb5

Please sign in to comment.