esme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Imtiaz Ahmed H E" <in.imt...@gmail.com>
Subject Re: Metadata handling (was "Release planning")
Date Sat, 24 Jul 2010 17:21:13 GMT
Hi,

I have made a few, not inappropriate, changes, all small one line ones in 
UserActor.scala, Distributor.scala, API2.scala, Message.scala, 
XmlHelper.scala.
The curl output with these in place follows at the end of this mail These 
fix the problems but do not remove entity encoding..

Ethan,

1. I thought, maybe, since both the addMsg and getNewMsgs API2 calls return 
an XML response, the 'innards' of that xml should be entity encoded. That's 
what happens naturally in Scala's xml handling and I have left it as such. 
*Please confirm that we need to decode that.*  I mean, ver generally 
speaking, the metadata, though outputted as XML, can be in any format, JSON 
included, and we 'don't know' about it. I mean the user could have his own 
convention, or maybe we can enforce it, of enclosing the entire metadata 
string in a specifically named tag, such as <json> to describe its format, 
which the user then needs to entity-decode, before interpreting it. I could 
be wrong here...

2. The extra <metadata></metadata> tag doesn't append anymore.

3. There was another problem, if you will look again at the curl output text 
file I attached with my patch attached previously to the Jira ticket, 
metadata input of JSON alone without surounding xml tags was 'lost'. The 
output showed empty metadata. This is fixed, but as I said, the JSON, since 
it is enclosed in a <metadata></metadata> tag is entity-encoded.

Let me know....and I will submit a patch to the metadata branch 
appropriately.

imtiaz@imtiaz-20100131 ~
$ cd /cygdrive/d/temp

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ curl --dump-header headers -d "token=HEZTQKM525SAMIPN4EDVRUOGHI40AKBL " 
http:
//localhost:8080/esme-server-apache-esme-1.0-RC1-incubating/api2/session
<?xml version="1.0" encoding="UTF-8"?>
<api><session><user><id>3</id><nickname>imtiaz2</nickname><image>None</image><wh
ole_name>I A 2 H E</whole_name></user></session></api>

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ cat headers
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=27318D34A3AC46BCD3EFC54B112F9123; 
Path=/esme-server-apach
e-esme-1.0-RC1-incubating
Expires: Sat, 24 Jul 2010 16:44:42 UTC
Date: Sat, 24 Jul 2010 16:44:41 GMT
Pragma: no-cache
Cache-Control: no-cache; private; no-store
X-Lift-Version: 2.0-SNAPSHOT
Content-Type: text/xml;charset=utf-8
Content-Length: 178


imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ \curl -b headers -d 
'message=test221&metadata=<outer><meta><metameta>Hello</m
etameta></meta><onlymeta>Meta</onlymeta></outer>' 
http://localhost:8080/esme-se
rver-apache-esme-1.0-RC1-incubating/api2/user/messages
<?xml version="1.0" encoding="UTF-8"?>
<api><message>
  <id>62</id>
  <date>Sat, 24 Jul 2010 16:45:03 UTC</date>
  <source>api2</source>
  <body>test221</body>
  <metadata><outer><meta><metameta>Hello</metameta></meta><onlymeta>Meta</onlyme
