To create new Collaboration folders and documents from a remote application, use the IDocumentManager interface in the IDK.
| 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. |
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)
...