[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.ohf] Re: ProvideAndRegisterDocumentSetType --> OMElement

Hi Stefan,

Indeed this is --- kinda simple. So, one thing to start with is - when sending the payload to the registry from a repository, you will need to convert from the ProvideAndRegisterDocumentSetType back to an ebXML SubmitObjectsRequestType. Once you're back into that type, then you can submit to the repository.

The way we handle this in the XDS Source and XDS Consumer is straightforward. In general, it requires three things:

1. Convert the ProvideAndRegisterDocumentSetType (XDS) object to SubmitObjectsRequestType (ebXML) object
2. Convert the EMF-created SubmitObjectsRequestType object to a DOM object
3. Convert the DOM object to OM for use with Axis2.



Converting from ProvideAndRegisterDocumentSetType (XDS) object to SubmitObjectsRequestType (ebXML) object
---


For XDS.a:

EbXML_2_1ProvideAndRegisterDocumentSetTransformer setTransformer = new EbXML_2_1ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest = setTransformer.getSubmitReq()



For XDS.b:

EbXML_3_0ProvideAndRegisterDocumentSetTransformer setTransformer = new EbXML_3_0ProvideAndRegisterDocumentSetTransformer();
setTransformer.transform(prDocumentSetTypeObject);
SubmitObjectsRequestType submitObjectsRequest = setTransformer.getSubmitReq()




Converting from EMF to DOM
---
This conversion requires the creation of an empty DOM Document and then using the EMF XMLResource's "save" method to save EMF to DOM. Code snippet looks something like this:


// Create DOM Document Instance
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
org.w3c.dom.Document domDocument = builder.newDocument();

// Convert / "save" EMF to DOM
RegistryPackage packageInstance = RegistryPackage.eINSTANCE;
DocumentRoot root = RegistryFactory.eINSTANCE.createDocumentRoot();
root.setSubmitObjectsRequest(submitObjectsRequest);
XMLResource resource = (XMLResource)(new RegistryResourceFactoryImpl()).createResource(URI.createURI(RegistryPackage.eNS_URI));
resource.getContents().add(root);
resource.save(domDocument, new HashMap(), new DefaultDOMHandlerImpl());
resource.unload();


Element domElement = domDocument.getDocumentElement();



Converting from DOM to OM
---
Apache Axis provides a utility to convert from DOM to OM (and back).
Use this:

OMElement omElement = org.apache.axis2.util.XMLUtils.toOM(domElement);




The P&R element should now be "sendable" over the wire.

I put this together pretty fast, so I'm sure I missed something, but might give it a try!

-Matt



Stefan S. wrote:
Hi Everybody!

I have a very basic question - at least I hope it is basic ;) - that is bothering me for days now!

I have metadata - received by an ITI-15 request - in form of an ProvideAndRegisterDocumentSetType. Now I am changing and adding some specific attributes. As an example - just for testing - I am trying to add a XDSDocumentEntry.size to every DocumentEntryType with a simple loop like:

for (DocumentEntryType documentEntry : (EList<DocumentEntryType>)xdsMetadata.getDocumentEntry()) {
documentEntry.setSize("123456");
}


Now my problem is, that I want to send this "modified" metadata to an IHE Registry using ITI-14.
Therefore I have to convert this metadata -ProvideAndRegisterDocumentSetType - to an OMElement.


But I am really stuck on how to solve this problem.
I hope someone can help me!

Thanks in Advance for both your time and your knowledge!

Greetings
Stefan