com.ibm.mm.sdk.common

Class DKLobICM

  • All Implemented Interfaces:
    dkDataObjectBase, dkXDO, dkXDOBase, java.io.Serializable


    public class DKLobICM
    extends dkResource
    IBM Content Manager (ICM) implementation for Large Object (LOB) content management.

    This class extends dkResource to provide comprehensive LOB/content management functionality for FileNet P8. It handles document content operations including upload, download, streaming, and metadata management.

    Key Features:

    • Content upload from files, streams, or byte arrays
    • Content download to files, streams, or byte arrays
    • Streaming support with offset and length control
    • MIME type and filename management
    • Version control and checkout/checkin
    • Content size and timestamp tracking
    • Automatic document checkout for content modifications

    Content Operations:

    • Add: add(InputStream), add(String filename), add(byte[])
    • Retrieve: retrieve(), getContent(), getContentInputStream()
    • Update: update(InputStream), update(String filename), setContent(byte[])
    • Delete: del(), del(boolean flush)

    Metadata Operations:

    • getMimeType() / setMimeType(String)
    • getOrgFileName() / setOrgFileName(String)
    • getSize() / size() / sizeInDatastore()
    • getVersionNumber()
    • getCreatedTimestamp() / getUpdatedTimestamp()

    Example usage - Upload content:

     // Create LOB from file
     DKDDO document = datastore.createDDO("Document", DKConstant.DK_CM_DOCUMENT);
     DKLobICM lob = new DKLobICM(document.getDocument(), datastore);
     lob.add("/path/to/file.pdf");
     lob.setMimeType("application/pdf");
    
     // Or from byte array
     byte[] content = "Hello, World!".getBytes();
     lob.setContent(content);
     lob.add();
     

    Example usage - Download content:

     // Retrieve LOB
     DKLobICM lob = (DKLobICM) document.getParts().item(0);
    
     // Download to file
     lob.retrieve("/path/to/output.pdf", null);
    
     // Or get as byte array
     byte[] content = lob.getContent();
    
     // Or stream with offset/length
     InputStream stream = lob.getContentInputStream(null, 0, 1024);
     
    See Also:
    dkResource, DKParts, ContentTransfer, DKDDO, Serialized Form
    • Constructor Detail

      • DKLobICM

        public DKLobICM(com.filenet.api.core.ContentTransfer contentTransfer,
                        DKDatastoreICM datastore)
        Constructs a LOB from a FileNet ContentTransfer.

        Used when wrapping existing content elements from documents.

        Parameters:
        contentTransfer - the FileNet content transfer object
        datastore - the datastore instance
      • DKLobICM

        public DKLobICM(com.filenet.api.core.Document document,
                        DKDatastoreICM datastore)
        Constructs a LOB for a FileNet Document.
        Parameters:
        document - the FileNet document
        datastore - the datastore instance
      • DKLobICM

        public DKLobICM(com.filenet.api.core.Document document,
                        DKDatastoreICM datastore,
                        java.lang.String semanticType)
        Constructs a LOB for a FileNet Document with semantic type.
        Parameters:
        document - the FileNet document
        datastore - the datastore instance
        semanticType - the CM8 semantic type
    • Method Detail

      • getInputStream

        @Deprecated
        public java.io.InputStream getInputStream(DKNVPair[] optionsDKNVPair,
                                                              int offset,
                                                              int length)
        Gets an input stream for the content.
        Parameters:
        optionsDKNVPair - retrieval options
        offset - starting offset in bytes
        length - number of bytes to read
        Returns:
        input stream for the content
      • getContentInputStream

        public java.io.InputStream getContentInputStream(DKNVPair[] options,
                                                         long offset,
                                                         long length)
        Gets an input stream for the content with offset and length control.

        Allows reading a specific portion of the content by specifying offset and length. Useful for streaming large files or implementing range requests.

        Parameters:
        options - retrieval options (currently unused)
        offset - starting offset in bytes (0-based)
        length - number of bytes to read (0 or negative for entire content)
        Returns:
        input stream positioned at the specified offset
        Throws:
        java.lang.RuntimeException - if content retrieval fails
      • getContent

        public byte[] getContent()
        Gets the entire content as a byte array.

        Loads the complete content into memory. Use with caution for large files.

        Returns:
        the content as a byte array, or null if no content exists
        Throws:
        java.lang.RuntimeException - if content reading fails
      • setContent

        public void setContent(byte[] aByteArray)
        Sets the content from a byte array.

        Prepares the content for upload. Call add() to persist the changes.

        Parameters:
        aByteArray - the content bytes
      • add

        public void add()
                 throws DKException,
                        java.lang.Exception
        Adds/persists the LOB content to the document.

        Saves the content that was set via setContent() or other add() methods.

        Specified by:
        add in interface dkXDO
        Overrides:
        add in class DKDDO
        Throws:
        DKException - if the add operation fails
        java.lang.Exception - if an unexpected error occurs
      • add

        public void add(java.io.InputStream inputStream,
                        long length)
                 throws DKException,
                        java.lang.Exception
        Adds content from an input stream.
        Parameters:
        inputStream - the input stream containing content
        length - the number of bytes to read (0 for all)
        Throws:
        DKException - if the add operation fails
        java.lang.Exception - if an unexpected error occurs
      • add

        public void add(java.io.InputStream inputStream,
                        long length,
                        int bitwiseAddOptions)
                 throws DKException,
                        java.lang.Exception
        Adds content from an input stream with options.
        Parameters:
        inputStream - the input stream containing content
        length - the number of bytes to read (0 for all)
        bitwiseAddOptions - bitwise options for the add operation
        Throws:
        DKException - if the add operation fails
        java.lang.Exception - if an unexpected error occurs
      • add

        public void add(int bitwiseAddOptions)
                 throws DKException,
                        java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • add

        public void add(java.lang.String fullyQualifiedFileName)
                 throws DKException,
                        java.lang.Exception
        Adds content from a file.

        Reads the file and uploads its content to the document. The filename is automatically set as the original filename.

        Parameters:
        fullyQualifiedFileName - the full path to the file
        Throws:
        DKException - if the file cannot be read or the add operation fails
        java.lang.Exception - if an unexpected error occurs
      • add

        public void add(java.lang.String fullyQualifiedFileName,
                        int bitwiseAddOptions)
                 throws DKException,
                        java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • retrieve

        public void retrieve()
        Description copied from class: DKDDO
        Retrieve (refresh) the document or folder from the object store. This method fetches the latest version of the object from FileNet P8, refreshing all properties to their current values in the repository. Supports both documents (DK_CM_DOCUMENT) and folders (DK_CM_FOLDER).
        Overrides:
        retrieve in class DKDDO
      • retrieve

        public void retrieve(DKNVPair[] optionsDKNVPair)
        Description copied from class: DKDDO
        Retrieve (refresh) the document from the object store with options. This overloaded method accepts an array of DKNVPair options but ignores them, internally calling the parameterless retrieve() method.
        Overrides:
        retrieve in class DKDDO
        Parameters:
        optionsDKNVPair - retrieve options (ignored in this implementation)
      • retrieve

        public java.lang.Object retrieve(DKNVPair[] optionsDKNVPair,
                                         long offset,
                                         long length)
      • retrieve

        public void retrieve(DKNVPair[] optionsDKNVPair,
                             java.lang.String targetLocalFileName,
                             int offset,
                             int length)
      • retrieve

        public void retrieve(java.lang.String targetLocalFileName,
                             DKNVPair[] optionsDKNVPair)
      • setMimeType

        public void setMimeType(java.lang.String string)
                         throws DKException,
                                java.lang.Exception
        Sets the MIME type for this content.
        Parameters:
        string - the MIME type (e.g., "application/pdf", "text/plain")
        Throws:
        DKException - if the operation fails
        java.lang.Exception - if an unexpected error occurs
      • getMimeType

        public java.lang.String getMimeType()
                                     throws DKException
        Gets the MIME type of this content.
        Returns:
        the MIME type string
        Throws:
        DKException - if the operation fails
      • setOrgFileName

        public void setOrgFileName(java.lang.String ofile)
      • getContentTransfer

        public com.filenet.api.core.ContentTransfer getContentTransfer()
        Gets the underlying FileNet ContentTransfer object.
        Returns:
        the ContentTransfer instance
      • del

        public void del()
                 throws DKException
        Deletes this LOB content.
        Overrides:
        del in class DKDDO
        Throws:
        DKException - if the delete operation fails
      • getContentToClientFile

        public void getContentToClientFile(java.lang.String fileName,
                                           int fileOption)
                                    throws DKException,
                                           java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • getCreatedTimestamp

        public java.lang.String getCreatedTimestamp()
                                             throws DKException,
                                                    java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • getReferencedTimestamp

        public java.lang.String getReferencedTimestamp()
                                                throws DKException,
                                                       java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • getItemId

        public java.lang.String getItemId()
      • getSize

        public long getSize()
                     throws DKException
        Gets the size of the content in bytes.
        Returns:
        the content size in bytes
        Throws:
        DKException - if the operation fails
      • getUpdatedTimestamp

        public java.lang.String getUpdatedTimestamp()
                                             throws DKException,
                                                    java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • getVersionNumber

        public java.lang.String getVersionNumber()
                                          throws DKException
        Gets the version number of the document.
        Returns:
        the version number as a string
        Throws:
        DKException - if the operation fails
      • isSet

        public boolean isSet()
                      throws DKException
        Checks if content has been set.
        Returns:
        true if content exists and has non-zero size, false otherwise
        Throws:
        DKException - if the check fails
      • setContentFromClientFile

        public void setContentFromClientFile(java.lang.String fileName)
                                      throws DKException,
                                             java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • isOpenSynchronous

        public boolean isOpenSynchronous()
      • isNull

        public boolean isNull()
      • setNewVersion

        public void setNewVersion(boolean newVersion)
      • update

        public void update(java.io.InputStream inputStream,
                           long length)
                    throws DKException,
                           java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • update

        public void update()
                    throws DKException
        Updates the LOB with current changes.
        Overrides:
        update in class DKDDO
        Throws:
        DKException - if the update fails
      • update

        public void update(int bitwiseUpdateOptions)
                    throws DKException,
                           java.lang.Exception
        Updates the LOB with options.
        Overrides:
        update in class DKDDO
        Parameters:
        bitwiseUpdateOptions - bitwise options for the update
        Throws:
        DKException - if the update fails
        java.lang.Exception - if an unexpected error occurs
      • update

        public void update(java.io.InputStream inputStream,
                           long length,
                           int bitwiseUpdateOptions)
                    throws DKException,
                           java.lang.Exception
        Updates content from an input stream.
        Parameters:
        inputStream - the input stream containing new content
        length - the number of bytes to read
        bitwiseUpdateOptions - bitwise options for the update
        Throws:
        DKException - if the update fails
        java.lang.Exception - if an unexpected error occurs
      • update

        public void update(java.lang.String fullyQualifiedFileName)
                    throws DKException,
                           java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • update

        public void update(java.lang.String fullyQualifiedFileName,
                           int bitwiseUpdateOptions)
                    throws DKException,
                           java.lang.Exception
        Throws:
        DKException
        java.lang.Exception
      • isContentChanged

        public boolean isContentChanged()
        Checks if the content has been modified.
        Returns:
        true if content has changed, false otherwise
      • getNewVersion

        public boolean getNewVersion()
        Gets whether this will create a new version.
        Returns:
        true (always creates new version)
Copyright © 2024 IBM Corporation

Copyright © 2024 IBM Corporation. All rights reserved.