Lets say you want to upload a file (e.g., test.png) to RAMADDA. First you need to establish a session with RAMADDA. You can just do a url get with:
http://<server>/repository/user/login?output=xml&user.password=<password>&user.id=<user>The output=xml tells RAMADDA to return the result as xml.
The above request returns xml of the form:
<response code="ok"> sessionid </response>Or if there was an error:
<response code="error"> some error message </response>Subsequent posts to RAMADDA just require an extra argument:
sessionid=<sessionid>You can also use RepositoryClient code:
RepositoryClient client = new RepositoryClient(server, 80, "/repository", userId,password);
String[] msg = { "" };
if (client.isValidSession(true, msg)) {
System.err.println("Valid session");
} else {
System.err.println("Invalid session:" + msg[0]);
}
Next, create an xml file that defines the entries you want to create.
<entries>
<entry name="test.png"
description=""
type="file"
id="0"
file="test.png"
parent="0/0"
south="-7.926"
west="-198.358"
north="71.864"
east="-3.950"
fromdate="2008-08-19 16:01:00 GMT"
todate="2008-08-19 16:01:00 GMT"
</entries>
<entries>
<entry name="Some group"
id="0"
parent="0/0"
type="group" />
<entry name="test.png"
description=""
type="file"
id="1"
file="test.png"
parent="0" />
</entries>
Now, zip up this xml file along with the file you want to upload and then post the zipped file to:
http://<server>/repository/entry/xmlcreateInclude the arguments:
output=xml sessionid=<sessionid> file=thezipfileIf you are not uploading files you can just post the xml file instead of the zip file. In that case instead of a file= attribute in the xml use url=, e.g.,:
<entries>
<entry name="Some opendap url"
type="file"
id="0"
url="the opendap url"
parent="0/0"
</entries>
Either way, you will get back the response xml with either code=ok and a list of the entry ids created:
<response code="ok"> <entry id="1219161636252_0.6145187911490728_17"/> </response>Or an error response:
<response code="error"> error message </response>Here is a longer version of an entries file:
<entries> <entry description="" east="-3.950" file="test.xidv" fromdate="2008-08-19 16:01:00 GMT" id="0" name="test.png" north="71.864" parent="0/0" south="-7.926" todate="2008-08-19 16:01:00 GMT" type="file" west="-198.358"/> <entry east="-3.950" file="test.png" fromdate="2008-08-19 16:01:00 GMT" id="1" name="test.png - Product" north="71.864" parent="0/0" south="-7.926" todate="2008-08-19 16:01:00 GMT" type="file" west="-198.358"/> <association from="0" name="generated product" to="1"/> </entries>With its response:
<response code="ok"> <entry id="1219161636252_0.5912686911125428_33"/> <entry id="1219161636252_0.34475975368841827_34"/> <association id="1219161636252_0.18087075533515407_35"/> </response>