com.ibm.xsp.model.domino.wrapped
Class DominoDocument

java.lang.Object
  extended by com.ibm.xsp.model.domino.wrapped.DominoDocument
All Implemented Interfaces:
com.ibm.xsp.model.DataObject, java.io.Serializable

public class DominoDocument
extends java.lang.Object
implements com.ibm.xsp.model.DataObject, java.io.Serializable

NotesXspDocument represents a Domino Document in XPages

See Also:
Serialized Form

Nested Class Summary
static class DominoDocument.AttachmentValueHolder
          Stores information about an attachment to a field and the operation performed on that attachment.
 class DominoDocument.FieldValueHolder
          Stores information about a field (a Domino Item proxy) and the operation performed on that field.
static class DominoDocument.XmlDocument
          Experimental XML support (DO NOT USE)
 
Constructor Summary
DominoDocument()
          This method is provided for object serialization/deserialization and should only be used for those purposes.
 
Method Summary
 void afterDeserializing(com.ibm.xsp.model.domino.DominoDocumentDataContainer container)
          Serialization mechanism.
 void beforeSerializing()
          Serialization mechanism.
 void checkDocumentValidity()
          Check if the document is still valid as an action might have deleted it
 void closeMIMEEntities(boolean persist, java.lang.String fieldName)
          If the fieldName is a RichTextItem - close the MIME Entities for the field
 void discardWrappedObject()
          Discards the wrapped Document.
 org.w3c.dom.Document getAttachmentAsXML(java.lang.String fieldName, java.lang.String attachmentName, boolean readOnly)
          Gets the content of a field attachment as an in memory XML Document.
 java.util.List<FileRowData> getAttachmentList(java.lang.String fieldName)
          Get the list of attachments for the field specified
 java.util.Map<java.lang.String,DominoDocument.FieldValueHolder> getChangedFields()
          Return list of changed fields
 java.lang.String getComputeWithFormNamed()
          Return the Form name for ComputeWithForm
 java.lang.String getDBName()
          Return the name of Database that stores the Document
 lotus.domino.Document getDocument()
          Return the wrapped Document
 lotus.domino.Document getDocument(boolean applyChanges)
          Return the wrapped document
 java.lang.String getDocumentId()
          Return the Note Id
 java.util.List<FileRowData> getEmbeddedImagesList(java.lang.String fieldName)
          Return the List of images attached to this Document
 org.w3c.dom.Document getFieldAsXML(java.lang.String fieldName, boolean readOnly)
          DO NOT USE
 java.lang.String getForm()
          Get the name of the Form associated with this Document
 java.util.Vector getItemValue(java.lang.String name)
          Return the value(s) stored in the field name
 com.ibm.jscript.std.ArrayObject getItemValueArray(java.lang.String name)
          Return the value(s) for a field name as an Array
 java.util.Date getItemValueDate(java.lang.String name)
          Return the value stored in field name as a Date Returns null if the field is not a DataTime.
 lotus.domino.DateTime getItemValueDateTime(java.lang.String name)
          Return the values stored in field name as a DateTime Returns null if the field is not a number.
 double getItemValueDouble(java.lang.String name)
          Return the values stored in field name as a double Returns 0 if the field is not a number.
 int getItemValueInteger(java.lang.String name)
          Return the values stored in field name as an int Returns 0 if the fields is not a number.
 java.lang.String getItemValueString(java.lang.String name)
          Returns the value stored in field name as a String.
 java.lang.String getNoteID()
          Return the Note Id
 lotus.domino.Database getParentDatabase()
          Return the Database that stores the Document
 java.lang.String getParentDatabaseFileName()
          Return the File Path for the Database that stores the Document
 java.lang.String getParentId()
          Return the parent id of the Document
 java.lang.String getPersistenceFolder(java.lang.String fieldName)
          Get the Folder name for persistence data in the form DominoDoc-[9999]-[filedName]
 DominoRichTextItem getRichTextItem(java.lang.String fieldName)
          Get the RichTextItem for this field.
 java.lang.String getSaveLinksAs()
          Save links in the document as HTTP:(UseWeb) or NOTES:(UseNotes)
 java.lang.Class getType(java.lang.Object key)
          Return the data type of the specified key
 lotus.domino.Document getValidDocument()
          Check if the document is valid and the we return it else, return a null pointer in that case
 java.lang.Object getValue(java.lang.Object fieldName)
          Return the value of the Item named fieldName.
 boolean hasItem(java.lang.String fieldName)
          Return true if the document has a field fieldName
 boolean isAllowDeletedDocs()
          Return true if deleted documents are allowed.
 boolean isEditable()
          Returns true if the document is editable
 boolean isNewNote()
          Return true if the Document is a new Document
 boolean isReadOnly(java.lang.Object key)
          Indicate whether this Document is ReadOnly or is Editable
 boolean isResponse()
          Return true if the Document is a response Document
 void recycle()
          Recycle.
 void removeAllAttachments(java.lang.String fieldName)
          Remove all attachement from the specified field
 boolean removeAttachment(java.lang.String fieldName, java.lang.String attachmentName)
          Remove an attachment associated with a field
 void removeItem(java.lang.String fieldName)
          Removes the item fieldName from the document
 void replaceItemValue(java.lang.String fieldName, java.lang.Object value)
          Replace the current value of item fieldName in the document with value
 void restoreWrappedDocument()
          Restore the wrapped document from the Database.
 boolean save()
          Save any changes to the Document (and compute any fields, if required)
 void setAllowDeletedDocs(boolean deletedDocs)
          Set whether Document is allowed deleted documents
 void setDocument(lotus.domino.Document document)
          Set this document to be the wrapped document
 void setEditable(boolean isEditable)
          Set true the document can be edited
 void setRichTextItem(java.lang.String fieldName, DominoRichTextItem drti)
          Add this field name and its RichTextItem value o the list of RichTextsItems
 void setValue(java.lang.Object fieldName, java.lang.Object value)
          DataObject setValue implementation.
