Hi All,
We developed DFS client code to connect to documentum server and get the files to local system.
But we are facing few problems in this code. When we are trying to get the contents of the data object using thisDataObject.getContents() , it is returning an empty list, even though we have files and also we are getting the repository name as null using the dataPackage.getRepositoryName() .
Following are documentum account details
Repository- edsDmDev
WSDL URL - http:// srvname:9070/services/core/ObjectService?WSDLWhen we log in we will be in the folder called: \Publisher\Transfer.
FileName: FolderOfTransactionFilesForAI (.doc file , an word document)
Actually we are trying to get the contents of .doc file, but if we try to read the content of .txt file we are getting an exception.
I pasted code below, can you please guide us in solving this issue.
public class DFS
{
ContextFactory ctFactory;
public static IServiceContext getSimpleServiceContext(
String repositoryName, String userName, String password) {
// create a ServiceContext
System.out.println("Creating ContextFactory");
ContextFactory contextFactory = ContextFactory.getInstance();
System.out.println("Creating ServiceContext");
IServiceContext context = contextFactory.newContext();
System.out.println("Creating RepositoryIdentity");
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(repositoryName);
repoId.setUserName(userName);
repoId.setPassword(password);
context.addIdentity(repoId);
return context;
}
public static void main(String[] args)
{
String moduleName = "core";
String contextRoot ="http://srvname:8070/services";
String repository = "edsDmDev";
String user = "usr";
String password = "pwd";
try
{
// Get a ContextFactory
IServiceContext iSrvContext = getSimpleServiceContext(repository,user,password);
ServiceFactory serviceFactory = ServiceFactory.getInstance();
IQueryService querySvc =
serviceFactory.getRemoteService(IQueryService.class, iSrvContext,
moduleName, contextRoot);
System.out.println("Creating ObjectService");
IObjectService objectService = ServiceFactory.getInstance().getRemoteService(IObjectService.class,
iSrvContext,
moduleName,
contextRoot);
String query="dm_document where object_name like 'TransactionFilesForAI%'";
System.out.println("Creating qualification");
Qualification qualification = new Qualification(query);
System.out.println("Creating ObjectIdentity");
ObjectIdentity targetObjectIdentity = new ObjectIdentity(qualification, repository);
ObjectIdentitySet objIdSet = new ObjectIdentitySet();
objIdSet.addIdentity(targetObjectIdentity);
ContentProfile contentProfile = new ContentProfile();
contentProfile.setFormatFilter(FormatFilter.SPECIFIED);
// contentProfile.setFormat("pdf");
// contentProfile.setContentReturnType(FileContent.class);
// Create an empty OperationOptions object
OperationOptions opts = new OperationOptions();
opts.setContentProfile(contentProfile);
opts.setProfile(contentProfile);
DataPackage dataPackage = new DataPackage();
System.out.println("Getting dataPackage from objectService");
dataPackage = objectService.get(objIdSet, opts);
System.out.println("DataPackage Repo Name: "+dataPackage.getRepositoryName()); // returns
// null
java.util.List dataObjsList=dataPackage.getDataObjects();
System.out.println("DataList length= " +dataObjsList.size() ); // length
// =1
// Iterate through the DataObject objects in the result DataPackage
Iterator iterator = dataObjsList.iterator();
PropertySet properties = new PropertySet();
while(iterator.hasNext()){
System.out.println("######## GETTING OBJECT PROPERTIES #########");
DataObject thisDataObject = (DataObject) iterator.next();
// Write out some properties for this DataObject
properties = thisDataObject.getProperties();
String dataObjName=properties.get("object_name").getValueAsString();
System.out.println("Object Name: " + dataObjName ); // name without
// ext
System.out.println("Object identity: " + thisDataObject.getIdentity().getValueAsString()); // objid
if(thisDataObject.getContents().isEmpty())
System.out.println("Object is empty"); // /prints obj is empty
else{
Content resultContent = (Content)thisDataObject.getContents().get(0);
if (resultContent.canGetAsFile())
{
System.out.println("Getting file content as a file");
File file = resultContent.getAsFile();
System.out.println("File exists: " + file.exists());
System.out.println("file path-"+file.getCanonicalPath());
}
if(resultContent.canGetAsByteArray()) {
System.out.println("This content can be fetched a Byte Array");
byte byteContent[] = resultContent.getAsByteArray();
System.out.println("Byte Content is ---"+byteContent.length);
System.out.println("Byte Content is ---"+byteContent.toString());
}
if(resultContent.canGetAsUcfPackageInfo()) {
System.out.println("This content can be fetched a UCF Package");
}
}
}
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Thanks,
Suresh