org.mycore.datamodel.ifs2
Class MCRMetadataStore

java.lang.Object
  extended by org.mycore.datamodel.ifs2.MCRStore
      extended by org.mycore.datamodel.ifs2.MCRMetadataStore
Direct Known Subclasses:
MCRVersioningMetadataStore

public class MCRMetadataStore
extends MCRStore

Stores XML metadata documents (or optionally any other BLOB data) in a persistent filesystem structure For each object type, a store must be defined as follows: MCR.IFS2.Store.DocPortal_document.Class=org.mycore.datamodel.ifs2.MCRMetadataStore MCR.IFS2.Store.DocPortal_document.BaseDir=/foo/bar MCR.IFS2.Store.DocPortal_document.SlotLayout=4-2-2 MCR.IFS2. MCR.IFS2.Store.DocPortal_document.ForceXML=true (which is default)

Author:
Frank Lützenkirchen

Field Summary
protected  boolean forceXML
          If true (which is default), store will enforce it gets XML to store, otherwise any binary content can be stored here.
 
Fields inherited from class org.mycore.datamodel.ifs2.MCRStore
ASCENDING, DESCENDING, dir, id, idLength, lastID, offset, prefix, slotLength, stores, suffix
 
Constructor Summary
MCRMetadataStore()
           
 
Method Summary
protected  MCRStoredMetadata buildMetadataObject(org.apache.commons.vfs.FileObject fo, int id)
          Builds a new stored metadata object in this store
 MCRStoredMetadata create(MCRContent xml)
          Stores a newly created document, using the next free ID.
 MCRStoredMetadata create(MCRContent xml, int id)
          Stores a newly created document under the given ID.
static MCRMetadataStore getStore(String type)
          Returns the store for the given metadata document type
protected  void init(String type)
          Initializes a new metadata store instance.
 MCRStoredMetadata retrieve(int id)
          Returns the metadata stored under the given ID, or null
protected  boolean shouldForceXML()
           
 
Methods inherited from class org.mycore.datamodel.ifs2.MCRStore
delete, delete, exists, getBaseDir, getHighestStoredID, getID, getNextFreeID, getSlot, getSlotPath, getSlotPaths, listIDs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forceXML

protected boolean forceXML
If true (which is default), store will enforce it gets XML to store, otherwise any binary content can be stored here. Override with MCR.IFS2.Store..ForceXML=true|false

Constructor Detail

MCRMetadataStore

public MCRMetadataStore()
Method Detail

getStore

public static MCRMetadataStore getStore(String type)
Returns the store for the given metadata document type

Parameters:
type - the type of metadata to store
Returns:
the store for this metadata type

init

protected void init(String type)
Initializes a new metadata store instance.

Overrides:
init in class MCRStore
Parameters:
type - the document type that is stored in this store

shouldForceXML

protected boolean shouldForceXML()

create

public MCRStoredMetadata create(MCRContent xml)
                         throws Exception
Stores a newly created document, using the next free ID.

Parameters:
xml - the XML document to be stored
Returns:
the stored metadata object
Throws:
Exception

create

public MCRStoredMetadata create(MCRContent xml,
                                int id)
                         throws Exception
Stores a newly created document under the given ID.

Parameters:
xml - the XML document to be stored
id - the ID under which the document should be stored
Returns:
the stored metadata object
Throws:
Exception

retrieve

public MCRStoredMetadata retrieve(int id)
                           throws Exception
Returns the metadata stored under the given ID, or null

Parameters:
id - the ID of the XML document
Returns:
the metadata stored under that ID, or null when there is no such metadata object
Throws:
Exception

buildMetadataObject

protected MCRStoredMetadata buildMetadataObject(org.apache.commons.vfs.FileObject fo,
                                                int id)
Builds a new stored metadata object in this store

Parameters:
fo - the FileObject that stores the data
id - the ID of the metadata object