Sunday, September 9, 2018

DFC - Upload a File

package dctm1;

import java.util.Scanner;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.IDfLoginInfo;

public class createdoc extends kavidoc{

public static void main(String[] args) throws DfException {
// TODO Auto-generated method stub

IDfClientX cx=new DfClientX();
IDfClient c=cx.getLocalClient();
IDfSessionManager sm=c.newSessionManager();
IDfLoginInfo login=cx.getLoginInfo();
login.setUser(uname);
login.setPassword(pwd);
sm.setIdentity(docbase, login);
IDfSession s=sm.getSession(docbase);
if(s!=null)
{
System.out.println("Session obtained succesfull");
System.out.println(s);

}
else
{
System.out.println("Login failed");
}
Scanner scan=new Scanner(System.in);
System.out.println("Enter the file name(pdf):");
String fname=scan.nextLine();
System.out.println("Enter the root folder:");
String rfolder=scan.nextLine();

IDfSysObject newobj=(IDfSysObject) s.newObject("dm_document");
newobj.setObjectName(fname);
newobj.setContentType("pdf");
newobj.setFile("c:\\test\\star.pdf");
newobj.link(rfolder);
newobj.save();
System.out.println("File upload completed");

}

}

No comments:

Post a Comment

ResourceBundle

package testJre; import java.util.ResourceBundle; public class testJre {  public static void main(String[] args) {   // TODO Auto-genera...