Creating a document object

The Document object can be created by using the constructor of the PortfolioDocument, as specified below:
public PortfolioDocument(String id, String name, String desc, String comment, int state, DocumentSource docSource, byte[] docContent, String docReference, Category ucat, Category lcat, int version, Date activeStartDate, Date activeEndDate, String lastChangeBy, String mimeType)

An alternative is to use the setter methods of the PortfolioDocument to set the different properties of the object.

A portfolio document can either be a document from a File or from the Correspondence Letter that was created in the CM system. A few parameters in the PortfolioDocument class enable us to create either of the two.

The following are the parameters which specify what type of Document object is being created:
  • DocumentSource: Specifies whether the document object is created from a File or from a Letter. Thus, it can either take the value DocumentSource.FILE or DocumentSource.LETTER

  • DocumentReference: If the DocumentSource is a File, then set it to Null. Otherwise set the new document object’s letter ID.

  • DocumentContent: Specifies the content of the document for which the object is being created. If the DocumentSource is a File, then it is the byte array of the PDF file. If the DocumentSource is letter, then this parameter is set to Null.

The following code snippet illustrates how the portfolioDocument can be created using the latter:
PortfolioDocument doc = new PortfolioDocument(); 
doc.setComment("Sample document"); 
doc.setDesc("Sample document"); 
doc.setDocContent(getdocumentContent()); 
doc.setDocReference(null); 
doc.setDocSource(DocumentSource.FILE); 
doc.setLcat(subCategoryObject); 
doc.setUcat(categoryObject); 
doc.setName(documentName);

While creating the Portfolio, organize the Documents in a folder structure and create the PortfolioFolder object.

Similar to the portfolioDocument, either use the constructor, or use the different setter methods.
public PortfolioFolder(String id, String name, String desc, List<PortfolioFolder> subFolders,List<PortfolioDocument> documents)

Finally, the portfolio object is created using the Folder objects and the Document objects and also references the other managed assets of CM.

public Portfolio(String id, String name, String desc, String comment, int state, Category ucat, Category lcat, int version,Date activeStartDate, Date activeEndDate, String lastChangeBy, PortfolioDocument navigator, PortfolioDocument cover,PortfolioFolder rootFolder)
There are a couple of special documents that are mentioned above in the Portfolio constructor.
  • Navigator: The Document Object is created using Adobe's special file format (.nav) for navigating the portfolio

  • Cover Page: The Document Object which is set as the Portfolio's cover page.

Note: It is mandatory to have the Navigator, Cover page, and a source Document while creating the Portfolio.

// Ethnio survey code removed