org.olat.commons.modules.bc.meta
Class MetaInfoFileImpl

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.olat.commons.modules.bc.meta.MetaInfoFileImpl
All Implemented Interfaces:
MetaInfo, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class MetaInfoFileImpl
extends org.xml.sax.helpers.DefaultHandler
implements MetaInfo

Initial Date: 08.07.2003

Author:
Mike Stock
Comment: Meta files are in a shadow filesystem with the same directory structure as their original files. Meta info for directories is stored in a file called ".xml" residing in the respective directory. Meta info for files is stored in a file with ".xml" appended to its filename.

Constructor Summary
MetaInfoFileImpl()
           
MetaInfoFileImpl(java.io.File metaFile)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void copyValues(MetaInfo fromMeta)
          Copy values from froMeta into this object except name.
 MetaInfo createMetaInfoFor(OlatRelPathImpl olatRelPathImpl)
          Lazy initialization: A meta file is created based on file data if no meta file can be found for the given path.
 boolean delete()
          Delete this meta info
 void deleteAll()
          Delete all associated meta info including sub files/directories
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 java.lang.String getAuthor()
           
 Identity getAuthorIdentity()
          Returns the identity of the initial author (the same identity is used in MetaInfo.getAuthor().
 java.lang.String getCity()
           
 java.lang.String getComment()
          Corresponds to DublinCore:description
 java.lang.String getCreator()
          In this context, the creator is the person or organization that is primarily responsible for making the content.
 int getDownloadCount()
           
 java.lang.String getFormattedSize()
           
 java.lang.String getHTMLFormattedAuthor()
           
 java.lang.String getIconCssClass()
           
 java.lang.String getLanguage()
          DublinCore compatible
 long getLastModified()
           
 java.lang.Long getLockedBy()
           
 Identity getLockedByIdentity()
           
 java.util.Date getLockedDate()
           
 java.lang.String getName()
           
 java.lang.String getPages()
           
 java.lang.String[] getPublicationDate()
          Corresponds to DublinCore:date + refinement
 java.lang.String getPublisher()
          DublinCore compatible
 long getSize()
           
 java.lang.String getSource()
          DublinCore compatible
 java.lang.String getTitle()
          DublinCore compatible
 java.lang.String getUrl()
           
 void increaseDownloadCount()
          Increases the download count by one.
 boolean isDirectory()
           
 boolean isLocked()
           
 void moveCopyToDir(OlatRelPathImpl target, boolean move)
          Move/Copy the given meta info to the target directory.
 boolean parseXMLdom(java.io.File fMeta)
          Deprecated. 
 void rename(java.lang.String newName)
          Rename the given meta info file
 void setAuthor(java.lang.String username)
           
 void setAuthorIdentKey(java.lang.Long authorIdentKey)
           
 void setCity(java.lang.String city)
           
 void setComment(java.lang.String string)
           
 void setCreator(java.lang.String creator)
           
 void setLanguage(java.lang.String language)
           
 void setLocked(boolean locked)
           
 void setLockedBy(java.lang.Long lockedBy)
           
 void setLockedDate(java.util.Date lockedDate)
           
 void setPages(java.lang.String pages)
           
 void setPublicationDate(java.lang.String month, java.lang.String year)
           
 void setPublisher(java.lang.String publisher)
           
 void setSource(java.lang.String source)
           
 void setTitle(java.lang.String title)
           
 void setUrl(java.lang.String url)
           
 void setWriter(java.lang.String writer)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 java.lang.String toString()
           
 boolean write()
          Writes the meta data to file.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaInfoFileImpl

public MetaInfoFileImpl()

MetaInfoFileImpl

public MetaInfoFileImpl(java.io.File metaFile)
Method Detail

createMetaInfoFor

public MetaInfo createMetaInfoFor(OlatRelPathImpl olatRelPathImpl)
Lazy initialization: A meta file is created based on file data if no meta file can be found for the given path. IMPORTANT: MetaInfa.getInstance can only create an instance, if the referred bcPath exists. It needs this bcPath to determine wether it is looking for a file or a folder meta info object.

Specified by:
createMetaInfoFor in interface MetaInfo
Parameters:
bcPath -
Returns:
MetaInfo instance or null if no instance could be created.

rename

public void rename(java.lang.String newName)
Rename the given meta info file

Specified by:
rename in interface MetaInfo
Parameters:
meta -
newName -

moveCopyToDir

public void moveCopyToDir(OlatRelPathImpl target,
                          boolean move)
Move/Copy the given meta info to the target directory.

Specified by:
moveCopyToDir in interface MetaInfo
Parameters:
targetDir -
move -

deleteAll

public void deleteAll()
Delete all associated meta info including sub files/directories

Specified by:
deleteAll in interface MetaInfo
Parameters:
meta -

copyValues

public void copyValues(MetaInfo fromMeta)
Copy values from froMeta into this object except name.

Specified by:
copyValues in interface MetaInfo
Parameters:
fromMeta -

isLocked

public boolean isLocked()
Specified by:
isLocked in interface MetaInfo
Returns:
if the file is locked

setLocked

public void setLocked(boolean locked)
Specified by:
setLocked in interface MetaInfo

getLockedByIdentity

public Identity getLockedByIdentity()
Specified by:
getLockedByIdentity in interface MetaInfo
Returns:
Identity of the user who locked the file

getLockedBy

public java.lang.Long getLockedBy()
Specified by:
getLockedBy in interface MetaInfo
Returns:
key of the user's identity who locked the file

setLockedBy

public void setLockedBy(java.lang.Long lockedBy)
Specified by:
setLockedBy in interface MetaInfo

getLockedDate

public java.util.Date getLockedDate()
Specified by:
getLockedDate in interface MetaInfo
Returns:
date of the lock

setLockedDate

public void setLockedDate(java.util.Date lockedDate)
Specified by:
setLockedDate in interface MetaInfo

write

public boolean write()
Writes the meta data to file. If no changes have been made, does not write anything.

Specified by:
write in interface MetaInfo
Returns:
True upon success.

delete

public boolean delete()
Delete this meta info

Specified by:
delete in interface MetaInfo
Returns:
True upon success.

parseXMLdom

@Deprecated
public boolean parseXMLdom(java.io.File fMeta)
Deprecated. 

Parse XML from file with SAX and fill-in MetaInfo attributes.

Parameters:
fMeta -

getAuthor

public java.lang.String getAuthor()
Specified by:
getAuthor in interface MetaInfo
Returns:
name of the initial author

getAuthorIdentity

public Identity getAuthorIdentity()
Description copied from interface: MetaInfo
Returns the identity of the initial author (the same identity is used in MetaInfo.getAuthor().

Specified by:
getAuthorIdentity in interface MetaInfo
Returns:
The identity of the initial author.
See Also:
MetaInfo.getAuthorIdentity()

getHTMLFormattedAuthor

public java.lang.String getHTMLFormattedAuthor()
Specified by:
getHTMLFormattedAuthor in interface MetaInfo
Returns:
The display name of the user formatted as HTML
See Also:
MetaInfo.getHTMLFormattedAuthor()

getComment

public java.lang.String getComment()
Description copied from interface: MetaInfo
Corresponds to DublinCore:description

Specified by:
getComment in interface MetaInfo
Returns:
comment

getName

public java.lang.String getName()
Specified by:
getName in interface MetaInfo

isDirectory

public boolean isDirectory()
Specified by:
isDirectory in interface MetaInfo
Returns:
True if this is a directory

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface MetaInfo
Returns:
Last modified timestamp

getSize

public long getSize()
Specified by:
getSize in interface MetaInfo
Returns:
size of file

getFormattedSize

public java.lang.String getFormattedSize()
Specified by:
getFormattedSize in interface MetaInfo
Returns:
formatted representation of size of file

setAuthor

public void setAuthor(java.lang.String username)
Specified by:
setAuthor in interface MetaInfo
Parameters:
string -

setComment

public void setComment(java.lang.String string)
Specified by:
setComment in interface MetaInfo
Parameters:
string -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getCity

public java.lang.String getCity()
Specified by:
getCity in interface MetaInfo
Returns:
The city or location of publication
See Also:
MetaInfo.getCity()

getLanguage

public java.lang.String getLanguage()
Description copied from interface: MetaInfo
DublinCore compatible

Specified by:
getLanguage in interface MetaInfo
See Also:
MetaInfo.getLanguage()

getPages

public java.lang.String getPages()
Specified by:
getPages in interface MetaInfo
See Also:
MetaInfo.getPages()

getPublicationDate

public java.lang.String[] getPublicationDate()
Description copied from interface: MetaInfo
Corresponds to DublinCore:date + refinement

Specified by:
getPublicationDate in interface MetaInfo
Returns:
The date in form of a {year, month} array.
See Also:
org.olat.core.commons.modules.bc.meta.MetaInfo#getPublishDate()

getPublisher

public java.lang.String getPublisher()
Description copied from interface: MetaInfo
DublinCore compatible

Specified by:
getPublisher in interface MetaInfo
See Also:
MetaInfo.getPublisher()

getCreator

public java.lang.String getCreator()
Description copied from interface: MetaInfo
In this context, the creator is the person or organization that is primarily responsible for making the content. The author, by contrast, is an OLAT user who uploaded the file.

Specified by:
getCreator in interface MetaInfo
Returns:
The writer of the resource
See Also:
MetaInfo.getCreator()

getSource

public java.lang.String getSource()
Description copied from interface: MetaInfo
DublinCore compatible

Specified by:
getSource in interface MetaInfo
See Also:
MetaInfo.getSource()

getTitle

public java.lang.String getTitle()
Description copied from interface: MetaInfo
DublinCore compatible

Specified by:
getTitle in interface MetaInfo
See Also:
MetaInfo.getTitle()

getUrl

public java.lang.String getUrl()
Specified by:
getUrl in interface MetaInfo
See Also:
MetaInfo.getUrl()

setCity

public void setCity(java.lang.String city)
Specified by:
setCity in interface MetaInfo
See Also:
MetaInfo.setCity(java.lang.String)

setLanguage

public void setLanguage(java.lang.String language)
Specified by:
setLanguage in interface MetaInfo
See Also:
MetaInfo.setLanguage(java.lang.String)

setPages

public void setPages(java.lang.String pages)
Specified by:
setPages in interface MetaInfo
See Also:
MetaInfo.setPages(java.lang.String)

setPublicationDate

public void setPublicationDate(java.lang.String month,
                               java.lang.String year)
Specified by:
setPublicationDate in interface MetaInfo
See Also:
org.olat.core.commons.modules.bc.meta.MetaInfo#setPublishDate(java.lang.String)

setPublisher

public void setPublisher(java.lang.String publisher)
Specified by:
setPublisher in interface MetaInfo
See Also:
MetaInfo.setPublisher(java.lang.String)

setWriter

public void setWriter(java.lang.String writer)
See Also:
org.olat.core.commons.modules.bc.meta.MetaInfo#setWriter(java.lang.String)

setCreator

public void setCreator(java.lang.String creator)
Specified by:
setCreator in interface MetaInfo
See Also:
org.olat.core.commons.modules.bc.meta.MetaInfo#setWriter(java.lang.String)

setSource

public void setSource(java.lang.String source)
Specified by:
setSource in interface MetaInfo
See Also:
MetaInfo.setSource(java.lang.String)

setTitle

public void setTitle(java.lang.String title)
Specified by:
setTitle in interface MetaInfo
See Also:
MetaInfo.setTitle(java.lang.String)

setUrl

public void setUrl(java.lang.String url)
Specified by:
setUrl in interface MetaInfo
See Also:
MetaInfo.setUrl(java.lang.String)

increaseDownloadCount

public void increaseDownloadCount()
Description copied from interface: MetaInfo
Increases the download count by one.

Specified by:
increaseDownloadCount in interface MetaInfo
See Also:
MetaInfo.increaseDownloadCount()

getDownloadCount

public int getDownloadCount()
Specified by:
getDownloadCount in interface MetaInfo
Returns:
The download count
See Also:
MetaInfo.getDownloadCount()

setAuthorIdentKey

public void setAuthorIdentKey(java.lang.Long authorIdentKey)

startElement

public final void startElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName,
                               org.xml.sax.Attributes attributes)
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

characters

public final void characters(char[] ch,
                             int start,
                             int length)
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

endElement

public final void endElement(java.lang.String uri,
                             java.lang.String localName,
                             java.lang.String qName)
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

getIconCssClass

public java.lang.String getIconCssClass()
Specified by:
getIconCssClass in interface MetaInfo
Returns:
An icon css class that represents this type of file
See Also:
MetaInfo.getIconCssClass()