Mezeo Ready Developer Center
February 04, 2012, 06:48:44 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
Author Topic: Walk the object tree for a user  (Read 377 times)
jguthrie
Mezeo Employee
Newbie
*****
Posts: 1


View Profile
« on: July 12, 2010, 01:11:01 PM »

Version 2 of the Mezeo API has a feature called "discoverability".  What that means is that the only URL you need to know is the root one for the API.  All other URL's are embedded in links.  One thing this gives is the ability to visit all of the nodes for a given user by starting at the root and simply visiting all the links pointed to by the root and then recursively fetching URL's in the documents fetched.

I've attached a simple bash script that does this for the specified user.  The script uses curl to fetch a URL and an XML application called XMLStarlet to process the data as retrieved.  The script would be straightforward, but for two things.  First, sometimes the links are to things that are not XML documents.  For example, file data isn't necessarily XML, neither are the thumbnail images associated with a file.  Trying to pass non XML data to XMLStarlet generates errors, so I check the first character of the document and don't attempt to parse the data if it isn't the less than character which XML starts with.  Also, some of the links contain links to parts of the tree toward the root.  Since the document graph isn't acyclic, I need to be careful to exclude any link to a parent before visiting a link.
Logged
Pages: [1]
 
Jump to:  

© Mezeo Software. All rights reserved. | Privacy Policies | Contact Us | Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC