net.sourceforge.sconman.rep
Class FSBasicRepository

java.lang.Object
  extended by net.sourceforge.sconman.rep.FSBasicRepository
All Implemented Interfaces:
IRepository, IXMLSerializable
Direct Known Subclasses:
FSQuotedRepository

public class FSBasicRepository
extends java.lang.Object
implements IRepository

File repository. This repository stores files in directories acording to year/month/day/copy.

Author:
mikeshadow

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sourceforge.sconman.IRepository
IRepository.IVisitor
 
Field Summary
protected  Category category
          Category of the repository
protected  java.lang.String rootPath
          FSBasicRepository root path
 
Fields inherited from interface net.sourceforge.sconman.IRepository
STORE_OK
 
Constructor Summary
FSBasicRepository()
          Default constructor
FSBasicRepository(java.lang.String rootPath)
          Constructor
 
Method Summary
 java.lang.String add(java.lang.String baseDir, java.lang.String filePath)
          Given a filename, return a valid path to store it calling getOutputStream(java.lang.String)
 java.lang.String addNonamed(java.lang.String baseDir, java.lang.String fileExtension)
          Given a file extension, return a valid path to store it calling getOutputStream(java.lang.String)
 void deserializeXML(org.kxml2.io.KXmlParser in)
          Deserialize from XML
 boolean exists(java.lang.String path)
          Checks if 'path' points to a valid entry
 Category getCategory()
          Gets the category of the repository
protected  java.io.File getFile(java.lang.String uri)
          Retrieves a file from the repository
 java.io.InputStream getInputStream(java.lang.String path)
          Returns an input channel to read contents
 java.util.Date getLastModified(java.lang.String path)
          Returns the last lastAccessed time for the pointed entry
 java.io.OutputStream getOutputStream(java.lang.String path)
          Returns an output channel to store contents
 java.lang.String getRootPath()
           
 void initialize()
          Initialize the repository
 void remove(java.lang.String path)
          Removes the stored file, given its path
 void serializeXML(org.kxml2.io.KXmlSerializer out)
          Serialize to XML
 void setCategory(Category category)
          Sets the category to the repository
protected  void setRootPath(java.lang.String rootPath)
           
 long size(java.lang.String path)
          Gets the size of the file
 int store(java.io.InputStream is, java.lang.String path)
          Store an InputStream in the repository
 void visit(java.lang.String relativePath, IRepository.IVisitor visitor)
          Explores the filesystem from relative path to the repository root path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootPath

protected java.lang.String rootPath
FSBasicRepository root path


category

protected Category category
Category of the repository

Constructor Detail

FSBasicRepository

public FSBasicRepository()
Default constructor


FSBasicRepository

public FSBasicRepository(java.lang.String rootPath)
Constructor

Parameters:
rootPath -
Method Detail

getRootPath

public java.lang.String getRootPath()
Returns:

setRootPath

protected void setRootPath(java.lang.String rootPath)
Parameters:
rootPath -

exists

public boolean exists(java.lang.String path)
Description copied from interface: IRepository
Checks if 'path' points to a valid entry

Specified by:
exists in interface IRepository
Parameters:
path - The path to check
Returns:
True if 'path' points to a valid entry

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String path)
                                     throws java.io.IOException
Returns an output channel to store contents

Specified by:
getOutputStream in interface IRepository
Parameters:
path - The path to the file
Returns:
The output stream to store data
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream(java.lang.String path)
                                   throws java.io.IOException
Returns an input channel to read contents

Specified by:
getInputStream in interface IRepository
Parameters:
path - The path to the file
Returns:
The input stream to read data from
Throws:
java.io.IOException

remove

public void remove(java.lang.String path)
            throws java.io.IOException
Removes the stored file, given its path

Specified by:
remove in interface IRepository
Parameters:
path -
Throws:
java.io.IOException

add

public java.lang.String add(java.lang.String baseDir,
                            java.lang.String filePath)
                     throws java.io.IOException
Given a filename, return a valid path to store it calling getOutputStream(java.lang.String)

Specified by:
add in interface IRepository
Parameters:
filePath - The file id
Returns:
The path pointing to a valid storage entry within the repository
Throws:
java.io.IOException

addNonamed

public java.lang.String addNonamed(java.lang.String baseDir,
                                   java.lang.String fileExtension)
                            throws java.io.IOException
Given a file extension, return a valid path to store it calling getOutputStream(java.lang.String)

Specified by:
addNonamed in interface IRepository
Parameters:
fileExtension - The file extension
Returns:
The path pointing to a valid storage entry within the repository
Throws:
java.io.IOException

getFile

protected java.io.File getFile(java.lang.String uri)
Retrieves a file from the repository

Parameters:
uri - Path relative to the root
Returns:
The requested File

visit

public void visit(java.lang.String relativePath,
                  IRepository.IVisitor visitor)
Explores the filesystem from relative path to the repository root path

Specified by:
visit in interface IRepository
Parameters:
relativePath - The root path where the visits should begin at
visitor - The visitor that will traverse the repository

getLastModified

public java.util.Date getLastModified(java.lang.String path)
Description copied from interface: IRepository
Returns the last lastAccessed time for the pointed entry

Specified by:
getLastModified in interface IRepository
Parameters:
path - The path to the entry
Returns:
Java time as long

store

public int store(java.io.InputStream is,
                 java.lang.String path)
          throws java.io.IOException
Description copied from interface: IRepository
Store an InputStream in the repository

Specified by:
store in interface IRepository
Parameters:
is - The InputStream
path - The path to the file
Returns:
Error code
Throws:
java.io.IOException

initialize

public void initialize()
                throws java.io.IOException
Description copied from interface: IRepository
Initialize the repository

Specified by:
initialize in interface IRepository
Throws:
java.io.IOException

size

public long size(java.lang.String path)
Description copied from interface: IRepository
Gets the size of the file

Specified by:
size in interface IRepository
Parameters:
path - The path to the file
Returns:
The size of the file

serializeXML

public void serializeXML(org.kxml2.io.KXmlSerializer out)
                  throws java.io.IOException
Description copied from interface: IXMLSerializable
Serialize to XML

Specified by:
serializeXML in interface IXMLSerializable
Parameters:
out - The KXmlSerializer to do the output
Throws:
java.io.IOException - Thrown if there's an IO problem

deserializeXML

public void deserializeXML(org.kxml2.io.KXmlParser in)
                    throws org.xmlpull.v1.XmlPullParserException,
                           java.io.IOException
Description copied from interface: IXMLSerializable
Deserialize from XML

Specified by:
deserializeXML in interface IXMLSerializable
Parameters:
in - The KXml pull parser
Throws:
org.xmlpull.v1.XmlPullParserException - Thrown if there's an XML problem
java.io.IOException - Thrown if there's an IO problem

setCategory

public void setCategory(Category category)
Description copied from interface: IRepository
Sets the category to the repository

Specified by:
setCategory in interface IRepository
Parameters:
category - The category

getCategory

public Category getCategory()
Description copied from interface: IRepository
Gets the category of the repository

Specified by:
getCategory in interface IRepository
Returns:
The category


Copyright null null. All Rights Reserved.