commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kax <>
Subject Re: [Digester] Problems
Date Mon, 20 Dec 2004 15:18:48 GMT
Answering my own question:

I solved this by creating my own custom rules.

1. I created a class StatusCheckRule which is mapped to the */a:response/a:propstat/a:status
path. In this class I check the content of the status element and if contains "200 OK" I push
a Boolean object with a given name (digester.push("myName", obj)) to the digester stack with
the value true.

2. I created a class MyProjObjectCreateRule which is mapped to the */a:response/a:propstat/a:status
path. In the begin() method I check if the statusFlag has been set to true and if it has I
create my Appointment object and push it to the stack. In the end() method I call a method
(the method name is passed in the constructor of MyProjObjectCreateRule) on my parent class
by using MethodUtils (similar to how it's done in SetNextRule).

Everything works fine and I have no problems with setting attributes on my object etc. My
new question is if this is good approach or could I have solved differently?

Thanks in advance


> From: kax <>
> Date: 2004/12/20 må AM 10:39:48 GMT
> To: <>
> Ämne: [Digester] Problems
> Hello,
> The problem I have is not really with Digester, the problem is with the xml I have to
parse. I thought using Digester was a good approach and I still think it is but I need some
help to solve a problem I have.
> I receive xml which looks like this:
> <a:response>
> 	<a:href></a:href>
> 	<a:propstat>
> 		<a:status>HTTP/1.1 200 OK</a:status>
> 		<a:prop>
> 			<d:to>"Some Name" &lt;;, =?iso-8859-1</d:to>
> 			<e:subject>Meeting</e:subject>
> 			<f:dtstart b:dt="">2004-12-13T12:30:00.000Z</f:dtstart>
> 			<f:dtend b:dt="">2004-12-13T14:00:00.000Z</f:dtend>
> 			<f:location>Meeting room 4</f:location>
> 		</a:prop>
> 	</a:propstat>
> 	<a:propstat>
> 		<a:status>HTTP/1.1 404 Resource Not Found</a:status>
> 		<a:prop><e:textdescription/></a:prop>
> 	</a:propstat>
> </a:response>
> This is a response to a propstat question via webdav to Microsoft Exchange. What I want
to do is to create a new CalendarAppointment object everytime I run in to a <a:propstat>
element. But the problem is that if a property of the appointment is empty, like the <e:textdescription/>
above, a propstat element is included in the response and at this <a:propstat> element
I don't want to create another CalendarAppointment object. And I don't want to try setting
the properties of the element and I don't want to call the addAppointment method, see example
xml rule file below:
> <pattern value="*/a:prop">
> <object-create-rule classname="myClass"/>
> <call-method-rule pattern="e:subject" methodname="setSubject" paramcount="0"/>
> 		<call-method-rule pattern="e:textdescription" methodname="setText" paramcount="0"/>
> 		<call-method-rule pattern="f:location" methodname="setLocation" paramcount="0"/>
> <set-next-rule methodname="addAppointment"/>
> </pattern>
> A way to solve this would be to check the content of the <a:status> element. If
it contains 200 everything is ok and the object can be created, the properties can be set
and the addAppoinntment method could be called, otherwise not. Can I acheive this behaviour
with Digester?
> Thanks in advance
> /Kax
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message