Class DKLobICM
- java.lang.Object
-
- 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
dkResourceto 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
-
-
Field Summary
-
Fields inherited from class com.ibm.mm.sdk.common.DKDDOBase
datastore, propertyIdMap, propertyNameToIdMap
-
Fields inherited from class com.ibm.mm.sdk.common.dkAbstractDataObjectBase
contentElementList, document, folder, objectStore, pid, semanticType
-
-
Constructor Summary
Constructors Constructor and Description DKLobICM(com.filenet.api.core.ContentTransfer contentTransfer, DKDatastoreICM datastore)Constructs a LOB from a FileNet ContentTransfer.DKLobICM(com.filenet.api.core.Document document, DKDatastoreICM datastore)Constructs a LOB for a FileNet Document.DKLobICM(com.filenet.api.core.Document document, DKDatastoreICM datastore, java.lang.String semanticType)Constructs a LOB for a FileNet Document with semantic type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidadd()Adds/persists the LOB content to the document.voidadd(java.io.InputStream inputStream, long length)Adds content from an input stream.voidadd(java.io.InputStream inputStream, long length, int bitwiseAddOptions)Adds content from an input stream with options.voidadd(int bitwiseAddOptions)voidadd(java.lang.String fullyQualifiedFileName)Adds content from a file.voidadd(java.lang.String fullyQualifiedFileName, int bitwiseAddOptions)voiddel()Deletes this LOB content.voiddel(boolean flush)voiddel(int option)byte[]getContent()Gets the entire content as a byte array.java.io.InputStreamgetContentInputStream(DKNVPair[] options, long offset, long length)Gets an input stream for the content with offset and length control.voidgetContentToClientFile(java.lang.String fileName, int fileOption)com.filenet.api.core.ContentTransfergetContentTransfer()Gets the underlying FileNet ContentTransfer object.java.lang.StringgetCreatedTimestamp()java.io.InputStreamgetInputStream(DKNVPair[] optionsDKNVPair, int offset, int length)Deprecated.UsegetContentInputStream(DKNVPair[], long, long)insteadjava.lang.StringgetItemId()java.lang.StringgetMimeType()Gets the MIME type of this content.booleangetNewVersion()Gets whether this will create a new version.java.lang.StringgetOrgFileName()intgetPartNumber()java.lang.StringgetReferencedTimestamp()java.lang.StringgetResourceName()java.lang.StringgetRMName()longgetSize()Gets the size of the content in bytes.java.lang.StringgetUpdatedTimestamp()java.lang.StringgetVersionNumber()Gets the version number of the document.booleanisContentChanged()Checks if the content has been modified.booleanisNull()booleanisOpenSynchronous()booleanisSet()Checks if content has been set.voidretrieve()Retrieve (refresh) the document or folder from the object store.voidretrieve(DKNVPair[] optionsDKNVPair)Retrieve (refresh) the document from the object store with options.java.lang.Objectretrieve(DKNVPair[] optionsDKNVPair, long offset, long length)voidretrieve(DKNVPair[] optionsDKNVPair, java.lang.String targetLocalFileName, int offset, int length)voidretrieve(DKThirdPartyServerDef thirdPartyServerDef, DKNVPair[] optionsDKNVPair)voidretrieve(java.lang.String targetLocalFileName, DKNVPair[] optionsDKNVPair)voidsetContent(byte[] aByteArray)Sets the content from a byte array.voidsetContentFromClientFile(java.lang.String fileName)voidsetMimeType(java.lang.String string)Sets the MIME type for this content.voidsetNewVersion(boolean newVersion)voidsetNull()voidsetOrgFileName(java.lang.String ofile)intsize()longsizeInDatastore()voidupdate()Updates the LOB with current changes.voidupdate(java.io.InputStream inputStream, long length)voidupdate(java.io.InputStream inputStream, long length, int bitwiseUpdateOptions)Updates content from an input stream.voidupdate(int bitwiseUpdateOptions)Updates the LOB with options.voidupdate(java.lang.String fullyQualifiedFileName)voidupdate(java.lang.String fullyQualifiedFileName, int bitwiseUpdateOptions)-
Methods inherited from class com.ibm.mm.sdk.common.DKDDO
addElement, del, getDatastore, getDocument, getFolder, removeMember, retrieve, toString, toXML, update
-
Methods inherited from class com.ibm.mm.sdk.common.DKDDOBase
dataCount, dataId, dataId, dataIdsByNameSpace, dataPropertyCount, dataPropertyId, getData, getDataByName, getDataByName, getDataName, getDataProperty, getDataPropertyByName, getDataPropertyByName, getDataPropertyByName, getDataPropertyName, getObjectType, getProperty, getProperty, getPropertyByName, getPropertyName, isDataPropertySet, isDataSet, isNull, isPropertySet, propertyCount, setData, setProperty, setProperty, setPropertyObject
-
Methods inherited from class com.ibm.mm.sdk.common.dkDataObject
getId, getPidObject, getProperties, save, setPidObject
-
Methods inherited from class com.ibm.mm.sdk.common.dkAbstractDataObjectBase
getContentElementList, getNativeObject, getObject, getSemanticType, setContentElementList, setDocument, setObject, setSemanticType
-
-
-
-
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 objectdatastore- 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 documentdatastore- 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 documentdatastore- the datastore instancesemanticType- the CM8 semantic type
-
-
Method Detail
-
getInputStream
@Deprecated public java.io.InputStream getInputStream(DKNVPair[] optionsDKNVPair, int offset, int length)
Deprecated. UsegetContentInputStream(DKNVPair[], long, long)insteadGets an input stream for the content.- Parameters:
optionsDKNVPair- retrieval optionsoffset- starting offset in byteslength- 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.ExceptionAdds/persists the LOB content to the document.Saves the content that was set via setContent() or other add() methods.
- Specified by:
addin interfacedkXDO- Overrides:
addin classDKDDO- Throws:
DKException- if the add operation failsjava.lang.Exception- if an unexpected error occurs
-
add
public void add(java.io.InputStream inputStream, long length) throws DKException, java.lang.ExceptionAdds content from an input stream.- Parameters:
inputStream- the input stream containing contentlength- the number of bytes to read (0 for all)- Throws:
DKException- if the add operation failsjava.lang.Exception- if an unexpected error occurs
-
add
public void add(java.io.InputStream inputStream, long length, int bitwiseAddOptions) throws DKException, java.lang.ExceptionAdds content from an input stream with options.- Parameters:
inputStream- the input stream containing contentlength- the number of bytes to read (0 for all)bitwiseAddOptions- bitwise options for the add operation- Throws:
DKException- if the add operation failsjava.lang.Exception- if an unexpected error occurs
-
add
public void add(int bitwiseAddOptions) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
add
public void add(java.lang.String fullyQualifiedFileName) throws DKException, java.lang.ExceptionAdds 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 failsjava.lang.Exception- if an unexpected error occurs
-
add
public void add(java.lang.String fullyQualifiedFileName, int bitwiseAddOptions) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
retrieve
public void retrieve()
Description copied from class:DKDDORetrieve (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).
-
retrieve
public void retrieve(DKNVPair[] optionsDKNVPair)
Description copied from class:DKDDORetrieve (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.
-
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(DKThirdPartyServerDef thirdPartyServerDef, DKNVPair[] optionsDKNVPair)
-
retrieve
public void retrieve(java.lang.String targetLocalFileName, DKNVPair[] optionsDKNVPair)
-
setMimeType
public void setMimeType(java.lang.String string) throws DKException, java.lang.ExceptionSets the MIME type for this content.- Parameters:
string- the MIME type (e.g., "application/pdf", "text/plain")- Throws:
DKException- if the operation failsjava.lang.Exception- if an unexpected error occurs
-
getMimeType
public java.lang.String getMimeType() throws DKExceptionGets 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)
-
getOrgFileName
public java.lang.String getOrgFileName() throws DKException- Throws:
DKException
-
getPartNumber
public int getPartNumber() throws DKException- Throws:
DKException
-
getContentTransfer
public com.filenet.api.core.ContentTransfer getContentTransfer()
Gets the underlying FileNet ContentTransfer object.- Returns:
- the ContentTransfer instance
-
del
public void del() throws DKExceptionDeletes this LOB content.- Overrides:
delin classDKDDO- Throws:
DKException- if the delete operation fails
-
del
public void del(boolean flush) throws DKException- Throws:
DKException
-
del
public void del(int option) throws DKException- Overrides:
delin classDKDDO- Throws:
DKException
-
getContentToClientFile
public void getContentToClientFile(java.lang.String fileName, int fileOption) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
getCreatedTimestamp
public java.lang.String getCreatedTimestamp() throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
getReferencedTimestamp
public java.lang.String getReferencedTimestamp() throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
getItemId
public java.lang.String getItemId()
-
getResourceName
public java.lang.String getResourceName() throws DKException- Throws:
DKException
-
getRMName
public java.lang.String getRMName() throws DKException- Throws:
DKException
-
getSize
public long getSize() throws DKExceptionGets the size of the content in bytes.- Returns:
- the content size in bytes
- Throws:
DKException- if the operation fails
-
size
public int size() throws DKException- Throws:
DKException
-
sizeInDatastore
public long sizeInDatastore() throws DKException- Throws:
DKException
-
getUpdatedTimestamp
public java.lang.String getUpdatedTimestamp() throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
getVersionNumber
public java.lang.String getVersionNumber() throws DKExceptionGets the version number of the document.- Returns:
- the version number as a string
- Throws:
DKException- if the operation fails
-
isSet
public boolean isSet() throws DKExceptionChecks 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:
DKExceptionjava.lang.Exception
-
isOpenSynchronous
public boolean isOpenSynchronous()
-
isNull
public boolean isNull()
-
setNewVersion
public void setNewVersion(boolean newVersion)
-
setNull
public void setNull() throws DKException- Throws:
DKException
-
update
public void update(java.io.InputStream inputStream, long length) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
update
public void update() throws DKExceptionUpdates the LOB with current changes.- Overrides:
updatein classDKDDO- Throws:
DKException- if the update fails
-
update
public void update(int bitwiseUpdateOptions) throws DKException, java.lang.ExceptionUpdates the LOB with options.- Overrides:
updatein classDKDDO- Parameters:
bitwiseUpdateOptions- bitwise options for the update- Throws:
DKException- if the update failsjava.lang.Exception- if an unexpected error occurs
-
update
public void update(java.io.InputStream inputStream, long length, int bitwiseUpdateOptions) throws DKException, java.lang.ExceptionUpdates content from an input stream.- Parameters:
inputStream- the input stream containing new contentlength- the number of bytes to readbitwiseUpdateOptions- bitwise options for the update- Throws:
DKException- if the update failsjava.lang.Exception- if an unexpected error occurs
-
update
public void update(java.lang.String fullyQualifiedFileName) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.lang.Exception
-
update
public void update(java.lang.String fullyQualifiedFileName, int bitwiseUpdateOptions) throws DKException, java.lang.Exception- Throws:
DKExceptionjava.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)
-
-