org.mycore.services.urn
Class MCRURNManager

java.lang.Object
  extended by org.mycore.services.urn.MCRURNManager

public class MCRURNManager
extends Object

Provides methods to create URNs (urn:nbn:de) and assign them to documents. A URN (uniform resource name) is a special kind of persistent identifier. This class handles URNs from the german subnamespace of NBN (national bibliographic number), these URNs all start with urn:nbn:de:... More information on persistent identifiers can be found at http://www.persistent-identifier.de/ URNs are described by RFC 2141 and have the following syntax: urn:[NID]:[SNID]-[NISS][Checksum] NID = namespace ID, in this implementation always "nbn:de" SNID = subnamespace ID, a unique identifier for an organization or public library that creates and assigns URNs within its subnamespace NISS = namespace-specific string, a unique ID Checksum: all nbn:de URNs end with one digit that is a checksum Example: urn:nbn:de:465-miless-20060622-213404-0017 A MyCoRe systen can generate URNs for more than one subnamespace. There must be one or more configurations that control the prefix (subnamespace) of generated URNs and the algorithm used to build new NISS within that subnamespace. Each configuration has a unique "subnamespace configuration ID" in mycore.properties, and optional additional properties depending on the implementation. MCR.URN.SubNamespace.[ConfigID].Prefix=[URNPrefix], for example MCR.URN.SubNamespace.Essen.Prefix=urn.nbn.de:hbz:465-

Author:
Frank Lützenkirchen

Constructor Summary
MCRURNManager()
           
 
Method Summary
static void assignURN(String urn, String documentID)
          Assigns the given urn to the given document ID
static void assignURN(String urn, String derivateID, String path, String filename)
          Assigns the given urn to the given derivate ID
static String buildAndAssignURN(String documentID, String configID)
          Create and Assign a new URN to the given Document Ensure that new created URNs do not allready exist in URN store
static String buildChecksum(String urn)
          Calculates the checksum for the given urn:nbn:de.
static String buildURN(String configID)
          Builds a URN using a MCRNISSBuilder object.
static String buildURN(String configID, String niss)
          Builds a URN with a custom, given NISS.
static String getDocumentIDforURN(String urn)
          Retrieves the document ID that is assigned to the given urn
static String getURNforDocument(String documentID)
          Retrieves the URN that is assigned to the given document ID
static boolean hasURNAssigned(String objId)
           
static boolean isAssigned(String urn)
          Returns true if the given urn is assigned to a document ID
static boolean isValid(String urn)
          Returns true if the given URN has a valid structure and the checksum is correct.
static void removeURN(String urn)
          Removes the urn (and assigned document ID) from the persistent store
static void removeURNByObjectID(String objID)
          Removes the urn (and assigned document ID) from the persistent store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRURNManager

public MCRURNManager()
Method Detail

buildChecksum

public static String buildChecksum(String urn)
Calculates the checksum for the given urn:nbn:de. The algorithm is specified by the "Carmen AP-4" project.

Returns:
the checksum for the given urn:nbn:de

buildURN

public static String buildURN(String configID,
                              String niss)
Builds a URN with a custom, given NISS.

Parameters:
configID - the ID of a subnamespace configuration in mycore.properties
niss - the custom NISS
Returns:
the complete URN including prefix, NISS and calculated checksum

buildURN

public static String buildURN(String configID)
Builds a URN using a MCRNISSBuilder object.

Parameters:
configID - the ID of a subnamespace configuration in mycore.properties
Returns:
the complete URN including prefix, niss and calculated checksum

isValid

public static boolean isValid(String urn)
Returns true if the given URN has a valid structure and the checksum is correct.


isAssigned

public static boolean isAssigned(String urn)
Returns true if the given urn is assigned to a document ID


assignURN

public static void assignURN(String urn,
                             String documentID)
Assigns the given urn to the given document ID


hasURNAssigned

public static boolean hasURNAssigned(String objId)
Returns:
true if the given object has an urn assigned

assignURN

public static void assignURN(String urn,
                             String derivateID,
                             String path,
                             String filename)
Assigns the given urn to the given derivate ID

Parameters:
urn - the urn to assign
derivateID - the id of the derivate
path - the path of the derivate in the internal filesystem
filename - the filename

getURNforDocument

public static String getURNforDocument(String documentID)
Retrieves the URN that is assigned to the given document ID

Returns:
the urn, or null if no urn is assigned to this ID

getDocumentIDforURN

public static String getDocumentIDforURN(String urn)
Retrieves the document ID that is assigned to the given urn

Returns:
the ID, or null if no ID is assigned to this urn

removeURN

public static void removeURN(String urn)
Removes the urn (and assigned document ID) from the persistent store


removeURNByObjectID

public static void removeURNByObjectID(String objID)
Removes the urn (and assigned document ID) from the persistent store


buildAndAssignURN

public static String buildAndAssignURN(String documentID,
                                       String configID)
Create and Assign a new URN to the given Document Ensure that new created URNs do not allready exist in URN store

Parameters:
documentID - a MCRID
configID - - the configurationID of the URN Builder
Returns:
the URN