org.mycore.datamodel.ifs2
Class MCRStoredNode

java.lang.Object
  extended by org.mycore.datamodel.ifs2.MCRNode
      extended by org.mycore.datamodel.ifs2.MCRStoredNode
Direct Known Subclasses:
MCRDirectory, MCRFile

public abstract class MCRStoredNode
extends MCRNode

A file or directory really stored by importing it from outside the system. Can be modified, updated and deleted, in contrast to virtual nodes.

Author:
Frank Lützenkirchen

Field Summary
protected  Element data
          Any additional data of this node that is not stored in the file object
 
Fields inherited from class org.mycore.datamodel.ifs2.MCRNode
fo, parent
 
Constructor Summary
protected MCRStoredNode(MCRDirectory parent, org.apache.commons.vfs.FileObject fo, Element data)
          Returns a stored node instance that already exists
protected MCRStoredNode(MCRDirectory parent, String name, String type)
          Creates a new stored node
 
Method Summary
 void clearLabels()
          Removes all labels set
 void delete()
          Deletes this node with all its data and children
 String getCurrentLabel()
          Returns the label in the current language, otherwise in default language, otherwise the first label defined, if any at all.
 String getLabel(String lang)
          Returns the label in the given language
 Map<String,String> getLabels()
          Returns a map of all labels, sorted by xml:lang, Key is xml:lang, value is the label for that language.
 void renameTo(String name)
          Renames this node.
(package private) abstract  void repairMetadata()
          Repairs additional metadata of this node
 void setLabel(String lang, String label)
          Sets a label for this node
 void setLastModified(Date time)
          Sets last modification time of this file to a custom value.
 
Methods inherited from class org.mycore.datamodel.ifs2.MCRNode
buildChildNode, getChild, getChildren, getContent, getLastModified, getName, getNodeByPath, getNumChildren, getParent, getPath, getRandomAccessContent, getRoot, getSize, hasChildren, isDirectory, isFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected Element data
Any additional data of this node that is not stored in the file object

Constructor Detail

MCRStoredNode

protected MCRStoredNode(MCRDirectory parent,
                        org.apache.commons.vfs.FileObject fo,
                        Element data)
                 throws Exception
Returns a stored node instance that already exists

Parameters:
parent - the parent directory containing this node
fo - the file object in local filesystem representing this node
data - the additional data of this node that is not stored in the file object
Throws:
Exception

MCRStoredNode

protected MCRStoredNode(MCRDirectory parent,
                        String name,
                        String type)
                 throws Exception
Creates a new stored node

Parameters:
parent - the parent directory
name - the name of the node
type - the node type, dir or file
Throws:
Exception
Method Detail

delete

public void delete()
            throws Exception
Deletes this node with all its data and children

Throws:
Exception

renameTo

public void renameTo(String name)
              throws Exception
Renames this node.

Parameters:
name - the new file name
Throws:
Exception

setLastModified

public void setLastModified(Date time)
                     throws Exception
Sets last modification time of this file to a custom value.

Parameters:
time - the time to be stored as last modification time
Throws:
Exception

setLabel

public void setLabel(String lang,
                     String label)
              throws Exception
Sets a label for this node

Parameters:
lang - the xml:lang language ID
label - the label in this language
Throws:
Exception

clearLabels

public void clearLabels()
                 throws Exception
Removes all labels set

Throws:
Exception

getLabels

public Map<String,String> getLabels()
Returns a map of all labels, sorted by xml:lang, Key is xml:lang, value is the label for that language.


getLabel

public String getLabel(String lang)
Returns the label in the given language

Parameters:
lang - the xml:lang language ID
Returns:
the label, or null if there is no label for that language

getCurrentLabel

public String getCurrentLabel()
Returns the label in the current language, otherwise in default language, otherwise the first label defined, if any at all.

Returns:
the label

repairMetadata

abstract void repairMetadata()
                      throws Exception
Repairs additional metadata of this node

Throws:
Exception