ta></outer></metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
</message></api>

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ curl -b headers -d 
'message=test222&metadata=<anytag>"meta":[{"place":{"place
_type":"city","region":"CA+"}},{"song":{"artist":"Prince","songtitle":"Never+Le
t+Me+Down"}}]</anytag>' 
http://localhost:8080/esme-server-apache-esme-1.0-RC1-i
ncubating/api2/user/messages
<?xml version="1.0" encoding="UTF-8"?>
<api><message>
  <id>63</id>
  <date>Sat, 24 Jul 2010 16:45:26 UTC</date>
  <source>api2</source>
  <body>test222</body>
  <metadata><anytag>&quot;meta&quot;:[{&quot;place&quot;:{&quot;place_type&quot;
:&quot;city&quot;,&quot;region&quot;:&quot;CA 
&quot;}},{&quot;song&quot;:{&quot;
artist&quot;:&quot;Prince&quot;,&quot;songtitle&quot;:&quot;Never
Let Me 
Down&qu
ot;}}]</anytag></metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
$

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ curl -b headers -d 
'message=test223&metadata="meta":[{"place":{"place_type":"
city","region":"CA+"}},{"song":{"artist":"Prince","songtitle":"Never+Let+Me+Dow
n"}}]' 
http://localhost:8080/esme-server-apache-esme-1.0-RC1-incubating/api2/us
er/messages
<?xml version="1.0" encoding="UTF-8"?>
<api><message>
  <id>64</id>
  <date>Sat, 24 Jul 2010 16:45:42 UTC</date>
  <source>api2</source>
  <body>test223</body>
  <metadata>&quot;meta&quot;:[{&quot;place&quot;:{&quot;place_type&quot;:&quot;c
ity&quot;,&quot;region&quot;:&quot;CA 
&quot;}},{&quot;song&quot;:{&quot;artist&q
uot;:&quot;Prince&quot;,&quot;songtitle&quot;:&quot;Never Let Me 
Down&quot;}}]</
metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
</message></api>

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$ curl -b headers 
http://localhost:8080/esme-server-apache-esme-1.0-RC1-incubat
ing/api2/user/messages
<?xml version="1.0" encoding="UTF-8"?>
<api><messages><message>
  <id>64</id>
  <date>Sat, 24 Jul 2010 16:45:42 UTC</date>
  <source>api2</source>
  <body>test223</body>
  <metadata>&quot;meta&quot;:[{&quot;place&quot;:{&quot;place_type&quot;:&quot;c
ity&quot;,&quot;region&quot;:&quot;CA 
&quot;}},{&quot;song&quot;:{&quot;artist&q
uot;:&quot;Prince&quot;,&quot;songtitle&quot;:&quot;Never Let Me 
Down&quot;}}]</
metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
</message><message>
  <id>63</id>
  <date>Sat, 24 Jul 2010 16:45:26 UTC</date>
  <source>api2</source>
  <body>test222</body>
  <metadata><anytag>&quot;meta&quot;:[{&quot;place&quot;:{&quot;place_type&quot;
:&quot;city&quot;,&quot;region&quot;:&quot;CA 
&quot;}},{&quot;song&quot;:{&quot;
artist&quot;:&quot;Prince&quot;,&quot;songtitle&quot;:&quot;Never
Let Me 
Down&qu
ot;}}]</anytag></metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
</message><message>
  <id>62</id>
  <date>Sat, 24 Jul 2010 16:45:03 UTC</date>
  <source>api2</source>
  <body>test221</body>
  <metadata><outer><meta><metameta>Hello</metameta></meta><onlymeta>Meta</onlyme
ta></outer></metadata>
  <author><nickname>imtiaz2</nickname><id>3</id></author>
  <tags></tags><replyto></replyto><conversation></conversation>
</message></messages></api>

imtiaz@imtiaz-20100131 /cygdrive/d/temp
$


Imtiaz

----- Original Message ----- 
From: "Ethan Jewett" <esjewett@gmail.com>
To: <esme-dev@incubator.apache.org>
Sent: Friday, July 23, 2010 7:23 PM
Subject: Re: Metadata handling (was "Release planning")


Done. The commit email should show up in a few minutes.

@Imtiaz - I also committed (separately) changes to the two failing
unit tests for the metadata issue on the metadata branch. You can run
the unit tests by doing "mvn test" or "mvn clean test", the same way
you would do "mvn jetty:run".

The two remaining problems as far as I can tell:

1. Response is HTML entity-encoded. We need to decode it before we
send it back to the client, or make sure it is never encoded in the
first place.

2. There is an extra <metadata></metadata> tag around the metadata
(which is then entity-encoded). You can see this in your test results.

I'm not sure if these problems are internal to the Message class or in
the API code, but if you want to work on fixing them, please feel
free.

Ethan



Mime
View raw message