org.mycore.datamodel.ifs2
Class MCRFile

java.lang.Object
  extended by org.mycore.datamodel.ifs2.MCRNode
      extended by org.mycore.datamodel.ifs2.MCRStoredNode
          extended by org.mycore.datamodel.ifs2.MCRFile

public class MCRFile
extends MCRStoredNode

Represents a file stored in a file collection. This is a file that is imported from outside the system, and may be updated and modified afterwards.

Author:
Frank Lützenkirchen

Field Summary
static String MD5_OF_EMPTY_FILE
          The md5 checksum of the empty file
 
Fields inherited from class org.mycore.datamodel.ifs2.MCRStoredNode
data
 
Fields inherited from class org.mycore.datamodel.ifs2.MCRNode
fo, parent
 
Constructor Summary
protected MCRFile(MCRDirectory parent, org.apache.commons.vfs.FileObject fo, Element data)
          Returns a MCRFile object representing an existing file already stored in the store.
protected MCRFile(MCRDirectory parent, String name)
          Creates a new MCRFile that does not exist yet
 
Method Summary
protected  MCRVirtualNode buildChildNode(org.apache.commons.vfs.FileObject fo)
          Returns a MCRVirtualNode contained in this file as a child.
 String getExtension()
          Returns the file name extension, which is the part after the last dot in the filename.
 File getLocalFile()
          Returns the local java.io.File representing this stored file.
 String getMD5()
          Returns the md5 checksum of the file's content.
(package private)  void repairMetadata()
          Repairs additional metadata of this file and all its children
 String setContent(MCRContent source)
          Sets the content of this file.
 
Methods inherited from class org.mycore.datamodel.ifs2.MCRStoredNode
clearLabels, delete, getCurrentLabel, getLabel, getLabels, renameTo, setLabel, setLastModified
 
Methods inherited from class org.mycore.datamodel.ifs2.MCRNode
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

MD5_OF_EMPTY_FILE

public static final String MD5_OF_EMPTY_FILE
The md5 checksum of the empty file

See Also:
Constant Field Values
Constructor Detail

MCRFile

protected MCRFile(MCRDirectory parent,
                  org.apache.commons.vfs.FileObject fo,
                  Element data)
           throws Exception
Returns a MCRFile object representing an existing file already stored in the store.

Parameters:
parent - the parent directory containing this file
fo - the file in the local underlying filesystem storing this file
Throws:
Exception

MCRFile

protected MCRFile(MCRDirectory parent,
                  String name)
           throws Exception
Creates a new MCRFile that does not exist yet

Parameters:
parent - the parent directory
name - the file name
Throws:
Exception
Method Detail

buildChildNode

protected MCRVirtualNode buildChildNode(org.apache.commons.vfs.FileObject fo)
                                 throws Exception
Returns a MCRVirtualNode contained in this file as a child. A file that is a container, like zip or tar, may contain other files as children.

Specified by:
buildChildNode in class MCRNode
Parameters:
fo - the FileObject representing the child in the underlying filesystem
Returns:
the child node
Throws:
Exception

getMD5

public String getMD5()
Returns the md5 checksum of the file's content.

Returns:
the md5 checksum of the file's content.

getExtension

public String getExtension()
Returns the file name extension, which is the part after the last dot in the filename.

Returns:
the file extension, or the empty string if the file name does not have an extension

setContent

public String setContent(MCRContent source)
                  throws Exception
Sets the content of this file.

Parameters:
content - the content to be read
Returns:
the MD5 checksum of the stored content
Throws:
Exception

getLocalFile

public File getLocalFile()
                  throws Exception
Returns the local java.io.File representing this stored file. Be careful to use this only for reading data, do never modify directly!

Returns:
the file in the local filesystem representing this file
Throws:
Exception

repairMetadata

void repairMetadata()
              throws Exception
Repairs additional metadata of this file and all its children

Specified by:
repairMetadata in class MCRStoredNode
Throws:
Exception