import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.operations.IDfImportNode;
import com.documentum.operations.IDfImportOperation;
/**
*
*/
/**
* @author mpoli_fujitsu
*
*/
public class DeepImport {
//static String parentLocation="dfgdgdgdg";
/**
* @param args
* @throws DfException
*/
public static void main(String[] args) throws DfException {
System.out.println("dsfsdfsd");
File sourceLocation=new File("dfgdgdgd");
File targetLocation=new File("dfgdgdgdg");
try {
copyDirectory(sourceLocation , targetLocation );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void copyDirectory(File sourceLocation , File targetLocation) throws IOException, DfException {
if (sourceLocation.isDirectory()) {
//System.out.println("Folder exists sourece Locaion*********************"+targetLocation.getParent());
// System.out.println("Folder name_________________________________________"+targetLocation.getName());
// System.out.println("ParentFolder name_++++++++++++++++++++++++++++++++++++++"+targetLocation.getParent());
createFolder(targetLocation.getParent(),targetLocation.getName());
//targetLocation.mkdir();
String[] children = sourceLocation.list();
for (int i=0; i<children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
//System.out.println("Folder sourece Locaion*********************"+sourceLocation);
}
} else {
System.out.println("sourece Locaion*********************"+sourceLocation.getName());
IDfSessionManager sesMgr = getSessionMgr();
IDfSession session = sesMgr.getSession("EDMS");
IDfClientX _clientx = new DfClientX();
IDfImportOperation _opi = _clientx.getImportOperation();
_opi.setSession(session);
IDfFolder _folder = session.getFolderByPath((targetLocation.getParent()).replace('\\', '/'));
_opi.setDestinationFolderId(_folder.getObjectId());
IDfImportNode _impNode = (IDfImportNode) _opi.add(sourceLocation.toString());
if (_impNode == null)
System.out.println ("Node is null.");
_impNode.setDocbaseObjectType("qd_project_doc");
_impNode.setNewObjectName(sourceLocation.getName());
//_opi.setSession(_dfcSes);
//
if (_opi.execute())
{
IDfDocument _newObj = (IDfDocument) _impNode.getNewObject();
_newObj.setObjectName(sourceLocation.getName());
_newObj.setString("process_area_name","Lusail Project Management");
_newObj.setString("document_type_name","Letter");
//_newObj.setOwnerName(_OWNER);
String resultString =
("Item" + _opi.getNewObjects().toString() +" imported successfully.");
System.out.println(resultString);
}
else
{
System.out.println ("Error during import operation.");
}
/*IDfDocument newFolder = (IDfDocument) session.newObject("dm_document");
newFolder.setObjectName(sourceLocation.getName());
//.replace('\\', '/');
newFolder.link((targetLocation.getParent()).replace('\\', '/'));
newFolder.save();*/
}
}
private static IDfSessionManager getSessionMgr(){
IDfSessionManager sessionMgr = null;
try{
IDfClientX clientx = new DfClientX();
IDfClient client = clientx.getLocalClient();
sessionMgr = client.newSessionManager();
IDfLoginInfo loginInfoObj = clientx.getLoginInfo();
loginInfoObj.setUser("dmadmin");
loginInfoObj.setPassword("fgfdg");
sessionMgr.setIdentity("dfgdg", loginInfoObj);
}catch(DfException exp){
exp.printStackTrace();
}
return sessionMgr;
}
private static void createFolder(String edmsLocation,String folderName) throws DfException
{
System.out.println("edmsLocation*********************"+edmsLocation);
if(folderName.equalsIgnoreCase("Section - 3")){
System.out.println("Folder Name Washington Parcel A");
}else{
System.out.println("Folder name_________________________________________"+folderName);
IDfSessionManager sesMgr = getSessionMgr();
IDfSession session = sesMgr.getSession("EDMS");
IDfFolder newFolder = (IDfFolder) session.newObject("qd_folder");
newFolder.setObjectName(folderName);
//.replace('\\', '/');
newFolder.link(edmsLocation.replace('\\', '/'));
newFolder.save();
}
}
}
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.operations.IDfImportNode;
import com.documentum.operations.IDfImportOperation;
/**
*
*/
/**
* @author mpoli_fujitsu
*
*/
public class DeepImport {
//static String parentLocation="dfgdgdgdg";
/**
* @param args
* @throws DfException
*/
public static void main(String[] args) throws DfException {
System.out.println("dsfsdfsd");
File sourceLocation=new File("dfgdgdgd");
File targetLocation=new File("dfgdgdgdg");
try {
copyDirectory(sourceLocation , targetLocation );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void copyDirectory(File sourceLocation , File targetLocation) throws IOException, DfException {
if (sourceLocation.isDirectory()) {
//System.out.println("Folder exists sourece Locaion*********************"+targetLocation.getParent());
// System.out.println("Folder name_________________________________________"+targetLocation.getName());
// System.out.println("ParentFolder name_++++++++++++++++++++++++++++++++++++++"+targetLocation.getParent());
createFolder(targetLocation.getParent(),targetLocation.getName());
//targetLocation.mkdir();
String[] children = sourceLocation.list();
for (int i=0; i<children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
//System.out.println("Folder sourece Locaion*********************"+sourceLocation);
}
} else {
System.out.println("sourece Locaion*********************"+sourceLocation.getName());
IDfSessionManager sesMgr = getSessionMgr();
IDfSession session = sesMgr.getSession("EDMS");
IDfClientX _clientx = new DfClientX();
IDfImportOperation _opi = _clientx.getImportOperation();
_opi.setSession(session);
IDfFolder _folder = session.getFolderByPath((targetLocation.getParent()).replace('\\', '/'));
_opi.setDestinationFolderId(_folder.getObjectId());
IDfImportNode _impNode = (IDfImportNode) _opi.add(sourceLocation.toString());
if (_impNode == null)
System.out.println ("Node is null.");
_impNode.setDocbaseObjectType("qd_project_doc");
_impNode.setNewObjectName(sourceLocation.getName());
//_opi.setSession(_dfcSes);
//
if (_opi.execute())
{
IDfDocument _newObj = (IDfDocument) _impNode.getNewObject();
_newObj.setObjectName(sourceLocation.getName());
_newObj.setString("process_area_name","Lusail Project Management");
_newObj.setString("document_type_name","Letter");
//_newObj.setOwnerName(_OWNER);
String resultString =
("Item" + _opi.getNewObjects().toString() +" imported successfully.");
System.out.println(resultString);
}
else
{
System.out.println ("Error during import operation.");
}
/*IDfDocument newFolder = (IDfDocument) session.newObject("dm_document");
newFolder.setObjectName(sourceLocation.getName());
//.replace('\\', '/');
newFolder.link((targetLocation.getParent()).replace('\\', '/'));
newFolder.save();*/
}
}
private static IDfSessionManager getSessionMgr(){
IDfSessionManager sessionMgr = null;
try{
IDfClientX clientx = new DfClientX();
IDfClient client = clientx.getLocalClient();
sessionMgr = client.newSessionManager();
IDfLoginInfo loginInfoObj = clientx.getLoginInfo();
loginInfoObj.setUser("dmadmin");
loginInfoObj.setPassword("fgfdg");
sessionMgr.setIdentity("dfgdg", loginInfoObj);
}catch(DfException exp){
exp.printStackTrace();
}
return sessionMgr;
}
private static void createFolder(String edmsLocation,String folderName) throws DfException
{
System.out.println("edmsLocation*********************"+edmsLocation);
if(folderName.equalsIgnoreCase("Section - 3")){
System.out.println("Folder Name Washington Parcel A");
}else{
System.out.println("Folder name_________________________________________"+folderName);
IDfSessionManager sesMgr = getSessionMgr();
IDfSession session = sesMgr.getSession("EDMS");
IDfFolder newFolder = (IDfFolder) session.newObject("qd_folder");
newFolder.setObjectName(folderName);
//.replace('\\', '/');
newFolder.link(edmsLocation.replace('\\', '/'));
newFolder.save();
}
}
}
No comments:
Post a Comment