static DominoDocument wrap(java.lang.String database, lotus.domino.Database db, java.lang.String parentId, java.lang.String form, java.lang.String computeWithForm, java.lang.String concurrencyMode, boolean allowDeletedDocs, java.lang.String saveLinksAs)
          Create a new DominoDocument(NotesXspDocument) that wraps a lotus.domino.document
static DominoDocument wrap(java.lang.String database, lotus.domino.Document document, java.lang.String computeWithForm, java.lang.String concurrencyMode, boolean allowDeletedDocs, java.lang.String saveLinksAs)
          Create a new DominoDocument(NotesXspDocument) that wraps a lotus.domino.document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DominoDocument

public DominoDocument()
This method is provided for object serialization/deserialization and should only be used for those purposes.

Method Detail

wrap

public static DominoDocument wrap(java.lang.String database,
                                  lotus.domino.Document document,
                                  java.lang.String computeWithForm,
                                  java.lang.String concurrencyMode,
                                  boolean allowDeletedDocs,
                                  java.lang.String saveLinksAs)
Create a new DominoDocument(NotesXspDocument) that wraps a lotus.domino.document

Parameters:
database -
document -
computeWithForm -
concurrencyMode -
allowDeletedDocs -
saveLinksAs - Save links in the document as HTTP:(UseWeb) or NOTES:(UseNotes)
Returns:

wrap

public static DominoDocument wrap(java.lang.String database,
                                  lotus.domino.Database db,
                                  java.lang.String parentId,
                                  java.lang.String form,
                                  java.lang.String computeWithForm,
                                  java.lang.String concurrencyMode,
                                  boolean allowDeletedDocs,
                                  java.lang.String saveLinksAs)
Create a new DominoDocument(NotesXspDocument) that wraps a lotus.domino.document

Parameters:
database -
db -
parentId -
form -
computeWithForm -
concurrencyMode -
allowDeletedDocs -
saveLinksAs -
Returns:

getPersistenceFolder

public java.lang.String getPersistenceFolder(java.lang.String fieldName)
Get the Folder name for persistence data in the form DominoDoc-[9999]-[filedName]

Parameters:
fieldName -
Returns:
Folder name for persistence data in the form DominoDoc-[9999]-[filedName]

getDBName

public java.lang.String getDBName()
Return the name of Database that stores the Document

Returns:
Return the name of Database that stores the Document

getComputeWithFormNamed

public java.lang.String getComputeWithFormNamed()
Return the Form name for ComputeWithForm

Returns:
Return the Form name for ComputeWithForm

isAllowDeletedDocs

public boolean isAllowDeletedDocs()
Return true if deleted documents are allowed.

Returns:
Return true if deleted documents are allowed

getSaveLinksAs

public java.lang.String getSaveLinksAs()
Save links in the document as HTTP:(UseWeb) or NOTES:(UseNotes)

Returns:
Save links in the document as HTTP:(UseWeb) or NOTES:(UseNotes)

setAllowDeletedDocs

public void setAllowDeletedDocs(boolean deletedDocs)
Set whether Document is allowed deleted documents

Parameters:
deletedDocs -

getDocument

public lotus.domino.Document getDocument()
Return the wrapped Document


getValidDocument

public final lotus.domino.Document getValidDocument()
                                             throws lotus.domino.NotesException
Check if the document is valid and the we return it else, return a null pointer in that case

Returns:
Throws:
lotus.domino.NotesException

checkDocumentValidity

public void checkDocumentValidity()
Check if the document is still valid as an action might have deleted it


setDocument

public void setDocument(lotus.domino.Document document)
Set this document to be the wrapped document

Parameters:
document -

getDocument

public lotus.domino.Document getDocument(boolean applyChanges)
                                  throws lotus.domino.NotesException
Return the wrapped document

Parameters:
applyChanges - Apply any changes to the wrapped document before returning it
Throws:
lotus.domino.NotesException

restoreWrappedDocument

public void restoreWrappedDocument()
Restore the wrapped document from the Database. Throws exception if document has been deleted. If it is a new Document, not yet saved, create a new Document.


recycle

public void recycle()
             throws lotus.domino.NotesException
Recycle. If wrapped Document is not null, recycle the document and discard the wrapped document

Throws:
lotus.domino.NotesException

discardWrappedObject

public void discardWrappedObject()
Discards the wrapped Document. If there are RichTextFields - cycles through and discards them also.


closeMIMEEntities

public void closeMIMEEntities(boolean persist,
                              java.lang.String fieldName)
                       throws lotus.domino.NotesException
If the fieldName is a RichTextItem - close the MIME Entities for the field

Parameters:
persist -
fieldName -
Throws:
lotus.domino.NotesException

getForm

public java.lang.String getForm()
                         throws lotus.domino.NotesException
Get the name of the Form associated with this Document

Throws:
lotus.domino.NotesException

isEditable

public boolean isEditable()
Returns true if the document is editable


setEditable

public void setEditable(boolean isEditable)
Set true the document can be edited

Parameters:
isEditable -

getParentId

public java.lang.String getParentId()
Return the parent id of the Document


getItemValue

public java.util.Vector getItemValue(java.lang.String name)
                              throws lotus.domino.NotesException
Return the value(s) stored in the field name

Throws:
lotus.domino.NotesException

getItemValueArray

public com.ibm.jscript.std.ArrayObject getItemValueArray(java.lang.String name)
                                                  throws lotus.domino.NotesException,
                                                         com.ibm.jscript.InterpretException
Return the value(s) for a field name as an Array

Throws:
lotus.domino.NotesException
com.ibm.jscript.InterpretException

getItemValueString

public java.lang.String getItemValueString(java.lang.String name)
                                    throws lotus.domino.NotesException
Returns the value stored in field name as a String. If it is a multi-valued field, only the first values is returned. If it is a RichTextField, then contents are returned as text.

Throws:
lotus.domino.NotesException

getItemValueInteger

public int getItemValueInteger(java.lang.String name)
                        throws lotus.domino.NotesException
Return the values stored in field name as an int Returns 0 if the fields is not a number.

Throws:
lotus.domino.NotesException

getItemValueDouble

public double getItemValueDouble(java.lang.String name)
                          throws lotus.domino.NotesException
Return the values stored in field name as a double Returns 0 if the field is not a number.

Throws:
lotus.domino.NotesException

getItemValueDateTime

public lotus.domino.DateTime getItemValueDateTime(java.lang.String name)
                                           throws lotus.domino.NotesException
Return the values stored in field name as a DateTime Returns null if the field is not a number.

Throws:
lotus.domino.NotesException

getItemValueDate

public java.util.Date getItemValueDate(java.lang.String name)
                                throws lotus.domino.NotesException
Return the value stored in field name as a Date Returns null if the field is not a DataTime.

Throws:
lotus.domino.NotesException

getNoteID

public java.lang.String getNoteID()
                           throws lotus.domino.NotesException
Return the Note Id

Throws:
lotus.domino.NotesException

getDocumentId

public java.lang.String getDocumentId()
Return the Note Id

Returns:
Return the Note Id

getParentDatabase

public lotus.domino.Database getParentDatabase()
                                        throws lotus.domino.NotesException
Return the Database that stores the Document

Throws:
lotus.domino.NotesException

getParentDatabaseFileName

public java.lang.String getParentDatabaseFileName()
                                           throws lotus.domino.NotesException
Return the File Path for the Database that stores the Document

Returns:
Return the File Path for the Database that stores the Document
Throws:
lotus.domino.NotesException

hasItem

public boolean hasItem(java.lang.String fieldName)
                throws lotus.domino.NotesException
Return true if the document has a field fieldName

Throws:
lotus.domino.NotesException

isNewNote

public boolean isNewNote()
                  throws lotus.domino.NotesException
Return true if the Document is a new Document

