Step 1a: Creating the necessary document objects for the Portfolio

/* Creating a document object for the Navigator */ 
PortfolioDocument navDoc = new PortfolioDocument(); 
navDoc.setComment("Navigator document"); 
navDoc.setDesc("Navigator document"); 
navDoc.setDocContent(getDocumentContent()); 
navDoc.setDocReference(null); 
navDoc.setDocSource(DocumentSource.FILE); 
navDoc.setLcat(getCategoryObject("SubCategory",1)); 
navDoc.setUcat(getCategoryObject("MainCategory",0)); 
navDoc.setName("SampleNavigator");

getDocumentContent(String docSource) is a custom method, which returns the file content as a byte array.

getCategoryObject(String categoryName, int categoryType) is a custom method which returns the Category object.

Create the cover page document object "coverDoc".
/* Creating a document object from a Letter */ 
PortfolioDocument ltrDoc = new PortfolioDocument(); 
ltrDoc.setComment("Sample document"); 
ltrDoc.setDesc("Sample document"); 
ltrDoc.setDocContent(null); 
ltrDoc.setDocReference(getLetterID("SampleLetter",0)); 
ltrDoc.setDocSource(DocumentSource.LETTER); 
ltrDoc.setLcat(getCategoryObject("SubCategory",1)); 
ltrDoc.setUcat(getCategoryObject("MainCategory",0)); 
ltrDoc.setName("SampleDocFromLetter");

getLetterID(String LetterName, int State) is a custom method which returns the Letter ID.

Now, the document objects navDoc, coverDoc, and ltrDoc are created but are not yet persisted. To do so, use createDocument().

public PortfolioDocument createDocument(PortfolioDocument document)

This method takes in a document object and persists it. It returns a PortfolioDocument object with the ID with which it is referenced in the Content Space.

// Ethnio survey code removed