org.apache.jackrabbit.mk.persistence
Class MongoPersistence

java.lang.Object
  extended by org.apache.jackrabbit.mk.persistence.MongoPersistence
All Implemented Interfaces:
Closeable, BlobStore, Persistence

public class MongoPersistence
extends Object
implements Persistence, Closeable, BlobStore


Nested Class Summary
protected  class MongoPersistence.DBObjectBinding
           
 
Field Summary
protected static String ENCODED_DOLLAR_SIGN
           
protected static String ENCODED_DOT
           
 
Constructor Summary
MongoPersistence()
           
 
Method Summary
 String addBlob(String tempFilePath)
          Write a blob from a temporary file.
 void close()
           
protected static String decodeName(String name)
           
protected static String encodeName(String name)
          see http://www.mongodb.org/display/DOCS/Legal+Key+Names
 long getBlobLength(String blobId)
           
 void initialize()
           
 int readBlob(String blobId, long pos, byte[] buff, int off, int length)
           
 ChildNodeEntriesMap readCNEMap(Id id)
           
 StoredCommit readCommit(Id id)
           
 Id readHead()
           
 void readNode(StoredNode node)
          Read a node from storage.
 String writeBlob(InputStream in)
          Write a blob from an input stream.
 Id writeCNEMap(ChildNodeEntriesMap map)
           
 void writeCommit(Id id, Commit commit)
          Persist a commit, with an id that is selected by the caller.
 void writeHead(Id id)
           
 Id writeNode(Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODED_DOT

protected static final String ENCODED_DOT
See Also:
Constant Field Values

ENCODED_DOLLAR_SIGN

protected static final String ENCODED_DOLLAR_SIGN
See Also:
Constant Field Values
Constructor Detail

MongoPersistence

public MongoPersistence()
Method Detail

initialize

public void initialize()
                throws Exception
Throws:
Exception

close

public void close()
Specified by:
close in interface Closeable
Specified by:
close in interface BlobStore

readHead

public Id readHead()
            throws Exception
Specified by:
readHead in interface Persistence
Throws:
Exception

writeHead

public void writeHead(Id id)
               throws Exception
Specified by:
writeHead in interface Persistence
Throws:
Exception

readNode

public void readNode(StoredNode node)
              throws NotFoundException,
                     Exception
Description copied from interface: Persistence
Read a node from storage.

Specified by:
readNode in interface Persistence
Parameters:
node - node to read, with id given in StoredNode.getId()
Throws:
NotFoundException - if no such node is found
Exception - if some other error occurs

writeNode

public Id writeNode(Node node)
             throws Exception
Specified by:
writeNode in interface Persistence
Throws:
Exception

readCommit

public StoredCommit readCommit(Id id)
                        throws NotFoundException,
                               Exception
Specified by:
readCommit in interface Persistence
Throws:
NotFoundException
Exception

writeCommit

public void writeCommit(Id id,
                        Commit commit)
                 throws Exception
Description copied from interface: Persistence
Persist a commit, with an id that is selected by the caller.

Specified by:
writeCommit in interface Persistence
Parameters:
id - commit id
commit - commit
Throws:
Exception - if an error occurs

readCNEMap

public ChildNodeEntriesMap readCNEMap(Id id)
                               throws NotFoundException,
                                      Exception
Specified by:
readCNEMap in interface Persistence
Throws:
NotFoundException
Exception

writeCNEMap

public Id writeCNEMap(ChildNodeEntriesMap map)
               throws Exception
Specified by:
writeCNEMap in interface Persistence
Throws:
Exception

addBlob

public String addBlob(String tempFilePath)
               throws Exception
Description copied from interface: BlobStore
Write a blob from a temporary file. The temporary file is removed afterwards. A file based blob stores might simply rename the file, so that no additional writes are necessary.

Specified by:
addBlob in interface BlobStore
Parameters:
tempFilePath - the temporary file
Returns:
the blob id
Throws:
Exception

writeBlob

public String writeBlob(InputStream in)
                 throws Exception
Description copied from interface: BlobStore
Write a blob from an input stream. This method closes the input stream.

Specified by:
writeBlob in interface BlobStore
Parameters:
in - the input stream
Returns:
the blob id
Throws:
Exception

readBlob

public int readBlob(String blobId,
                    long pos,
                    byte[] buff,
                    int off,
                    int length)
             throws Exception
Specified by:
readBlob in interface BlobStore
Throws:
Exception

getBlobLength

public long getBlobLength(String blobId)
                   throws Exception
Specified by:
getBlobLength in interface BlobStore
Throws:
Exception

encodeName

protected static String encodeName(String name)
see http://www.mongodb.org/display/DOCS/Legal+Key+Names

Parameters:
name -

decodeName

protected static String decodeName(String name)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.