Sunday, 9 September 2018

DFC - New Folder Creation

package dctm1;

import java.util.Scanner;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfFolder;
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 testsession 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 Folder Name:");
String fol=scan.nextLine();
System.out.println("Enter the Root Folder");
String rfol=scan.nextLine();


//Check if Folder exist

//Target Folder
String tfolder=rfol+"/"+fol;
IDfFolder target=s.getFolderByPath(rfol+"/"+fol);
if (target!=null)

System.out.println("Folder "+tfolder+" already exist");
}
else
{


IDfSysObject obj=(IDfFolder) s.newObject("dm_folder");
obj.setObjectName(fol);
obj.link(rfol);
obj.save();
System.out.println("Folder Created");

}

}

}


//////

Session obtained succesfull
com.documentum.fc.client.DfSession@f5da06
Enter Folder Name:
2018
Enter the Root Folder
/Ramesh/sales
Folder Created

////




No comments:

Post a Comment