openlsd.network.server.legacy.LSDDocument Class Reference

Inheritance diagram for openlsd.network.server.legacy.LSDDocument:

Inheritance graph
[legend]
Collaboration diagram for openlsd.network.server.legacy.LSDDocument:

Collaboration graph
[legend]

List of all members.


Detailed Description

LSDDocument is the class for Document part. It handles the access (read, write, move, delete, exist, ...) for the real file, according to the LSDDbLegacy, crypted or not.

Author:
Frederic Bregier LGPL

Public Member Functions

 LSDDocument (LSDStorage storage, long did)
String getFileGlobalPath ()
String getFileAbstractName ()
String getFileBasePath ()
void clear ()
boolean isFile ()
long getFileLength ()
void setLoopIdUnique (LSDStorage storage, long did)
boolean isInWritingProcess ()
boolean write (byte[] bytes)
boolean writeBlock (byte[] bytes)
boolean writeBlockEnd (byte[] bytes)
long write (FileChannel fileChannelIn)
long write (InputStream inputStream)
boolean writeCrypto (byte[] bytes)
boolean writeBlockCrypto (byte[] bytes)
boolean writeBlockCryptoEnd (byte[] bytes)
long writeCrypto (FileChannel fileChannelIn)
long writeCrypto (InputStream inputStream)
byte[] get ()
byte[] getBlock (int sizeblock)
boolean get (FileChannel fileChannelOut)
byte[] getCrypto ()
byte[] getBlockCrypto (int sizeblock)
boolean getCrypto (FileChannel fileChannelOut)
boolean delete ()
LSDDocument move (long sidSto, long didFile)
boolean move (LSDDocument docnew)
String computeMD5 ()
boolean isInternalMD5Equal (String shash)
boolean isMD5equal (String shash)
boolean setLSDPath (long id)
String getGlobalPath ()
String getAbstractName ()
String getGlobalPathWoBasename ()
String getBaseName ()

Public Attributes

long idUnique = LSDConstants.invalide_idx

Private Member Functions

CipherInputStream getCipherInputStream ()
CipherOutputStream getCipherOutputStream ()
FileChannel getFileChannel (boolean isOut)
boolean updateLastTime ()

Private Attributes

boolean isReady = false
LSDStorage storage = null
File realFile = null
String realPath = null
FileChannel bfileChannelOut = null
FileChannel bfileChannelIn = null
CipherOutputStream bcipherOut = null
CipherInputStream bcipherIn = null
ByteBuffer bbyteBuffer = null

Constructor & Destructor Documentation

openlsd.network.server.legacy.LSDDocument.LSDDocument ( LSDStorage  storage,
long  did 
)

Create a new LSDDocument according to the storage and its did (unique id for the document).

The LSDDocument is marked as Ready.

Parameters:
storage associated Storage
did Document Id


Member Function Documentation

String openlsd.network.server.legacy.LSDDocument.getFileGlobalPath (  ) 

To get FileGlobalPath (/basePath/a/b/c)

Returns:
FileGlobalPath (/basePath/a/b/c)

String openlsd.network.server.legacy.LSDDocument.getFileAbstractName (  ) 

To get FileAbstractName (/outPath/_a_b_c)

Returns:
FileAbstractName (/outPath/_a_b_c)

String openlsd.network.server.legacy.LSDDocument.getFileBasePath (  ) 

To get FileBasePath (/basePath/a/b without c)

Returns:
FileBasePath (/basePath/a/b without c)

void openlsd.network.server.legacy.LSDDocument.clear (  ) 

Set empty this LSDDocument, mark it unReady

Reimplemented from openlsd.network.server.legacy.LSDPath.

boolean openlsd.network.server.legacy.LSDDocument.isFile (  ) 

Returns true if the file exists physically. If the document is unReady (isReady false), returns false.

Returns:
if the file exists or not

long openlsd.network.server.legacy.LSDDocument.getFileLength (  ) 

Returns the file length. Warning: this length can be different than the real document size, since the crypto algorithm increase a little the file size compared to the original file size.

Returns:
returns the length of the file, (-1) if does not exist.

void openlsd.network.server.legacy.LSDDocument.setLoopIdUnique ( LSDStorage  storage,
long  did 
)

Set the did for the current Document: to use with really care.

The main goal is for quick loop index.

Parameters:
storage associated Storage
did Document Id

boolean openlsd.network.server.legacy.LSDDocument.isInWritingProcess (  ) 

Returns the status of this Document if it is in current writing status (one block at least is written).

Returns:
the status of the file beeing in writing process or not

boolean openlsd.network.server.legacy.LSDDocument.write ( byte[]  bytes  ) 

Write in the associated Legacy/Storage the Document with the given byte array, limitating the file size to 2^32 bytes.

The mode is non crypted.

Parameters:
bytes for the file
Returns:
True if the insertion is OK, False else

boolean openlsd.network.server.legacy.LSDDocument.writeBlock ( byte[]  bytes  ) 

