Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312928

Summary: [build] create Hudson JAXB model
Product: z_Archived Reporter: Markus Knittig <markus>
Component: MylynAssignee: Markus Knittig <markus>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: steffen.pingel
Version: unspecified   
Target Milestone: 0.7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
ant build
none
primary xml schema for Hudson
none
OSGi jaxb dependency
none
ant build steffen.pingel: iplog+

Description Markus Knittig CLA 2010-05-14 11:37:04 EDT
Generate a JAXB model from the Hudson XML schema for marshalling/unmarshalling to communication with the Hudson REST API.
Place build.xml, PrimaryView.xsd and jaxb-dependencies.zip in the root of org.eclipse.mylyn.hudson.core (this files don't need to be checked in). Then unpack the zip and execute the ant build. Apply the patch for the javax.xml.bind dependency.
The proposed package is org.eclipse.mylyn.hudson.internal.rest.model
Comment 1 Markus Knittig CLA 2010-05-14 11:38:00 EDT
Created attachment 168550 [details]
ant build
Comment 2 Markus Knittig CLA 2010-05-14 11:40:37 EDT
Created attachment 168552 [details]
primary xml schema for Hudson
Comment 3 Markus Knittig CLA 2010-05-14 11:42:15 EDT
Created attachment 168554 [details]
OSGi jaxb dependency
Comment 4 Markus Knittig CLA 2010-05-14 11:46:34 EDT
Dependecies for the ant build: http://knittig.de/temp/ant-dependencies.zip
Contains the following jars (all from public Maven repositories):
* jaxb-api-2.0.jar
* jaxb-impl-2.0.jar
* jaxb-xjc-2.0.jar
* stax-api-1.0.jar
* activation-1.1.jar
Comment 5 Markus Knittig CLA 2010-05-14 13:44:24 EDT
Created attachment 168572 [details]
ant build
Comment 6 Markus Knittig CLA 2010-05-14 13:45:32 EDT
Better replace 'model' with 'primaryview' since there are more than one schema for the Hudson API.
Comment 7 Steffen Pingel CLA 2010-05-17 21:49:29 EDT
Thanks. I was able to generate the source files locally but I'll need to check with the legal team if there are any concerns with committing the generated files to CVS. Can you take a look at http://download.eclipse.org/tools/orbit/downloads/drops/S20100514103823/ and let me know which of the Orbit bundles (e.g. com.sun.xml.bind) we would need? Do you have any experience with Apache JaxMe which is also available in Orbit?
Comment 8 Markus Knittig CLA 2010-05-18 03:13:51 EDT
(In reply to comment #7)
> Thanks. I was able to generate the source files locally but I'll need to check
> with the legal team if there are any concerns with committing the generated
> files to CVS. Can you take a look at
> http://download.eclipse.org/tools/orbit/downloads/drops/S20100514103823/ and
> let me know which of the Orbit bundles (e.g. com.sun.xml.bind) we would need?

com.sun.xml.bind, which is already used by Mylyn.

> Do you have any experience with Apache JaxMe which is also available in Orbit?

No, but since it's just another JAXB implementation, there shouldn't be much difference.
Comment 9 Steffen Pingel CLA 2010-05-18 18:20:18 EDT
Thanks. I have requested CQs for the 2.2 versions of the javax.xml.bind and com.sun.xml.bind Orbit bundles. Did you create the xsd yourself or did that come from Hudson? Can you post a short example what a repository connection through JAXB would look like?
Comment 10 Markus Knittig CLA 2010-05-19 17:44:53 EDT
(In reply to comment #9)
> Thanks. I have requested CQs for the 2.2 versions of the javax.xml.bind and
> com.sun.xml.bind Orbit bundles.

Ups, sorry, com.sun.xml.bind isn't needed, only javax.xml.bind.

> Did you create the xsd yourself or did that come from Hudson?

From Hudson (created by JAXB from the model I guess).

> Can you post a short example what a repository connection
> through JAXB would look like?

Like this (simplified):

        GetMethod jobsRequest = new GetMethod(hudsonUrl + "/api/xml");
        String response = httpClient.executeMethod(jobsRequest);

        JAXBContext ctx = JAXBContext.newInstance(HudsonModelHudson.class);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();

        JAXBElement<HudsonModelHudson> hudsonRoot = unmarshaller.unmarshal(new StringReader(response), HudsonModelHudson.class);
        HudsonModelHudson hudson = hudsonRoot.getValue();
Comment 11 Steffen Pingel CLA 2010-05-19 18:14:08 EDT
Thanks. Can you point me at the URL where you got the XSD? I need to verify if we can actually commit this to CVS or not.
Comment 12 Markus Knittig CLA 2010-05-20 02:25:06 EDT
(In reply to comment #11)
> Thanks. Can you point me at the URL where you got the XSD? I need to verify if
> we can actually commit this to CVS or not.

Well, they are available on every Hudson instance e.g. http://deadlock.netbeans.org/hudson/api/schema
Comment 13 Steffen Pingel CLA 2010-05-20 15:25:51 EDT
I see. Can you come up with a list of schemas and corresponding URLs that would be relevant to the Hudson integration? I would like to come up with a consistent schema for the namespaces, e.g.:
/hudson -> org.eclipse.mylyn.internal.hudson.core.model
/hudson/job -> org.eclipse.mylyn.internal.hudson.core.model.job

What are your thoughts on that?
Comment 14 Markus Knittig CLA 2010-05-24 17:26:52 EDT
(In reply to comment #13)
> I see. Can you come up with a list of schemas and corresponding URLs that would
> be relevant to the Hudson integration?

Not sure I missed a URL:
<baseurl>/api/schema -> needed
<baseurl>/queue/api/schema -> not sure, probably not for now
<baseurl>/overallLoad/api/schema -> not needed (at least for now)
<baseurl>/job/<jobname>/api/schema -> looks like all attributes are also included in the primary schema
<baseurl>/job/<jobname>/<buildnumber>/api/schema -> needed since some attributes are unique 
<baseurl>/people/api/schema -> not sure, but useful if we need a list of all people available
<baseurl>/computer/api/schema -> not needed for now
<baseurl>/computer/(<computername>)/api/schema -> not needed for now

> I would like to come up with a
> consistent schema for the namespaces, e.g.:
> /hudson -> org.eclipse.mylyn.internal.hudson.core.model
> /hudson/job -> org.eclipse.mylyn.internal.hudson.core.model.job
> 
> What are your thoughts on that?

We defintely need that. The "core" is missing in my suggested namespace. Also I'm not sure "rest" is the right prefix...
Comment 15 Steffen Pingel CLA 2010-05-27 16:06:55 EDT
Thanks. What confuses me slightly is the overlap models between the different schemas. In the end most things available under /job/api/schema are the same as what is available under /api/schema. Should we map all of that to the same Java package or does that need to go into different namespaces? 

I would like to make progress here to unblock you. I am thinking of mapping /hudson/api/schema to org.eclipse.mylyn.internal.hudson.core.model for now and then we can take it from there. Let me know if you want me to do something else.
Comment 16 Steffen Pingel CLA 2010-05-30 18:06:36 EDT
I have generated and committed code from the following schemas into a single package in the o.e.m.hudson.core plug-in as a start:

https://build.eclipse.org/hudson/api/schema
https://build.eclipse.org/hudson/people/api/schema
https://build.eclipse.org/hudson/job/epp-mpc-nightly/api/schema
https://build.eclipse.org/hudson/job/epp-mpc-nightly/62/api/schema

Marking resolved. We can reopen if additional schemas are needed or if it turns out that the different namespaces need to be in their own packages.