/**
*
*/
package dfs;
import java.awt.Desktop;
import java.io.File;
import java.util.List;
import com.emc.documentum.fs.datamodel.core.DataObject;
import com.emc.documentum.fs.datamodel.core.DataPackage;
import com.emc.documentum.fs.datamodel.core.ObjectId;
import com.emc.documentum.fs.datamodel.core.ObjectIdentity;
import com.emc.documentum.fs.datamodel.core.ObjectIdentitySet;
import com.emc.documentum.fs.datamodel.core.OperationOptions;
import com.emc.documentum.fs.datamodel.core.content.Content;
import com.emc.documentum.fs.datamodel.core.content.ContentTransferMode;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.datamodel.core.profiles.ContentProfile;
import com.emc.documentum.fs.datamodel.core.profiles.ContentTransferProfile;
import com.emc.documentum.fs.datamodel.core.profiles.FormatFilter;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.emc.documentum.fs.services.core.client.IObjectService;
import com.emc.documentum.fs.services.core.client.IQueryService;
/**
* @author mpoli_fujitsu
*
*/
public class DownloadFileFromEDMS {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
SimpleContentTransfer();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static String repository = "XXXX";
private static String userName = "XXXX"; //superadmin
private static String password = "XXXX"; //superadmin
private static String address = "http://abcdfg:9080/services";
private static String moduleName = "core";
private static IServiceContext servicecontext;
private static IObjectService objectService;
private static IQueryService queryService;
public static void SimpleContentTransfer() throws Exception
{
try
{
ContextFactory contextfact= ContextFactory.getInstance();
IServiceContext seriveContext=contextfact.newContext();
RepositoryIdentity repid=new RepositoryIdentity();
repid.setRepositoryName(repository);
repid.setPassword(password);
repid.setUserName(userName);
seriveContext.addIdentity(repid);
ServiceFactory serviceFactory = ServiceFactory.getInstance();
objectService = serviceFactory.getRemoteService(IObjectService.class,seriveContext, moduleName, address);
OperationOptions operationOptions = new OperationOptions();
ObjectId oid = new ObjectId("09021e3c80036e0c");
ObjectIdentitySet objectIdSet = new ObjectIdentitySet();
objectIdSet.addIdentity(new ObjectIdentity(oid, repository));
List<ObjectIdentity> objIdList = objectIdSet.getIdentities();
ContentTransferProfile contenttransfer = new ContentTransferProfile();
contenttransfer.setTransferMode(ContentTransferMode.MTOM);
ContentProfile contentprofile = new ContentProfile();
contentprofile.setFormatFilter(FormatFilter.ANY);
OperationOptions op1 = new OperationOptions();
System.out.println("sfsdfsd");
op1.setContentTransferProfile(contenttransfer);
op1.setContentProfile(contentprofile);
DataPackage dp = objectService.get(objectIdSet, op1);
DataObject dataObject = dp.getDataObjects().get(0);
Content resultContent = dataObject.getContents().get(0);
if (resultContent.canGetAsFile())
{
File file=new File(resultContent.getAsFile().toString());
file.createNewFile();
Desktop.getDesktop().open(file);
System.out.println(resultContent.getFormat());
}
}
catch (Exception ex)
{
throw ex;
}
}
}
*
*/
package dfs;
import java.awt.Desktop;
import java.io.File;
import java.util.List;
import com.emc.documentum.fs.datamodel.core.DataObject;
import com.emc.documentum.fs.datamodel.core.DataPackage;
import com.emc.documentum.fs.datamodel.core.ObjectId;
import com.emc.documentum.fs.datamodel.core.ObjectIdentity;
import com.emc.documentum.fs.datamodel.core.ObjectIdentitySet;
import com.emc.documentum.fs.datamodel.core.OperationOptions;
import com.emc.documentum.fs.datamodel.core.content.Content;
import com.emc.documentum.fs.datamodel.core.content.ContentTransferMode;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.datamodel.core.profiles.ContentProfile;
import com.emc.documentum.fs.datamodel.core.profiles.ContentTransferProfile;
import com.emc.documentum.fs.datamodel.core.profiles.FormatFilter;
import com.emc.documentum.fs.rt.context.ContextFactory;
import com.emc.documentum.fs.rt.context.IServiceContext;
import com.emc.documentum.fs.rt.context.ServiceFactory;
import com.emc.documentum.fs.services.core.client.IObjectService;
import com.emc.documentum.fs.services.core.client.IQueryService;
/**
* @author mpoli_fujitsu
*
*/
public class DownloadFileFromEDMS {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
SimpleContentTransfer();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static String repository = "XXXX";
private static String userName = "XXXX"; //superadmin
private static String password = "XXXX"; //superadmin
private static String address = "http://abcdfg:9080/services";
private static String moduleName = "core";
private static IServiceContext servicecontext;
private static IObjectService objectService;
private static IQueryService queryService;
public static void SimpleContentTransfer() throws Exception
{
try
{
ContextFactory contextfact= ContextFactory.getInstance();
IServiceContext seriveContext=contextfact.newContext();
RepositoryIdentity repid=new RepositoryIdentity();
repid.setRepositoryName(repository);
repid.setPassword(password);
repid.setUserName(userName);
seriveContext.addIdentity(repid);
ServiceFactory serviceFactory = ServiceFactory.getInstance();
objectService = serviceFactory.getRemoteService(IObjectService.class,seriveContext, moduleName, address);
OperationOptions operationOptions = new OperationOptions();
ObjectId oid = new ObjectId("09021e3c80036e0c");
ObjectIdentitySet objectIdSet = new ObjectIdentitySet();
objectIdSet.addIdentity(new ObjectIdentity(oid, repository));
List<ObjectIdentity> objIdList = objectIdSet.getIdentities();
ContentTransferProfile contenttransfer = new ContentTransferProfile();
contenttransfer.setTransferMode(ContentTransferMode.MTOM);
ContentProfile contentprofile = new ContentProfile();
contentprofile.setFormatFilter(FormatFilter.ANY);
OperationOptions op1 = new OperationOptions();
System.out.println("sfsdfsd");
op1.setContentTransferProfile(contenttransfer);
op1.setContentProfile(contentprofile);
DataPackage dp = objectService.get(objectIdSet, op1);
DataObject dataObject = dp.getDataObjects().get(0);
Content resultContent = dataObject.getContents().get(0);
if (resultContent.canGetAsFile())
{
File file=new File(resultContent.getAsFile().toString());
file.createNewFile();
Desktop.getDesktop().open(file);
System.out.println(resultContent.getFormat());
}
}
catch (Exception ex)
{
throw ex;
}
}
}
No comments:
Post a Comment