Creating a Document
This code creates a document in object store with Document class and file in a folder using Referential Containment Relationship
// Write the connection code here or click here to get the connection code
Domain domain = Factory.Domain.fetchInstance(connection, null, null);
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "your object store name", null);
Document doc = Factory.Document.createInstance(os, ClassNames.DOCUMENT);
doc.getProperties().putValue("DocumentTitle", "Your Document Title");
doc.set_MimeType("text/plain");
StorageArea sa = Factory.StorageArea.getInstance(os, new Id("{********-****-****-****-************}"));
doc.set_StorageArea(sa);
doc.save(RefreshMode.NO_REFRESH);
doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY,
CheckinType.MAJOR_VERSION);
doc.save(RefreshMode.NO_REFRESH);
get the folder object where you want to place the newly created document
Folder folder = Factory.Folder.getInstance(os, ClassNames.FOLDER,new Id("{********-****-****-****-************}") );
The below code will place the document in the folder
ReferentialContainmentRelationship rcr = folder.file(doc,
AutoUniqueName.AUTO_UNIQUE, "Adding New Document with Java Code",
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
rcr.save(RefreshMode.NO_REFRESH);
No comments:
Post a Comment