Class DocumentDB

  • All Implemented Interfaces:
    java.io.Serializable

    public class DocumentDB
    extends java.lang.Object
    implements java.io.Serializable

    Document instance

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DocumentDB.DocData
      Document data
    • Constructor Summary

      Constructors 
      Constructor Description
      DocumentDB​(boolean multi)
      Empty constructor
      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 docId, java.lang.String path, java.io.File tmpFile, java.lang.String objName, java.lang.String fieldName, java.lang.String rowId)
      Simplified constructor (used to create a new document)
      DocumentDB​(java.lang.String docId, java.lang.String path, java.io.InputStream stream, java.lang.String objName, java.lang.String fieldName, java.lang.String rowId)
      Simplified constructor (used to create a new document)
      DocumentDB​(java.lang.String name, java.lang.String rpath, java.lang.String mime, long size, int vers)
      Simplified single document 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.Map<java.lang.String,​java.lang.String> groups, java.util.Map<java.lang.String,​java.lang.String> fields, java.lang.String objName, java.lang.String fldName, java.lang.String rowId, java.lang.String lastupd)
      Single document constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(DocumentDB doc)
      Add a document to multi-docs list
      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_)
      DocumentDB copyDocuments​(java.lang.String targetObject, java.lang.String targetField, java.lang.String targetRowId)
      Clone the multi-documents
      void copyTo​(java.lang.String path)
      Copy document to specified path
      static void copyToRecycleBin​(DocumentDB doc)
      Copy to recycle bin
      static boolean exists​(java.lang.String docId)
      Checks document existence
      java.util.List<java.lang.String> getAccessGroups()
      Get bookshelf groups
      java.lang.String getBookshelfName()
      Get 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
      java.lang.String getDataURL​(boolean thumbnail)
      Get data URL
      DocumentDB.DocData getDocData()
      Get all data
      DocumentDB getDocument​(java.lang.String docId)
      Get a document from multi-docs list
      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.util.List<DocumentDB> getDocuments()
      Get all documents of multi-docs list
      static DocumentDB getDocuments​(ObjectCore obj, ObjectField field, java.lang.String rowId)
      Retrieve documents data from ID: dbdoc path, name, size, mime-type, version, etc.
      java.lang.String getError()
      Get error
      java.lang.String getExtension()
      Get document extension from name or path
      java.lang.String getFieldRef()
      Get field name associated to the document
      java.util.Map<java.lang.String,​java.lang.String> getFields()
      Get indexed fields
      java.io.File getFile()
      Get the document as a local file
      java.lang.String getId()
      Get document ID
      java.io.InputStream getInputStream()
      Get content as input stream
      java.lang.String getLastUpdated()
      Get last updated date time
      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
      java.lang.String getPath()
      Get path (= document unique key in document table)
      java.lang.String getRespId()
      Get document owner
      java.lang.String getRespLogin()
      get 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)
      java.lang.String getTextTypeFromExtension()
      Get editor/preview type from extension
      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 thumbnail content as input stream (only relevant for images with thumbnail)
      java.lang.String getThumbnailPath()
      Get thumbnail image path (only relevant for images with thumbnail)
      java.lang.String getThumbnailURL​(java.lang.String cdisp)
      Get image document thumbnail URL (only relevant for images with thumbnail)
      java.io.File getUploadFile()
      Get temporary file to upload file without bytes in memory
      java.io.InputStream getUploadStream()
      Get input stream to upload file without bytes in memory
      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 inlined document string (XML usage).
      boolean isBinary()
      Is a binary file?
      static boolean isBinary​(java.lang.String mime)
      Is a binary MIME type file?
      boolean isEmpty()
      Is document file empty ?
      boolean isGroupGranted​(java.lang.String group, char grt)
      Is the group granted ?
      boolean isImage()
      Is an image?
      static boolean isImage​(java.lang.String mime)
      Is an image?
      boolean isText()
      Is a text file?
      static boolean isText​(java.lang.String mime)
      Is a text MIME type file?
      boolean isZIP()
      Is a ZIP file?
      static boolean isZIP​(java.lang.String mime)
      Is a ZIP file?
      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
      void remove​(java.lang.String docId)
      Remove a document from multi-docs list
      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
      ZZZ will use lot of memory, try to use setTmpStream ZZZ
      void setBytes​(byte[] b, boolean append)
      Set binary content
      ZZZ will use lot of memory, try to use setTmpStream ZZZ
      void setDocData​(DocumentDB.DocData data)
      Set all data
      void setError​(java.lang.String error)
      Set error
      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)
      void setStatus​(char status)
      1=to upload / 2=to delete on save
      void setUploadFile​(java.io.File file)
      Set temporary file to upload file without bytes in memory
      void setUploadStream​(java.io.InputStream in)
      Set input stream to upload file without bytes in memory
      static java.lang.String toBase64​(java.lang.String docId)
      Read a document content into a Base64 encoded String
      boolean toDelete()
      To delete on save?
      org.json.JSONArray toJSONArray()
      Generates a JSON object representation of the multi-documents.
      org.json.JSONObject toJSONObject()
      Generates a JSON object representation of the single document.
      java.lang.String toString()
      Generates a string representation of the doucment(s)
      static java.lang.String toString​(java.lang.String docId)
      Read a document content into a plain String.
      boolean toUpload()
      To upload on save?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_DOCUMENT_VERSION

        public static final int DEFAULT_DOCUMENT_VERSION
        Default document version
        See Also:
        Constant Field Values
      • STATUS_UNCHANGED

        public static final char STATUS_UNCHANGED
        Unchanged status
        See Also:
        Constant Field Values
      • STATUS_TO_UPLOAD

        public static final char STATUS_TO_UPLOAD
        To upload status
        See Also:
        Constant Field Values
      • STATUS_TO_DELETE

        public static final char STATUS_TO_DELETE
        To delete status
        See Also:
        Constant Field Values
      • SESSION_DOC_ACCESS

        public static final java.lang.String SESSION_DOC_ACCESS
        Session doc access
        See Also:
        Constant Field Values
    • Constructor Detail

      • DocumentDB

        public DocumentDB​(boolean multi)
        Empty constructor
        Parameters:
        multi - is multi documents?
      • DocumentDB

        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.Map<java.lang.String,​java.lang.String> groups,
                          java.util.Map<java.lang.String,​java.lang.String> fields,
                          java.lang.String objName,
                          java.lang.String fldName,
                          java.lang.String rowId,
                          java.lang.String lastupd)
        Single document constructor
        Parameters:
        name - Name
        rpath - Relative Path
        mime - Mime Type
        size - Size
        vers - Version
        index - Index
        respId - respId
        respLogin - respLogin
        groups - Groups
        fields - Meta fields
        objName - Object Name
        fldName - Field Name
        rowId - Row Id
        lastupd - Last Update
      • DocumentDB

        public DocumentDB​(java.lang.String name,
                          java.lang.String rpath,
                          java.lang.String mime,
                          long size,
                          int vers)
        Simplified single document constructor
        Parameters:
        name - Name
        rpath - Relative path
        mime - Mime Type
        size - Size
        vers - Version
      • DocumentDB

        public 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)
        Parameters:
        docId - Document ID or null (or ObjectField.DEFAULT_ROW_ID) for a new document
        path - File relative path or file name (used to determine MIME type and size)
        b - Bytes
        objName - Object name
        fieldName - Object field name
        rowId - Object row ID (can be null or ObjectField.DEFAULT_ROW_ID at creation of object)
      • DocumentDB

        public DocumentDB​(java.lang.String docId,
                          java.lang.String path,
                          java.io.File tmpFile,
                          java.lang.String objName,
                          java.lang.String fieldName,
                          java.lang.String rowId)
        Simplified constructor (used to create a new document)
        Parameters:
        docId - Document ID or null (or ObjectField.DEFAULT_ROW_ID) for a new document
        path - File relative path or file name
        tmpFile - Temporary source file
        objName - Object name
        fieldName - Object field name
        rowId - Object row ID (can be null or ObjectField.DEFAULT_ROW_ID at creation of object)
      • DocumentDB

        public DocumentDB​(java.lang.String docId,
                          java.lang.String path,
                          java.io.InputStream stream,
                          java.lang.String objName,
                          java.lang.String fieldName,
                          java.lang.String rowId)
        Simplified constructor (used to create a new document)
        Parameters:
        docId - Document ID or null (or ObjectField.DEFAULT_ROW_ID) for a new document
        path - File relative path or file name
        stream - source stream
        objName - Object name
        fieldName - Object field name
        rowId - Object row ID (can be null or ObjectField.DEFAULT_ROW_ID at creation of object)
    • Method Detail

      • setDocData

        public void setDocData​(DocumentDB.DocData data)
        Set all data
        Parameters:
        data - Data
      • add

        public void add​(DocumentDB doc)
        Add a document to multi-docs list
        Parameters:
        doc - document
      • getDocuments

        public java.util.List<DocumentDB> getDocuments()
        Get all documents of multi-docs list
        Returns:
        List of documents
      • getDocument

        public DocumentDB getDocument​(java.lang.String docId)
        Get a document from multi-docs list
        Parameters:
        docId - document ID
      • remove

        public void remove​(java.lang.String docId)
        Remove a document from multi-docs list
        Parameters:
        docId - document ID
      • getId

        public java.lang.String getId()
        Get document ID
        Returns:
        document Id
      • setId

        public void setId​(java.lang.String id)
        Set document ID
        Parameters:
        id - document Id
      • getName

        public java.lang.String getName()
        Get file name
        Returns:
        file name
      • setName

        public void setName​(java.lang.String name)
        Set file name
        Parameters:
        name - file name
      • getPath

        public java.lang.String getPath()
        Get path (= document unique key in document table)
        Returns:
        Path
      • setPath

        public void setPath​(java.lang.String path)
        Set path (= document unique key in document table)
        Parameters:
        path - Path
      • getError

        public java.lang.String getError()
        Get error
        Returns:
        Error
      • setError

        public void setError​(java.lang.String error)
        Set error
        Parameters:
        error - Error
      • toDelete

        public boolean toDelete()
        To delete on save?
        Returns:
        flag
      • toUpload

        public boolean toUpload()
        To upload on save?
        Returns:
        flag
      • setStatus

        public void setStatus​(char status)
        1=to upload / 2=to delete on save
        Parameters:
        status - integer
      • getExtension

        public java.lang.String getExtension()
        Get document extension from name or path
        Returns:
        extension
      • getTextTypeFromExtension

        public java.lang.String getTextTypeFromExtension()
        Get editor/preview type from extension
        Returns:
        Editor/preview type from extension
      • getFile

        public java.io.File getFile()
        Get the document as a local file
        Returns:
        Get the document as a local file
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Get content as input stream
        Returns:
        Get content as input stream
        Throws:
        java.io.IOException
      • getBytes

        public byte[] getBytes()
        Get binary content (current content, not forced to read from file)
        Returns:
        Get binary content
      • getBytes

        public byte[] getBytes​(boolean read)
                        throws java.io.IOException
        Get binary content
        Parameters:
        read - Force read bytes from file ?
        Returns:
        Get binary content
        Throws:
        java.io.IOException
      • isEmpty

        public boolean isEmpty()
        Is document file empty ?
        Returns:
        True when bytes are unset or empty
      • setBytes

        public void setBytes​(byte[] b)
        Set binary content
        ZZZ will use lot of memory, try to use setTmpStream ZZZ
        Parameters:
        b - Binary content
      • setBytes

        public void setBytes​(byte[] b,
                             boolean append)
        Set binary content
        ZZZ will use lot of memory, try to use setTmpStream ZZZ
        Parameters:
        b - binary content
        append - Append?
      • getUploadFile

        public java.io.File getUploadFile()
        Get temporary file to upload file without bytes in memory
        Returns:
        Temporary upload file
      • setUploadFile

        public void setUploadFile​(java.io.File file)
        Set temporary file to upload file without bytes in memory
        Parameters:
        file - Temporary upload file
      • getUploadStream

        public java.io.InputStream getUploadStream()
        Get input stream to upload file without bytes in memory
        Returns:
        Input stream to upload file
      • setUploadStream

        public void setUploadStream​(java.io.InputStream in)
        Set input stream to upload file without bytes in memory
        Parameters:
        in - Input stream to upload file
      • getURL

        public java.lang.String getURL​(java.lang.String cdisp)
        Get document URL (only relevant for generic web UI)
        Parameters:
        cdisp - Current disposition
        Returns:
        document URL
      • getThumbnailPath

        public java.lang.String getThumbnailPath()
        Get thumbnail image path (only relevant for images with thumbnail)
        Returns:
        thumbnail image path
      • getThumbnailFile

        public java.io.File getThumbnailFile()
        Get thumbnail file with absolute path (only relevant for images with thumbnail)
        Returns:
        thumbnail file
      • getThumbnailBytes

        public byte[] getThumbnailBytes​(boolean read)
                                 throws java.io.IOException
        Get thumbnail binary content (only relevant for images with thumbnail)
        Parameters:
        read - Force read bytes from file ?
        Returns:
        thumbnail binary content
        Throws:
        java.io.IOException
      • getThumbnailInputStream

        public java.io.InputStream getThumbnailInputStream()
                                                    throws java.io.IOException
        Get thumbnail content as input stream (only relevant for images with thumbnail)
        Returns:
        Thumbnail content as input stream
        Throws:
        java.io.IOException
      • getThumbnailURL

        public java.lang.String getThumbnailURL​(java.lang.String cdisp)
        Get image document thumbnail URL (only relevant for images with thumbnail)
        Parameters:
        cdisp - Disposition
        Returns:
        User picture thumbnail URL
      • getDataURL

        public java.lang.String getDataURL​(boolean thumbnail)
        Get data URL
        Parameters:
        thumbnail - Thumbnail or document content (true is only relevant for images with thumbnail)?
        Returns:
        Data URL for document or null if there was an exception reading thubnail or document content
      • getMIME

        public java.lang.String getMIME()
        Get MIME type
        Returns:
        MIME type
      • setMIME

        public void setMIME​(java.lang.String mime)
        Set MIME type
        Parameters:
        mime - MIME type
      • getContentType

        public java.lang.String getContentType()
        Get content type (from MIME type)
        Returns:
        content type
      • exists

        public static boolean exists​(java.lang.String docId)
        Checks document existence
        Parameters:
        docId - Doc ID
        Returns:
        true if exists in m_document
      • getMIME

        public static java.lang.String getMIME​(java.lang.String path)
        Get MIME type
        Parameters:
        path - Path
        Returns:
        MIME type extracted from file extension (or empty string if not found)
      • getContentType

        public static java.lang.String getContentType​(java.lang.String path)
        Get content type from MIME type for file name
        Parameters:
        path - Path
        Returns:
        Content type from MIME type extracted from file extension (or empty string if not found)
      • isZIP

        public static boolean isZIP​(java.lang.String mime)
        Is a ZIP file?
        Parameters:
        mime - MIME
        Returns:
        True if MIME type is ZIPF
      • isZIP

        public boolean isZIP()
        Is a ZIP file?
        Returns:
        True if MIME type is ZIP
      • isImage

        public static boolean isImage​(java.lang.String mime)
        Is an image?
        Parameters:
        mime - MIME
        Returns:
        true if MIME type is PNG, JPEG, SVG or GIF
      • isImage

        public boolean isImage()
        Is an image?
        Returns:
        true if MIME type is PNG, JPEG, SVG or GIF
      • isText

        public static boolean isText​(java.lang.String mime)
        Is a text MIME type file?
        Parameters:
        mime - MIME
        Returns:
        true if the MIME type of the file is a text MIME type
      • isBinary

        public static boolean isBinary​(java.lang.String mime)
        Is a binary MIME type file?
        Parameters:
        mime - MIME
        Returns:
        true if the MIME type of the file is not a text MIME type
      • isText

        public boolean isText()
        Is a text file?
        Returns:
        true if MIME type is a text file
      • isBinary

        public boolean isBinary()
        Is a binary file?
        Returns:
        true if MIME type is a binary file
      • inline

        public java.lang.String inline()
        Convert the document to a String (XML usage). Use base64 encoding for non textual contents.
        Returns:
        DATA:<docname>:[base64:]:<content...>
      • inline

        public static java.lang.String inline​(DocumentDB d)
        Convert a document to a inlined document string (XML usage). Use base64 encoding for non textual contents.
        Parameters:
        d - Document
        Returns:
        Inlined document string (DATA:<docname>:[base64:]:<content...>)
      • parse

        public static java.lang.Object[] parse​(java.lang.String doc)
        Parse a document (from XML import)
        Parameters:
        doc - Document
        Returns:
        Document path + bytes array when document is inlined
      • getSize

        public long getSize()
        Get file size (bytes)
        Returns:
        file size (bytes)
      • setSize

        public void setSize​(long size)
        Set file size (bytes)
        Parameters:
        size - file size (bytes)
      • getVersion

        public int getVersion()
        Version (automatically increased when saving)
        Returns:
        Version
      • getLastUpdated

        public java.lang.String getLastUpdated()
        Get last updated date time
        Returns:
        Last updated date time
      • getBookshelfName

        public java.lang.String getBookshelfName()
        Get bookshelf name
        Returns:
        Bookshelf name
      • getRespId

        public java.lang.String getRespId()
        Get document owner
        Returns:
        Document owner
      • getRespLogin

        public java.lang.String getRespLogin()
        get user login managing the document requests
        Returns:
        User login
      • getAccessGroups

        public java.util.List<java.lang.String> getAccessGroups()
        Get bookshelf groups
        Returns:
        Groups list
      • isGroupGranted

        public boolean isGroupGranted​(java.lang.String group,
                                      char grt)
        Is the group granted ?
        Parameters:
        group - Group name
        grt - Grant type (U)pload (D)ownload (M)Update index (G)Update grant (S)Delete
        Returns:
        True if the group is granted to the type
      • getFields

        public java.util.Map<java.lang.String,​java.lang.String> getFields()
        Get indexed fields
        Returns:
        Indexed fields
      • getObjectRef

        public java.lang.String getObjectRef()
        Get object name associated to the document
        Returns:
        object name associated to the document
      • setObjectRef

        public void setObjectRef​(java.lang.String object)
        Set object name associated to the document
        Parameters:
        object - object name associated to the document
      • getFieldRef

        public java.lang.String getFieldRef()
        Get field name associated to the document
        Returns:
        field name associated to the document
      • setFieldRef

        public void setFieldRef​(java.lang.String field)
        Set field name associated to the document
        Parameters:
        field - field name associated to the document
      • getRowIdRef

        public java.lang.String getRowIdRef()
        Get object record row ID associated to the document
        Returns:
        object record row ID
      • setRowIdRef

        public void setRowIdRef​(java.lang.String rowId)
        Set object record row ID associated to the document
        Parameters:
        rowId - object record row ID
      • getDocumentIdFromCondition

        public static java.lang.String getDocumentIdFromCondition​(java.lang.String condition)
        Get first document ID that matches specified SQL condition
        Parameters:
        condition - Condition
        Returns:
        ObjectField.DEFAULT_ROW_ID if no matching document is found
      • getDocumentIdFromPath

        public static java.lang.String getDocumentIdFromPath​(java.lang.String path)
        Get first document ID that matches specified path
        Parameters:
        path - Path
        Returns:
        ObjectField.DEFAULT_ROW_ID if no matching document is found
      • getDocumentIdFromName

        public static java.lang.String getDocumentIdFromName​(java.lang.String name)
        Get first document ID that matches specified name
        Parameters:
        name - Name
        Returns:
        ObjectField.DEFAULT_ROW_ID if no matching document is found
      • getDocumentId

        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
        Parameters:
        g - Grant
        object - Object name
        field - Field name
        rowId - Row ID
        Returns:
        null if no document is found or object is not granted
      • getDocumentId

        public 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
        Parameters:
        obj - Object
        field - Field name
        rowId - Row ID
        Returns:
        null if no document is found
      • select

        public static byte[] select​(java.lang.String docId)
        Read a document content from the ID
        Parameters:
        docId - Document ID
        Returns:
        Document content
      • read

        public static byte[] read​(java.lang.String path)
        Read a document content
        Parameters:
        path - Document path
        Returns:
        Document content
      • toString

        public static java.lang.String toString​(java.lang.String docId)
        Read a document content into a plain String.
        Parameters:
        docId - Document ID
        Returns:
        Document content as a plain String
      • toBase64

        public static java.lang.String toBase64​(java.lang.String docId)
        Read a document content into a Base64 encoded String
        Parameters:
        docId - Document ID
        Returns:
        Document content as a Base64 encoded String
      • getDocument

        public static DocumentDB getDocument​(java.lang.String docId,
                                             Grant grant)
        Retrieve document data from ID: dbdoc path, name, size, mime-type, version, etc.
        Parameters:
        docId - Document ID
        grant - User grants
        Returns:
        Document data
      • getDocuments

        public static DocumentDB getDocuments​(ObjectCore obj,
                                              ObjectField field,
                                              java.lang.String rowId)
        Retrieve documents data from ID: dbdoc path, name, size, mime-type, version, etc.
        Parameters:
        obj - Object
        field - Document field
        rowId - Object row ID
        Returns:
        Document data
      • copyDocuments

        public DocumentDB copyDocuments​(java.lang.String targetObject,
                                        java.lang.String targetField,
                                        java.lang.String targetRowId)
        Clone the multi-documents
        Parameters:
        targetObject - Target object name
        targetField - Target field name
        targetRowId - Target row ID
        Returns:
        Cloned multi-documents
      • addAccess

        public static void addAccess​(Grant g,
                                     java.lang.String docId)
        Add a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
        Parameters:
        g - User rights
        docId - Document id
      • removeAccess

        public static void removeAccess​(Grant g,
                                        java.lang.String docId)
        Remove a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
        Parameters:
        g - User rights
        docId - Document id
      • checkAccess

        public static boolean checkAccess​(Grant g,
                                          java.lang.String docId)
        Check a read access to the document in user's session (param _SESSION_DOC_ACCESS_)
        Parameters:
        g - User rights
        docId - Document id
        Returns:
        true is accessible
      • copyToRecycleBin

        public static void copyToRecycleBin​(DocumentDB doc)
        Copy to recycle bin
        Parameters:
        doc - Document
      • copyTo

        public void copyTo​(java.lang.String path)
        Copy document to specified path
        Parameters:
        path - Absolute path to copy document to
      • toJSONObject

        public org.json.JSONObject toJSONObject()
        Generates a JSON object representation of the single document. { id, path, name, size, contenttype, object, field, rowid }
        Returns:
        Document as JSON object
      • toJSONArray

        public org.json.JSONArray toJSONArray()
        Generates a JSON object representation of the multi-documents. [{ id, path, name, size, contenttype, object, field, rowid }]
        Returns:
        Documents as JSON array
      • toString

        public java.lang.String toString()
        Generates a string representation of the doucment(s)
        Overrides:
        toString in class java.lang.Object
        Returns:
        Document as string