public class DocumentDB
extends java.lang.Object
implements java.io.Serializable
Document instance
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DOCUMENT_VERSION
Default document version
|
static java.lang.String |
SESSION_DOC_ACCESS |
Constructor and Description |
---|
DocumentDB(java.lang.String docId,
java.lang.String path,
byte[] b,
java.lang.String objName,
java.lang.String fieldName,
java.lang.String rowId)
Simplified constructor (used to retrieve an existing document or create a new document and create or update it)
|
DocumentDB(java.lang.String name,
java.lang.String rpath,
java.lang.String mime,
long size,
int vers)
Simplified constructor
|
DocumentDB(java.lang.String name,
java.lang.String rpath,
java.lang.String mime,
long size,
int vers,
java.lang.String index,
java.lang.String respId,
java.lang.String respLogin,
java.util.Hashtable<java.lang.String,java.lang.String> groups,
java.util.Hashtable<java.lang.String,java.lang.String> fields,
boolean ondemand,
java.lang.String objName,
java.lang.String fldName,
java.lang.String rowId,
java.lang.String lastupd)
Indexed document constructor
|
Modifier and Type | Method and Description |
---|---|
static void |
addAccess(Grant g,
java.lang.String docId)
Add a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
|
static boolean |
checkAccess(Grant g,
java.lang.String docId)
Check a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
|
java.util.Vector<java.lang.String> |
getAccessGroup()
Bookshelf groups
|
java.lang.String |
getBookshelfName()
Bookshelf name
|
byte[] |
getBytes()
Get binary content (current content, not forced to read from file)
|
byte[] |
getBytes(boolean read)
Get binary content
|
java.lang.String |
getContentType()
Get content type (from MIME type)
|
static java.lang.String |
getContentType(java.lang.String path)
Get content type from MIME type for file name
|
static DocumentDB |
getDocument(java.lang.String docId,
Grant grant)
Retrieve document data from ID: dbdoc path, name, size, mime-type, version, etc.
|
static java.lang.String |
getDocumentId(Grant g,
java.lang.String object,
java.lang.String field,
java.lang.String rowId)
Get document ID that matches specified object name, field name and row ID
|
static java.lang.String |
getDocumentId(ObjectDB obj,
java.lang.String field,
java.lang.String rowId)
Get document ID that matches specified object field name and row ID
|
static java.lang.String |
getDocumentIdFromCondition(java.lang.String condition)
Get first document ID that matches specified SQL condition
|
static java.lang.String |
getDocumentIdFromName(java.lang.String name)
Get first document ID that matches specified name
|
static java.lang.String |
getDocumentIdFromPath(java.lang.String path)
Get first document ID that matches specified path
|
java.lang.String |
getExtension()
Get document extension from name or path
|
java.lang.String |
getFieldRef()
Get field name associated to the document
|
java.util.Hashtable<java.lang.String,java.lang.String> |
getFields()
Indexed fields
|
java.io.File |
getFile()
Get the document as a local file
|
boolean |
getGroupGrant(java.lang.String group,
char grt)
Is the group granted ?
|
java.lang.String |
getId()
Get document ID
|
java.io.InputStream |
getInputStream()
Get content as input stream
|
java.lang.String |
getLastUpdated()
Last updated
|
java.lang.String |
getMIME()
Get MIME type
|
static java.lang.String |
getMIME(java.lang.String path)
Get MIME type
|
java.lang.String |
getName()
Get file name
|
java.lang.String |
getObjectRef()
Get object name associated to the document
|
boolean |
getOnDemand()
Request allowed ?
|
java.lang.String |
getPath()
Get path = document unique key in document table
|
java.lang.String |
getRelativePath()
Deprecated.
|
java.lang.String |
getRespId()
Document owner
|
java.lang.String |
getRespLogin()
User login managing the document requests
|
java.lang.String |
getRowIdRef()
Get object record row ID associated to the document
|
long |
getSize()
Get file size (bytes)
|
byte[] |
getThumbnailBytes()
Get thumbnail binary content (only relevant for images with thumbnail)
|
byte[] |
getThumbnailBytes(boolean read)
Get thumbnail binary content (only relevant for images with thumbnail)
|
java.io.File |
getThumbnailFile()
Get thumbnail file with absolute path (only relevant for images with thumbnail)
|
java.io.InputStream |
getThumbnailInputStream()
Get content as input stream
|
java.lang.String |
getThumbnailPath()
Get thumbnail image path (only relevant for images with thumbnail)
|
java.lang.String |
getThumbnailURL(java.lang.String cdisp)
Get thumbnail image URL (only relevant for generic web UI)
|
java.lang.String |
getURL(java.lang.String cdisp)
Get document URL (only relevant for generic web UI)
|
int |
getVersion()
Version (automatically increased when saving)
|
java.lang.String |
inline()
Convert the document to a String (XML usage).
|
static java.lang.String |
inline(DocumentDB d)
Convert a document to a String (XML usage).
|
static java.lang.Object[] |
parse(java.lang.String doc)
Parse a document (from XML import)
|
static byte[] |
read(java.lang.String path)
Read a document content.
|
static void |
removeAccess(Grant g,
java.lang.String docId)
Remove a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
|
static byte[] |
select(java.lang.String docId)
Read a document content from the ID
|
void |
setBytes(byte[] b)
Set binary content
|
void |
setBytes(byte[] b,
boolean append)
Set binary content
|
void |
setFieldRef(java.lang.String field)
Set field name associated to the document
|
void |
setId(java.lang.String id)
Set document ID
|
void |
setMIME(java.lang.String mime)
Set MIME type
|
void |
setName(java.lang.String name)
Set file name
|
void |
setObjectRef(java.lang.String object)
Set object name associated to the document
|
void |
setPath(java.lang.String path)
Set path = document unique key in document table
|
void |
setRowIdRef(java.lang.String rowId)
Set object record row ID associated to the document
|
void |
setSize(long size)
Set file size (bytes)
|
static java.lang.String |
toBase64(java.lang.String docId)
Read a document content into a Base64 encoded String.
|
java.lang.String |
toString() |
static java.lang.String |
toString(java.lang.String docId)
Read a document content into a plain String.
|
static void |
write(java.lang.String path,
byte[] data)
Write a document content.
|
static void |
write(java.lang.String path,
byte[] data,
boolean append)
Write a document content.
|
static void |
write(java.lang.String docId,
Grant grant,
byte[] data)
Write a document content.
|
static void |
write(java.lang.String docId,
Grant grant,
byte[] data,
boolean append)
Write a document content.
|
public static final int DEFAULT_DOCUMENT_VERSION
public static final java.lang.String SESSION_DOC_ACCESS
public DocumentDB(java.lang.String name, java.lang.String rpath, java.lang.String mime, long size, int vers, java.lang.String index, java.lang.String respId, java.lang.String respLogin, java.util.Hashtable<java.lang.String,java.lang.String> groups, java.util.Hashtable<java.lang.String,java.lang.String> fields, boolean ondemand, java.lang.String objName, java.lang.String fldName, java.lang.String rowId, java.lang.String lastupd)
public DocumentDB(java.lang.String name, java.lang.String rpath, java.lang.String mime, long size, int vers)
public DocumentDB(java.lang.String docId, java.lang.String path, byte[] b, java.lang.String objName, java.lang.String fieldName, java.lang.String rowId)
docId
- Document ID or null (or ObjectField.DEFAULT_ROW_ID) for a new documentpath
- File relative path or file name (used to determine MIME type and size)objName
- Object namefieldName
- Object field namerowId
- Object row ID (can be null or ObjectField.DEFAULT_ROW_ID at creation of object)public java.lang.String getId()
public void setId(java.lang.String id)
public java.lang.String getName()
public void setName(java.lang.String name)
@Deprecated public final java.lang.String getRelativePath()
Use getPath instead
public java.lang.String getPath()
public void setPath(java.lang.String path)
public java.lang.String getExtension()
public java.io.File getFile()
public java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
public byte[] getBytes()
public byte[] getBytes(boolean read)
read
- Force read bytes from file ?public void setBytes(byte[] b)
public void setBytes(byte[] b, boolean append)
append
- Append ?public java.lang.String getURL(java.lang.String cdisp)
public java.lang.String getThumbnailPath()
public java.io.File getThumbnailFile()
public byte[] getThumbnailBytes()
public byte[] getThumbnailBytes(boolean read)
read
- Force read bytes from file ?public java.io.InputStream getThumbnailInputStream() throws java.io.IOException
java.io.IOException
public java.lang.String getThumbnailURL(java.lang.String cdisp)
public java.lang.String getMIME()
public void setMIME(java.lang.String mime)
public java.lang.String getContentType()
public static java.lang.String getMIME(java.lang.String path)
public static java.lang.String getContentType(java.lang.String path)
public java.lang.String inline()
public static java.lang.String inline(DocumentDB d)
d
- Documentpublic static java.lang.Object[] parse(java.lang.String doc)
doc
- Documentpublic long getSize()
public void setSize(long size)
public int getVersion()
public java.lang.String getLastUpdated()
public java.lang.String getBookshelfName()
public java.lang.String getRespId()
public java.lang.String getRespLogin()
public boolean getOnDemand()
public java.util.Vector<java.lang.String> getAccessGroup()
public boolean getGroupGrant(java.lang.String group, char grt)
group
- Group namegrt
- Grant type (U)pload (D)ownload (M)Update index (G)Update grant (S)Deletepublic java.util.Hashtable<java.lang.String,java.lang.String> getFields()
public java.lang.String getObjectRef()
public void setObjectRef(java.lang.String object)
public java.lang.String getFieldRef()
public void setFieldRef(java.lang.String field)
public java.lang.String getRowIdRef()
public void setRowIdRef(java.lang.String rowId)
public static java.lang.String getDocumentIdFromCondition(java.lang.String condition)
Get first document ID that matches specified SQL condition
public static java.lang.String getDocumentIdFromPath(java.lang.String path)
Get first document ID that matches specified path
public static java.lang.String getDocumentIdFromName(java.lang.String name)
Get first document ID that matches specified name
public static java.lang.String getDocumentId(Grant g, java.lang.String object, java.lang.String field, java.lang.String rowId)
Get document ID that matches specified object name, field name and row ID
g
- Grantobject
- Object namefield
- Field namerowId
- Row IDpublic static java.lang.String getDocumentId(ObjectDB obj, java.lang.String field, java.lang.String rowId)
Get document ID that matches specified object field name and row ID
obj
- Objectfield
- Field namerowId
- Row IDpublic static void write(java.lang.String docId, Grant grant, byte[] data)
Write a document content.
docId
- Document IDgrant
- User grantdata
- Document contentpublic static void write(java.lang.String docId, Grant grant, byte[] data, boolean append)
Write a document content.
docId
- Document IDgrant
- User grantdata
- Document contentappend
- Append ?public static void write(java.lang.String path, byte[] data)
Write a document content.
path
- Document pathdata
- Document contentpublic static void write(java.lang.String path, byte[] data, boolean append)
Write a document content.
path
- Document pathdata
- Document contentappend
- Append ?public static byte[] select(java.lang.String docId)
Read a document content from the ID
docId
- Document IDpublic static byte[] read(java.lang.String path)
Read a document content.
path
- Document pathpublic static java.lang.String toString(java.lang.String docId)
Read a document content into a plain String.
docId
- Document IDpublic static java.lang.String toBase64(java.lang.String docId)
Read a document content into a Base64 encoded String.
docId
- Document IDpublic static DocumentDB getDocument(java.lang.String docId, Grant grant)
Retrieve document data from ID: dbdoc path, name, size, mime-type, version, etc.
docId
- Document IDgrant
- User grantspublic static void addAccess(Grant g, java.lang.String docId)
Add a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
g
- User rightsdocId
- Document idpublic static void removeAccess(Grant g, java.lang.String docId)
Remove a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
g
- User rightsdocId
- Document idpublic static boolean checkAccess(Grant g, java.lang.String docId)
Check a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
g
- User rightsdocId
- Document idpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright (c)2006-2014 Simplicite Software. All Rights Reserved.