org.fcrepo.server.storage.lowlevel.akubra
Class HashPathIdMapper

java.lang.Object
  extended by org.fcrepo.server.storage.lowlevel.akubra.HashPathIdMapper
All Implemented Interfaces:
org.akubraproject.map.IdMapper

public class HashPathIdMapper
extends Object
implements org.akubraproject.map.IdMapper

Provides a hash-based file: mapping for any URI.

The path component of each internal URI is derived from an MD5 hash of the external URI. The filename component is a reversible encoding of the external URI that is safe to use as a filename on modern filesystems.

Hash Path Patterns

The pattern given at construction time determines how the path component of each internal URI will be composed. Within the pattern, the # character is a stand-in for a hexadecimal [0-f] digit from the MD5 hash of the external id.

Patterns:

Example patterns:

Filesystem-Safe Encoding

The last part of the internal URI is a "filesystem-safe" encoding of the external URI. All characters will be UTF-8 percent-encoded ("URI escaped") except for the following: a-z A-Z 0-9 = ( ) [ ] - In addition, . (period) will be escaped as %2E when it occurs as the last character of the URI.

Example Mappings

With pattern #/#: With pattern ##/##:

Author:
Chris Wilper

Constructor Summary
HashPathIdMapper(String pattern)
          Creates an instance that will use the given pattern.
 
Method Summary
 URI getExternalId(URI internalId)
           
 URI getInternalId(URI externalId)
           
 String getInternalPrefix(String externalPrefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashPathIdMapper

public HashPathIdMapper(String pattern)
Creates an instance that will use the given pattern.

Parameters:
pathPattern - the pattern to use, possibly null or "".
Throws:
IllegalArgumentException - if the pattern is invalid.
Method Detail

getExternalId

public URI getExternalId(URI internalId)
                  throws NullPointerException
Specified by:
getExternalId in interface org.akubraproject.map.IdMapper
Throws:
NullPointerException

getInternalId

public URI getInternalId(URI externalId)
                  throws NullPointerException
Specified by:
getInternalId in interface org.akubraproject.map.IdMapper
Throws:
NullPointerException

getInternalPrefix

public String getInternalPrefix(String externalPrefix)
                         throws NullPointerException
Specified by:
getInternalPrefix in interface org.akubraproject.map.IdMapper
Throws:
NullPointerException


Copyright © 2012 DuraSpace. All Rights Reserved.