Write in the associated Legacy/Storage the Document with the given byte array. The file is not limited to 2^32 bytes since this write operation is in add mode.

The mode is non crypted.

Parameters:
bytes added to the file
Returns:
True if the insertion is OK, False else

boolean openlsd.network.server.legacy.LSDDocument.writeBlockEnd ( byte[]  bytes  ) 

End the Write in the associated Legacy/Storage the Document with the given byte array. The file is not limited to 2^32 bytes since this write operation is in add mode.

The mode is non crypted.

Parameters:
bytes added to the file
Returns:
True if the insertion is OK, False else

long openlsd.network.server.legacy.LSDDocument.write ( FileChannel  fileChannelIn  ) 

Write in the associated Legacy/Storage the Document with the given fileChannelIn. The file is not limited to 2^32 bytes since it depends on the FileChannel itself.

The mode is non crypted.

This call closes the fileChannelIn with fileChannelIn.close() if the operation is in success.

Parameters:
fileChannelIn source of the file
Returns:
The size of insertion if is OK, else (-1)

long openlsd.network.server.legacy.LSDDocument.write ( InputStream  inputStream  ) 

Write in the associated Legacy/Storage the Document with the given inputStream. The file is not limited to 2^32 bytes since it depends on the inputStream itself.

The mode is non crypted.

This call closes the inputStream with inputStream.close() if the operation is in success.

Parameters:
inputStream for the file
Returns:
The size of insertion if is OK, else (-1)

boolean openlsd.network.server.legacy.LSDDocument.writeCrypto ( byte[]  bytes  ) 

Write in the associated Legacy/Storage the Document with the given byte array, limitating the file size to 2^32 bytes.

The mode is crypted.

Parameters:
bytes for the file
Returns:
True if the insertion is OK, False else

boolean openlsd.network.server.legacy.LSDDocument.writeBlockCrypto ( byte[]  bytes  ) 

Write in the associated Legacy/Storage the Document with the given byte array. The file is not limited to 2^32 bytes since this write operation is in add mode.

The mode is crypted.

Parameters:
bytes added to the file
Returns:
True if the insertion is OK, False else

boolean openlsd.network.server.legacy.LSDDocument.writeBlockCryptoEnd ( byte[]  bytes  ) 

End the Write in the associated Legacy/Storage the Document with the given byte array. The file is not limited to 2^32 bytes since this write operation is in add mode.

The mode is crypted.

Parameters:
bytes added to the file
Returns:
True if the insertion is OK, False else

long openlsd.network.server.legacy.LSDDocument.writeCrypto ( FileChannel  fileChannelIn  ) 

Write in the associated Legacy/Storage the Document with the given fileChannelIn. The file is not limited to 2^32 bytes since it depends on the FileChannel itself.

The mode is crypted.

This call closes the fileChannelIn with fileChannelIn.close() if the operation is in success.

Parameters:
fileChannelIn source of the file
Returns:
The size of insertion if is OK, else (-1)

long openlsd.network.server.legacy.LSDDocument.writeCrypto ( InputStream  inputStream  ) 

Write in the associated Legacy/Storage the Document with the given inputStream. The file is not limited to 2^32 bytes since it depends on the inputStream itself.

The mode is crypted.

This call closes the inputStream with inputStream.close() if the operation is in success.

Parameters:
inputStream source of the file
Returns:
The size of insertion if is OK, else (-1)

byte [] openlsd.network.server.legacy.LSDDocument.get (  ) 

Get the byte array of the Document stored in the associated Legacy/Storage, limitating the file size to 2^32 bytes.

The mode is non crypted.

Returns:
the resulting array of byte, or null in error.

byte [] openlsd.network.server.legacy.LSDDocument.getBlock ( int  sizeblock  ) 

Get the current block byte array of the Document stored in the associated Legacy/Storage. There is therefore no limitation of the file size to 2^32 bytes.

The returned block is limited to sizeblock. If the returned block is less than sizeblock length, it is the last block to read.

The mode is non crypted.

Parameters:
sizeblock is the limit size for the block array
Returns:
the resulting block array of byte or null in error

boolean openlsd.network.server.legacy.LSDDocument.get ( FileChannel  fileChannelOut  ) 

Write the Document stored in the associated Legacy/Storage to the fileChannelOut, thus bypassing the limitation of the file size to 2^32 bytes.

The mode is non crypted.

This call closes the fileChannelOut with fileChannelOut.close() if the operation is in success.

Parameters:
fileChannelOut 
Returns:
True if OK, False in error.

byte [] openlsd.network.server.legacy.LSDDocument.getCrypto (  ) 

Get the byte array of the Document stored in the associated Legacy/Storage, limitating the file size to 2^32 bytes.

The mode is crypted.

Returns:
the resulting array of byte, or null in error.

byte [] openlsd.network.server.legacy.LSDDocument.getBlockCrypto ( int  sizeblock  ) 

Get the current block byte array of the Document stored in the associated Legacy/Storage. There is therefore no limitation of the file size to 2^32 bytes.