Throws:
lotus.domino.NotesException

isResponse

public boolean isResponse()
                   throws lotus.domino.NotesException
Return true if the Document is a response Document

Throws:
lotus.domino.NotesException

removeItem

public void removeItem(java.lang.String fieldName)
                throws lotus.domino.NotesException
Removes the item fieldName from the document

Throws:
lotus.domino.NotesException

replaceItemValue

public void replaceItemValue(java.lang.String fieldName,
                             java.lang.Object value)
                      throws lotus.domino.NotesException
Replace the current value of item fieldName in the document with value

Throws:
lotus.domino.NotesException

save

public boolean save()
             throws lotus.domino.NotesException
Save any changes to the Document (and compute any fields, if required)

Throws:
lotus.domino.NotesException

getValue

public java.lang.Object getValue(java.lang.Object fieldName)
Return the value of the Item named fieldName. What is returned depends on the datatype of the fields. Could be a String value, or an MIME entity if the item is a RichTextItem.

Specified by:
getValue in interface com.ibm.xsp.model.DataObject

getType

public java.lang.Class getType(java.lang.Object key)
Return the data type of the specified key

Specified by:
getType in interface com.ibm.xsp.model.DataObject

setValue

public void setValue(java.lang.Object fieldName,
                     java.lang.Object value)
DataObject setValue implementation. This function is called by the JSF layer, thus with "pure" Java data. For example, dates are expressed through Java Date object and not Notes DateTime. => Some conversion should happen then at this layer

Specified by:
setValue in interface com.ibm.xsp.model.DataObject

isReadOnly

public boolean isReadOnly(java.lang.Object key)
Indicate whether this Document is ReadOnly or is Editable

Specified by:
isReadOnly in interface com.ibm.xsp.model.DataObject

getChangedFields

public java.util.Map<java.lang.String,DominoDocument.FieldValueHolder> getChangedFields()
Return list of changed fields

Returns:
Return list of changed fields

getAttachmentList

public java.util.List<FileRowData> getAttachmentList(java.lang.String fieldName)
                                              throws lotus.domino.NotesException
Get the list of attachments for the field specified

Throws:
lotus.domino.NotesException

getEmbeddedImagesList

public java.util.List<FileRowData> getEmbeddedImagesList(java.lang.String fieldName)
                                                  throws lotus.domino.NotesException
Return the List of images attached to this Document

Throws:
lotus.domino.NotesException

removeAttachment

public boolean removeAttachment(java.lang.String fieldName,
                                java.lang.String attachmentName)
                         throws lotus.domino.NotesException
Remove an attachment associated with a field

Throws:
lotus.domino.NotesException

removeAllAttachments

public void removeAllAttachments(java.lang.String fieldName)
                          throws lotus.domino.NotesException
Remove all attachement from the specified field

Throws:
lotus.domino.NotesException

getRichTextItem

public DominoRichTextItem getRichTextItem(java.lang.String fieldName)
Get the RichTextItem for this field. Return null if the field is not a RichTextItem

Parameters:
fieldName -
Returns:

setRichTextItem

public void setRichTextItem(java.lang.String fieldName,
                            DominoRichTextItem drti)
Add this field name and its RichTextItem value o the list of RichTextsItems

Parameters:
fieldName -
drti -

beforeSerializing

public void beforeSerializing()
Serialization mechanism. Discards the wrapped object before serializing the data


afterDeserializing

public void afterDeserializing(com.ibm.xsp.model.domino.DominoDocumentDataContainer container)
Serialization mechanism. Empty method for now


getFieldAsXML

public org.w3c.dom.Document getFieldAsXML(java.lang.String fieldName,
                                          boolean readOnly)
                                   throws lotus.domino.NotesException,
                                          com.ibm.commons.xml.XMLException

DO NOT USE

Gets the content of a field as an in memory XML Document.

Parameters:
fieldName - the field that contains the XML as text
readOnly - indicates if the document is readonly. If so, the changes are not saved back with the document.
Throws:
lotus.domino.NotesException
com.ibm.commons.xml.XMLException

getAttachmentAsXML

public org.w3c.dom.Document getAttachmentAsXML(java.lang.String fieldName,
                                               java.lang.String attachmentName,
                                               boolean readOnly)
                                        throws lotus.domino.NotesException,
                                               com.ibm.commons.xml.XMLException
Gets the content of a field attachment as an in memory XML Document.

Parameters:
fieldName - the field that contains the XML as text
attachmentName - the attachment that contains the XML as text
readOnly - indicates if the document is readonly. If so, the changes are not saved back with the document.
Throws:
lotus.domino.NotesException
com.ibm.commons.xml.XMLException