AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating Collaboration Folders and Documents Using IDK Remote APIs

To create new Collaboration folders and documents from a remote application, use the IDocumentManager interface in the IDK.

The IDocumentManager interface allows you to create new folders, subfolders and documents. The IDocumentManager interface also allows you to copy existing documents and folders to target folders in any project.
  • To create a new folder, create it and insert it into an existing folder. The insertNewFolder method takes in the target parent folder, the new folder, and an optional third parameter to set the new folder to inherit security from the parent folder.
  • To create a new document, create it and insert it into an existing folder. The parameters in the insertNewDocument method allow you to set the following properties:
    Check in comment Required. A string that will be added as the first check in comment for the new document.
    Input stream Required. An InputStream from which the contents of the new document can be read.
    Language The ISO 639-1 language code for the content in the document (for example, "en" for english). If null, the language is set to that of the current user.
    Inherit security If set to true, the new document will inherit security from the parent folder.
    Note: If there is already a document or subfolder in the parent folder with the same name as a supplied document, the name of the newly inserted document will be changed. For example, if a document is submitted with a name of report.doc and a file with this name already exists, the name of the new file will be changed to report_1.doc (or report_2.doc if report_1.doc also already exists). You can check the name of the returned IDocument to see if it differs from the name in the document parameter.
  • To copy a folder or document, use the IDocumentManager.copyToFolder method and pass in the source folder, target folder, and document(s) or folder(s) to copy.
  • To create a new folder or document, follow the steps below.
  1. Create a PRC session. This example retrieves a login token using the IPortletContext; you can also use IRemoteSession. (For details, see Initiating a PRC Session to Use IDK Remote APIs.)
  2. Get the IDocumentManager.
  3. Get the ID of the parent folder. To insert a folder or document at the root level, get the top level document folder for the project using getTopLevelFolder.
  4. Create the folder or document and insert it in the parent folder as shown in the code samples below.
These examples create a new folder in the top level folder and a new document in the new folder.

Java

...

IRemoteSession remoteSession = portletContext.getRemotePortalSession();
IDocumentManager documentManager = remoteSession.getCollaborationFactory().getDocumentManager();

//get top level folder in project to create new root folder
topLevelFolder = documentManager.getTopLevelFolder(containingProject);

//create a new folder
newFolder = documentManager.createNewFolder("Example Name", "Example Description");

//insert the folder, set to inherit security from the top level folder
IDocumentFolder storedFolder = documentManager.insertNewFolder(topLevelFolder, newFolder, true);

//create the document
IDocument newDocument = documentManager.createNewDocument("Example Document Name", "Example Document Description");

//set additional properties before inserting the document or they will not be persisted
newDocument.setAuthor("joe bloggs");
newDocument.setContentType("text/vnd.ms-word");

//open an inputstream for the document contents
InputStream fileInputStream = new FileInputStream("c:\\report.doc");

//insert the document, inheriting the containing folder's security
documentManager.insertNewDocument(storedFolder, newDocument, "initial check-in", fileInputStream, "en", true);

...

.NET (C#)

...

remoteSession = portletContext.GetRemotePortalSession();
documentManager = remoteSession.GetCollaborationFactory().GetDocumentManager();

//get the top level folder for the project to create a root folder
IDocumentFolder rootFolder = documentManager.GetTopLevelFolder(project);

//create a new folder
IDocumentFolder newFolder = documentManager.CreateDocumentFolder("Example Name", "Example Description");

//insert the new folder into the top level folder, set to inherit security 
IDocumentFolder storedFolder = documentManager.InsertNewFolder(topLevelFolder, newFolder,true);

//create the document
IDocument newDocument = documentManager.CreateNewDocument("Example Document Name", "Example Document Description");

//set additional properties before inserting the document or they will not be persisted
newDocument.Author = "joe bloggs";
newDocument.ContentType = "text/vnd.ms-word";

//open a Stream for the document contents
Stream fileInputStream = new FileStream("c:\\report.doc");

//insert the document, set to inherit security from the parent folder
documentManager.InsertNewDocument(storedFolder, newDocument, "initial check-in", fileInputStream, "en", true);

...

.NET (VB)

...

dim documentManager As IDocumentManager
dim remoteSession As Plumtree.Remote.PRC.IRemoteSession
remoteSession = portletContext.GetRemotePortalSession()
documentManager = remoteSession.GetCollaborationFactory().GetDocumentManager()

'get the top level folder for the project to create a root folder
dim rootFolder As IDocumentFolder = documentManager.GetTopLevelFolder(project)

'create the new folder
dim newFolder As IDocumentFolder = documentManager.CreateDocumentFolder("Example Name", "Example Description")

'Insert the new folder into the top level folder, set to inherit security 
dim storedFolder As IDocumentFolder = documentManager.InsertNewFolder(topLevelFolder, newFolder, true)

'create the document
dim newDocument As IDocument = documentManager.CreateNewDocument("Example Document Name", "Example Document Description")

'set additional properties before inserting the document or they will not be persisted
newDocument.Author = "joe bloggs"
newDocument.ContentType = "text/vnd.ms-word"

'open a Stream for the document contents
dim fileInputStream as Stream = new FileStream("c:\\report.doc")

'insert the document, set to inherit security from the parent folder
documentManager.InsertNewDocument(storedFolder, newDocument, "initial check-in", fileInputStream, "en", true)

...

  Back to Top      Previous Next