The returned block is limited to sizeblock. If the returned block is less than sizeblock length, it is the last block to read.

The mode is crypted.

Parameters:
sizeblock is the limit size for the block array
Returns:
the resulting block array of byte or null in error

boolean openlsd.network.server.legacy.LSDDocument.getCrypto ( FileChannel  fileChannelOut  ) 

Write the Document stored in the associated Legacy/Storage to the fileChannelOut, thus bypassing the limitation of the file size to 2^32 bytes.

The mode is crypted.

This call closes the fileChannelOut with fileChannelOut.close() if the operation is in success.

Parameters:
fileChannelOut 
Returns:
True if OK, False in error.

boolean openlsd.network.server.legacy.LSDDocument.delete (  ) 

Delete physically the file associated with this Legacy / Storage / Document.

The LSDDocument is not cleared itself.

Returns:
True if OK, else if not (or if the file never exists).

LSDDocument openlsd.network.server.legacy.LSDDocument.move ( long  sidSto,
long  didFile 
)

Move physically the file from one triple LSD to another triple where only the Storage and Document can change.

This version is optimized for moving in the same Legacy.

It returns the new LSDDocument associated or null if error.

Runs both in crypted and non crypted mode.

Parameters:
sidSto Storage Id as destination
didFile Document Id as destination
Returns:
the new LSDDocument if OK, or null if the move failed

boolean openlsd.network.server.legacy.LSDDocument.move ( LSDDocument  docnew  ) 

Move physically the file from one triple LSD to another triple LSD, whatever the changes.

It returns True if the move is ok, False if move failed.

Runs both in crypted and non crypted mode, whatever the source and destination.

Parameters:
docnew New LSDDocument destination
Returns:
True if the move is OK, False else

CipherInputStream openlsd.network.server.legacy.LSDDocument.getCipherInputStream (  )  [private]

Returns a CiptherInputStream for access to the file in Read mode.

Crypted Mode

Returns:
the CipherInputStream or null in error

CipherOutputStream openlsd.network.server.legacy.LSDDocument.getCipherOutputStream (  )  [private]

Returns a CiptherOutputStream for access to the file in Write mode.

Crypted Mode

Returns:
the CipherOutputStream or null in error

FileChannel openlsd.network.server.legacy.LSDDocument.getFileChannel ( boolean  isOut  )  [private]

Returns the FileChannel in Out mode (if isOut is True) or in In mode (if isOut is False) associated with the file of the LSDDocument.

The mode is non crypted.

Parameters:
isOut 
Returns:
the FileChannel (OUT or IN)

boolean openlsd.network.server.legacy.LSDDocument.updateLastTime (  )  [private]

Set the LastTime on the Directories up to the root of the current Legacy

Returns:
True if OK, else False

String openlsd.network.server.legacy.LSDDocument.computeMD5 (  ) 

Compute the MD5 for the Document (Hex version)

Returns:
the MD5 in a byte array or NULL if an error occurs

boolean openlsd.network.server.legacy.LSDDocument.isInternalMD5Equal ( String  shash  ) 

Test if MD5 as parameter is the same as the one from the file (internaly not physical, so not correct when considering crypted file but only considering decrypted file).

Parameters:
shash 
Returns:
True if they are the same, false else.

boolean openlsd.network.server.legacy.LSDDocument.isMD5equal ( String  shash  ) 

Test if MD5 as parameter is the same as the one from the file

Parameters:
shash 
Returns:
True if they are the same, false else.

boolean openlsd.network.server.legacy.LSDPath.setLSDPath ( long  id  )  [inherited]

Create a LSDPath from an id

Parameters:
id 
Returns:
True if the LSDPath is OK, else False

String openlsd.network.server.legacy.LSDPath.getGlobalPath (  )  [inherited]

Get LGlobalPath (/a/b/c)

Returns:
LGlobalPath (/a/b/c)

String openlsd.network.server.legacy.LSDPath.getAbstractName (  )  [inherited]

Get LAbstractName (_a_b_c)

Returns:
LAbstractName (_a_b_c)

String openlsd.network.server.legacy.LSDPath.getGlobalPathWoBasename (  )  [inherited]

Get GlobalPath without Basename (/a/b)

Returns:
GlobalPath without Basename (/a/b)

String openlsd.network.server.legacy.LSDPath.getBaseName (  )  [inherited]

Get BaseName (c)

Returns:
BaseName (c)


Member Data Documentation

Is this Document ready to be accessed

associated Storage

The associated FILE

Full path

FileChannel Out

FileChannel In

CipherOutputStream openlsd.network.server.legacy.LSDDocument.bcipherOut = null [private]

Cipher Out Stream

CipherInputStream openlsd.network.server.legacy.LSDDocument.bcipherIn = null [private]

Cipher In Stream

Associated ByteBuffer

Id between LSDConstants.minimal_idx and maximal_idx


The documentation for this class was generated from the following file: