Saturday, May 15, 2021

Add document to FileNet

Steps:

//Get CE Connection

//Create Subject

//Push Subject

//Get Domain (domain)
 //Get Folder
 //Get the File details
// Create Document
//Check-in the doc
////Set document properties 
//Save document and file into a folder

ObjectStore os = null;
objectStoreName = "OSName"

os = Factory.ObjectStore.fetchInstance(domain, objectStoreName, null); 

Folder folder=null;
folderName = ''/Folder1";
folder=Factory.Folder.fetchInstance(os, folderName, null); 


InputStream inputFile = "";
String inputFileName = "";
int fileSize = "";
 
String docClass = "dcument class name";
Document document = Factory.Document.createInstance(os, docClass); 

if (inputFile != null && fileSize > 0) {
                        ContentTransfer contentTransfer = Factory.ContentTransfer.createInstance();
                        contentTransfer.setCaptureSource(file);
                        contentElementList.add(contentTransfer);
                        doc.set_ContentElements(contentElementList);
                        contentTransfer.set_RetrievalName(
inputFileName );                       
                        
document .set_MimeType(getMimetype(inputFileName ));
                    }
                   


document.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY,CheckinType.MAJOR_VERSION);                   

String documentName ="";

Properties prop = doc.getProperties();
p.putValue("DocumentTitle","Sample File");
p.putValue("Author","Iron Man");
p.putValue("Contact Number","007"); 

              

doc.save(RefreshMode.REFRESH);


 ReferentialContainmentRelationship rc = folder.file(doc,
                                    AutoUniqueName.AUTO_UNIQUE,
                                    documentName,
                                    DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);

 rc.save(RefreshMode.REFRESH);

No comments:

Post a Comment