Hi, I'm new :)
I am trying to do a proof of concept for the download of a file by MTOM.
I have launched the commands to download the code:
wsdl2java -o C:\temp\documentum\dfc.6.7 -d jaxbri -uri http://url:port/services/core/runtime/ContextRegistryService?wsdl
wsdl2java -o C:\temp\documentum\dfc.6.7 -d jaxbri -uri http://url:port/services/core/VersionControlService?wsdl
wsdl2java -o C:\temp\documentum\dfc.6.7 -d jaxbri -uri http://url:por/services/core/QueryService?wsdl
wsdl2java -o C:\temp\documentum\dfc.6.7 -d jaxbri -uri http://url:por/services/core/ObjectService?wsdl
wsdl2java -o C:\temp\documentum\dfc.6.7 -d jaxbri -uri http://url:por/services/core/SchemaService?wsdl
Once imported into my project, and creating the contextFactory I don't have the ContextFactory class,
I can't import ContextFactory and IServiceContext, is there any other service for this? What do I need?
ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext serviceContext = contextFactory.newContext();
In the example of downloading a file, who is the m_servicePort?
I can't import the ObjectService .. !!
String objectServiceURL = "url" + "/core/ObjectService";
ObjectService objectService = new ObjectService(new URL(objectServiceURL),
new QName("http://core.services.fs.documentum.emc.com/","ObjectService"));
servicePort = objectService.getObjectServicePort(new MTOMFeature());
// EMC Documentum Foundation Services Version 6.7 Development Guide, pag 49
public IServiceContext getSimpleServiceContext(String repositoryName, String userName, String password)
{
ContextFactory contextFactory = ContextFactory.getInstance();
IServiceContext context = contextFactory.newContext();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.setRepositoryName(repositoryName);
repoId.setUserName(userName);
repoId.setPassword(password);
context.addIdentity(repoId);
return context;
}
// EMC Documentum Foundation Services Version 6.7 Development Guide, pag 168
//example of downloading a file by MTOM
public File getContentAsFile(ObjectIdentity objectIdentity, File targetFile)
throws IOException, SerializableException {
ObjectIdentitySet objectIdentitySet = new ObjectIdentitySet();
objectIdentitySet.getIdentities().add(objectIdentity);
ContentTransferProfile contentTransferProfile = new ContentTransferProfile();
contentTransferProfile.setTransferMode(ContentTransferMode.MTOM);
ContentProfile contentProfile = new ContentProfile();
contentProfile.setFormatFilter(FormatFilter.ANY);
OperationOptions operationOptions = new OperationOptions();
operationOptions.getProfiles().add(contentTransferProfile);
operationOptions.getProfiles().add(contentProfile);
DataPackage dp = m_servicePort.get(objectIdentitySet, operationOptions);
Content content = dp.getDataObjects().get(0).getContents().get(0);
OutputStream os = new FileOutputStream(targetFile);
if (content instanceof UrlContent) {
// Handle URL content -- see following section
} else if (content instanceof BinaryContent) {
BinaryContent binaryContent = (BinaryContent) content;
os.write(binaryContent.getValue());
} else if (content instanceof DataHandlerContent) {
DataHandlerContent dataHandlerContent = (DataHandlerContent) content;
InputStream inputStream = dataHandlerContent.getValue().getInputStream();
if (inputStream != null) {
int byteRead;
while ((byteRead = inputStream.read()) != -1) {
os.write(byteRead);
}
inputStream.close();
}
}
os.close();
return targetFile;
}