Project

General

Profile

1
Accessing and Submitting Metadata and Data
2
==========================================
3

    
4
.. contents::
5

    
6
The Metacat repository can be accessed and updated using a number of tools, 
7
including: 
8

    
9
* the Registry, Metacat's optional Web interface
10
* user-created HTML forms 
11
* Metacat's EarthGrid API
12
* existing clients, such as KNB's Morpho application, designed to help 
13
  scientists create, edit, and manage metadata
14
* user-created desktop clients that take advantage of Metacat's Java API.
15

    
16
In this section, we will look at how to take advantage of these tools to 
17
customize Metacat for your user-base.
18

    
19
A Brief Note about How Information is Stored
20
--------------------------------------------
21
Metacat stores XML files as a hierarchy of nodes, where each node is stored as 
22
records in database tables. Because many XML data schemas are broken up into 
23
multiple DTDs requiring multiple XML files that are related but stored 
24
separately in the system, the system uses "packages" to link related but 
25
separate documents. Packaged documents contain information that shows how they 
26
are related to eachother, essentially stating that file A has a relationship 
27
to file B, etc. A package file also allows users to link metadata files to the 
28
data files they describe. For more information about the structure of data 
29
packages and how XML documents and data are stored in Metacat, please see the 
30
developer's documentation.
31

    
32
Using the Registry
33
------------------
34
Metacat's optional Registry provides a simple Web-based interface for creating, 
35
editing, and submitting metadata to the Metacat repository (screenshot below). The 
36
interface includes help documentation, and can be customized using Metacat's 
37
configuration settings. The Registry also includes an administrative interface 
38
for managing LDAP user accounts, which is useful if you are using LDAP as your 
39
Metacat authentication system. Note that you must be running your own LDAP 
40
server if you wish to use the LDAP Web interface. If you do not have your own 
41
LDAP server, you can create and manage new accounts on the KNB website 
42
(http://knb.ecoinformatics.org/). Please note that at this time, the Registry 
43
interface has only been tested on Linux systems.
44

    
45
.. figure:: images/screenshots/image033.jpg
46
   :align: center
47

    
48
   An example installation of the Register's web interface. Customize the 
49
   displayed and required modules with the Skins Configuration settings.
50
   
51
You can customize which modules (e.g., "Name of Submitter" or "Temporal 
52
Coverage of Data") are displayed and which are required using the Skins 
53
Configuration settings
54

    
55
Installing the Registry
56
~~~~~~~~~~~~~~~~~~~~~~~
57
In order to install and run the Registry, you must have Metacat installed and 
58
Tomcat must be running behind an Apache Web server (see previous sections for 
59
information about installing and configuring Apache to run with Tomcat).
60

    
61
To install and run the Registry:
62

    
63
1. Build the Metacat Perl client library:
64

    
65
  ::
66

    
67
    cd $METACAT/src/perl/Metacat
68
    perl Makefile.PL
69
    sudo make
70
    sudo make install
71

    
72
.. sidebar:: Instructions for Red Hat (Alternate Step 2)
73

    
74
  * Install the libraries
75

    
76
    ::
77
    
78
      sudo yum install gcc libxml2-devel libxslt-devel ant –y
79

    
80
  * Install CPAN, which allows us to install the Perl dependencies for the 
81
    registry and account management parts of Metacat. If asked to manually 
82
    configure cpan, type 'no' and CPAN will be setup with its default values.
83

    
84
    ::
85
    
86
      sudo yum install perl-CPAN
87
      sudo cpan
88

    
89
  * You should now see a prompt which looks like:
90

    
91
    ::
92
    
93
      cpan>
94

    
95
  * The rest of the commands assume you're inside of CPAN. Let's get the most 
96
    recent version of the CPAN software. Just press return after any prompts 
97
    you receive during this process.
98
    
99
    ::
100
    
101
      install Bundle::CPAN
102
      reload cpan
103

    
104
  * Install the required modules. Here we're installing an old LibXSLT, as the 
105
    current one requires a newer libxslt than is available on Redhat 4 & 5. 
106
    Again, just answer 'yes' to any questions.
107

    
108
    ::
109

    
110
      install AutoLoader
111
      install CGI
112
      install CGI::SEssion
113
      install LWP::UserAgent
114
      install Net::LDAP
115
      install Template 
116
      install URI
117
      install MSERGEANT/XML-LibXSLT-1.58.tar.gz
118

    
119
2. Install the required system libraries using Ubuntu/Debian (instructions 
120
   Red Hat in sidebar)
121
         
122
  * Install the libraries
123

    
124
    ::
125

    
126
      sudo apt-get install ant libappconfig-perl libxml-libxml-perl \
127
      libxml-libxslt-perl libtemplate-perl libcgi-session-perl \
128
      libdigest-sha1-perl libnet-ldap-perl libterm-readkey-perl \
129
      libxml-dom-perl libsoap-lite-perl -y
130

    
131
  * Install two more package using cpan 
132

    
133
    ::
134
    
135
      sudo cpan -i Config::Properties
136
      sudo cpan -i Scalar::Util
137

    
138

    
139
3. Double-check that Metacat's temporary folder, application.tempDir, is 
140
   writable by the apache user, usually www-data or apache. 
141

    
142
4. Make sure that the following scripts (found in ``<tomcat-home>/webapps/knb/cgi-bin``) 
143
   are executable: register-dataset.cgi and ldapweb.cgi.
144

    
145
  ::
146
  
147
    sudo chmod +x <tomcat-home>/webapps/knb/cgi-bin/*.cgi
148

    
149
5. Restart Apache.
150

    
151
  ::
152
  
153
    sudo /etc/init.d/apache2 restart
154

    
155
6. Visit the resulting URL: 
156
   http://<your_context_url>/cgi-bin/register-dataset.cgi?cfg=default
157
   Where ``<your_context_url>`` is the URL of the server hosting the Metacat 
158
   followed by the name of the WAR file (i.e., the application context) that 
159
   you installed. For instance, the context URL for the KNB Metacat is: 
160
   http://knb.ecoinformatics.org/knb.
161

    
162
If everything worked correctly, the registry home page will open (see figure).
163

    
164
.. figure:: images/screenshots/image035.jpg
165
   :align: center
166

    
167
   An example of the Registry home page (with the default skin).
168
   
169
Customizing the Registry
170
~~~~~~~~~~~~~~~~~~~~~~~~
171
Before using the registry, you may wish to customize the interface using the 
172
Skins Configuration settings. If you are using the default skin, you must 
173
disable the 'show site list' setting before you can submit the form without 
174
errors. You may also wish to remove (or modify) the list of NCEAS-specific 
175
projects that appear in the default registry. To remove these form fields, 
176
open Metacat's administrative interface (http://<your.context.url>/knb/admin) 
177
and select the Skins Specific Properties Configuration option. On the skins 
178
configuration page, uncheck the boxes beside any form elements that you do not 
179
wish to appear in the registry.
180

    
181
Once you have saved your changes, you must restart Tomcat for them to come 
182
into effect. To restart Tomcat, type: ``sudo /etc/init.d/tomcat6 restart`` or an 
183
equivalent command appropriate to your operating system. 
184

    
185
.. figure:: images/screenshots/image037.jpg
186
   :align: center
187

    
188
   Uncheck the box beside any setting to remove it from the Registry form. In 
189
   the example, the "Show Site List" and "Show Work Group" form fields, 
190
   corresponding to the "Station Name" and "NCEAS Project" drop-down lists in 
191
   the registry form, have been removed.
192
   
193
Using HTML Forms (the HTTP Interface)
194
-------------------------------------
195
Metacat's HTTP interface supports Get and Post requests and a variety of actions (Table 4.1) that facilitate information retrieval and storage. HTTP requests can be sent from any client application that communicates using the Web's HTTP protocol. 
196

    
197
* Supported Actions (API)
198
* Logging in
199
* Inserting, Updating, and Deleting XML and Data Documents
200
* Searching Metacat
201
* Paged Query Return
202
* Reading Data and Metadata
203

    
204
Supported Actions
205
~~~~~~~~~~~~~~~~~
206
Metacat supports get and post requests as well as actions for writing, querying, 
207
and reading stored XML. In addition, the HTTP interface includes functions for 
208
validating and transforming XML documents (see table). 
209

    
210
Note that if Replication is enabled, Metacat recognizes several additional 
211
actions, included in Table 4.2. For more information about replication, 
212
please see :doc:`replication`.
213

    
214
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
215
| Action                   | Description and Parameters                                                                                                                                                                                                                                         |
216
+==========================+====================================================================================================================================================================================================================================================================+
217
| delete                   | Delete the specified document from the database. For an                                                                                                                                                                                                            |
218
|                          | example, please see Inserting, Updating, and                                                                                                                                                                                                                       |
219
|                          | Deleting XML and Data Documents.                                                                                                                                                                                                                                   |
220
|                          |                                                                                                                                                                                                                                                                    |
221
|                          | ``docid`` - the docid of the document to delete                                                                                                                                                                                                                    |
222
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
223
| export                   | Export a data package in a zip file.                                                                                                                                                                                                                               |
224
|                          |                                                                                                                                                                                                                                                                    |
225
|                          | ``docid`` - the docid of the document to delete                                                                                                                                                                                                                    |
226
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
227
| getaccesscontrol         | Get the access control list (ACL) for the                                                                                                                                                                                                                          |
228
|                          | specified document.                                                                                                                                                                                                                                                |
229
|                          |                                                                                                                                                                                                                                                                    |
230
|                          | ``docid`` - the docid of the document to delete                                                                                                                                                                                                                    |
231
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
232
| getalldocids             | Retrieve a list of all docids registered with the system.                                                                                                                                                                                                          |
233
|                          |                                                                                                                                                                                                                                                                    |
234
|                          | ``scope`` - a string used to match a range of docids in a SQL LIKE statement                                                                                                                                                                                       |
235
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
236
| getdataguide             | Read a data guide for the specified document type                                                                                                                                                                                                                  |
237
| DEPRECATED               |                                                                                                                                                                                                                                                                    |
238
| Use getdtdschema instead | ``doctype`` - the doctype for which to get the data guide                                                                                                                                                                                                          |
239
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
240
| getdoctypes              | Get all doctypes currently available in the Metacat Catalog System. No parameters.                                                                                                                                                                                 |
241
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
242
| getdtdschema             | Read the DTD or XMLSchema file for the specified doctype.                                                                                                                                                                                                          |
243
|                          |                                                                                                                                                                                                                                                                    |
244
|                          | ``doctype`` - the doctype for which DTD or XMLSchema files to read                                                                                                                                                                                                 |
245
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
246
| getlastdocid             | Get the latest docid with revision number used by scope.                                                                                                                                                                                                           |
247
|                          |                                                                                                                                                                                                                                                                    |
248
|                          | ``scope`` - the scope to be queried                                                                                                                                                                                                                                |
249
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
250
| getlog                   | Get the latest docid with revision number used by user.                                                                                                                                                                                                            |
251
|                          |                                                                                                                                                                                                                                                                    |
252
|                          | ``ipaddress`` - the internet protocol address for the event                                                                                                                                                                                                        |
253
|                          | ``principal`` - the principal for the event (a username, etc)                                                                                                                                                                                                      |
254
|                          | ``docid`` - the identifier of the document to which the event applies                                                                                                                                                                                              |
255
|                          | ``event`` - the string code for the event                                                                                                                                                                                                                          |
256
|                          | ``start`` - beginning of date-range for query                                                                                                                                                                                                                      |
257
|                          | ``end`` - end of date-range for query                                                                                                                                                                                                                              |
258
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
259
| getloggedinuserinfo      | Get user info for the currently logged in user. No parameters.                                                                                                                                                                                                     |
260
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
261
| getpricipals             | Get all users and groups in the current authentication schema. No parameters.                                                                                                                                                                                      |
262
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
263
| getrevisionanddoctype    | Return the revision and doctype of a document.                                                                                                                                                                                                                     |
264
|                          | The output is String that looks like "rev;doctype"                                                                                                                                                                                                                 |
265
|                          |                                                                                                                                                                                                                                                                    |
266
|                          | ``docid`` - the docid of the document                                                                                                                                                                                                                              |
267
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
268
| getversion               | Get Metacat version.   Return the current version of Metacat as XML. No parameters.                                                                                                                                                                                |
269
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
270
| insert                   | Insert an XML document into the database. For an example, please see                                                                                                                                                                                               |
271
|                          | Inserting, Updating, and Deleting XML and Data Documents                                                                                                                                                                                                           |
272
|                          |                                                                                                                                                                                                                                                                    |
273
|                          | ``docid`` - the user-defined docid to assign to the new XML document                                                                                                                                                                                               |
274
|                          | ``doctext`` - the text of the XML document to insert                                                                                                                                                                                                               |
275
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
276
| insertmultipart          | Insert an XML document using multipart encoding into the database.                                                                                                                                                                                                 |
277
|                          |                                                                                                                                                                                                                                                                    |
278
|                          | ``docid`` - the user-defined docid to assign to the new XML document                                                                                                                                                                                               |
279
|                          | ``doctext`` - the text of the XML document to insert                                                                                                                                                                                                               |
280
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
281
| isregistered             | Check if an individual document exists in either the xml_documents or xml_revisions tables.                                                                                                                                                                        |
282
|                          | For more information about Metacat's database schema, please see the developer documentation.                                                                                                                                                                      |
283
|                          |                                                                                                                                                                                                                                                                    |
284
|                          | ``docid`` - the docid of the document                                                                                                                                                                                                                              |
285
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
286
| login                    | Log the user in. You must log in using this action before you can perform                                                                                                                                                                                          |
287
|                          | many of the actions. For an example of the login action, see Logging In.                                                                                                                                                                                           |
288
|                          |                                                                                                                                                                                                                                                                    |
289
|                          | ``username`` - the user's login name                                                                                                                                                                                                                               |
290
|                          | ``password`` - the user's password                                                                                                                                                                                                                                 |
291
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
292
| logout                   | Log the current user out and destroy the associated session. No parameters.                                                                                                                                                                                        |
293
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
294
| query                    | Perform a free text query. For an example, please see Searching Metacat.                                                                                                                                                                                           |
295
|                          |                                                                                                                                                                                                                                                                    |
296
|                          | ``returndoctype`` - the doctype to use for your Package View. For more information about packages, see http://knb.ecoinformatics.org/software/metacat/packages.html                                                                                                |
297
|                          | ``qformat`` - the format of the returned result set. Possible values are html or xml or the name of your servlet's Metacat skin.                                                                                                                                   |
298
|                          | ``querytitle`` - OPTIONAL - the title of the query                                                                                                                                                                                                                 |
299
|                          | ``doctype`` - OPTIONAL - if doctype is specified, the search is limited only to the specified doctype(s). (e.g., eml://ecoinformatics.org/eml-2.0.1 and/or eml://ecoinformatics.org/eml-2.0.0) If no doctype element is specified, all document types are returned |
300
|                          | ``returnfield`` - a custom field to be returned by any hit document.                                                                                                                                                                                               |
301
|                          | ``operator`` - the Boolean operator to apply to the query. Possible values are: union or intersect                                                                                                                                                                 |
302
|                          | ``searchmode`` - the type of search to be performed. Possible values are: contains, starts-with, ends-with, equals, isnot-equal, greater-than, less-than, greater-than-equals, less-than-equals.                                                                   |
303
|                          | ``anyfield`` - a free-text search variable. The value placed in this parameter will be searched for in any document in any node.                                                                                                                                   |
304
|                          | ``pagesize`` – the number of search results to display on each search results page (e.g., 10). Used with pagestart. See section 4.3.4 for an example.                                                                                                              |
305
|                          | ``pagestart`` – the displayed search results page (e.g, 1). Used with pagesize. See section 4.3.4 for an example.                                                                                                                                                  |
306
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
307
| read                     | Get a document from the database and return it in the specified format. See Searching Metacat for an example.                                                                                                                                                      |
308
|                          |                                                                                                                                                                                                                                                                    |
309
|                          | ``docid`` - the docid of the document to return                                                                                                                                                                                                                    |
310
|                          | ``qformat`` - the format to return the document in. Possible values are: ``html``, ``xml``,or, if your Metacat uses a skin, the name of the skin.                                                                                                                  |
311
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
312
| readinlinedata           | Read inline data only.                                                                                                                                                                                                                                             |
313
|                          |                                                                                                                                                                                                                                                                    |
314
|                          | ``inlinedataid`` - the id of the inline data to read                                                                                                                                                                                                               |
315
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
316
| setaccess                | Change access permissions for a user on a specified document.                                                                                                                                                                                                      |
317
|                          |                                                                                                                                                                                                                                                                    |
318
|                          | ``docid`` - the docid of the document to be modified.                                                                                                                                                                                                              |
319
|                          | ``principal`` - the user or group whose permissions will be modified                                                                                                                                                                                               |
320
|                          | ``permission`` - the permission  to set (read, write, all)                                                                                                                                                                                                         |
321
|                          | ``permType`` - the type of permission to set (allow, deny)                                                                                                                                                                                                         |
322
|                          | ``permOrder`` - the order in which to apply the permission (allowFirst, denyFirst)                                                                                                                                                                                 |
323
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
324
| spatial_query            | Perform a spatial query. These queries may include any of the queries supported by the                                                                                                                                                                             |
325
|                          | WFS / WMS standards. For more information, see Spatial Queries.                                                                                                                                                                                                    |
326
|                          |                                                                                                                                                                                                                                                                    |
327
|                          | ``xmax`` - max x spatial coordinate                                                                                                                                                                                                                                |
328
|                          | ``ymax`` - max y spatial coordinate                                                                                                                                                                                                                                |
329
|                          | ``xmin`` - min x spatial coordinate                                                                                                                                                                                                                                |
330
|                          | ``ymin`` - min y spatial coordinate                                                                                                                                                                                                                                |
331
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
332
| squery                   | Perform a structured query. For an example, please see Searching Metacat.                                                                                                                                                                                          |
333
|                          |                                                                                                                                                                                                                                                                    |
334
|                          | ``query`` - the text of the pathquery document sent to the server  																																																																																																																																																																								|
335
|                          | ``qformat`` - the format to return the results in. Possible values are:  ``xml``, or the name of the a skin.                                                                                                                  |                                                                              |
336
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
337
| update                   | Overwrite an XML document with a new one and give the new one the same docid but with                                                                                                                                                                              |
338
|                          | the next revision number. For an example, please see Inserting, Updating, and                                                                                                                                                                                      |
339
|                          | Deleting XML and Data Documents.                                                                                                                                                                                                                                   |
340
|                          |                                                                                                                                                                                                                                                                    |
341
|                          | ``docid`` - the docid of the document to update                                                                                                                                                                                                                    |
342
|                          | ``doctext`` - the text with which to update the XML document                                                                                                                                                                                                       |
343
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
344
| upload                   | Upload (insert or update) a data file into Metacat. Data files are stored on Metacat and may be in any                                                                                                                                                             |
345
|                          | format (binary or text), but they are all treated as if they were binary.                                                                                                                                                                                          |
346
|                          |                                                                                                                                                                                                                                                                    |
347
|                          | ``docid`` - the docid of the data file to upload                                                                                                                                                                                                                   |
348
|                          | ``datafile`` - the data file to upload                                                                                                                                                                                                                             |
349
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
350
| validate                 | Validate a specified document against its DTD.                                                                                                                                                                                                                     |
351
|                          |                                                                                                                                                                                                                                                                    |
352
|                          | ``docid`` - the docid of the document to validate                                                                                                                                                                                                                  |
353
|                          | ``valtext`` - the DTD by which to validate this document                                                                                                                                                                                                           |
354
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
355

    
356

    
357
Metacat Replication Parameters
358

    
359
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
360
| Action         | Description and Parameters                                                                                                                                      |
361
+================+=================================================================================================================================================================+
362
| forcereplicate | Force the local server to get the specified document from the remote host.                                                                                      |
363
|                |                                                                                                                                                                 |
364
|                | ``server`` - The server to which this document is being sent                                                                                                    |
365
|                | ``docid`` - The docid of the document to send                                                                                                                   |
366
|                | ``dbaction`` - The action to perform on the document: insert or update (the default)                                                                            |
367
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
368
| getall         | Force the local server to check all known servers for updated documents. No parameters.                                                                         |
369
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
370
| getcatalog     | Send the contents of the xml_catalog table encoded in XML. No parameters.                                                                                       |
371
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
372
| getlock        | Request a lock on the specified document.                                                                                                                       |
373
|                |                                                                                                                                                                 |
374
|                | ``docid`` - the docid of the document                                                                                                                           |
375
|                | ``updaterev`` - the revision number of docid                                                                                                                    |
376
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
377
| gettime        | Return the local time on this server. No parameters.                                                                                                            |
378
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
379
| servercontrol  | Perform the specified replication control on the Replication daemon.                                                                                            |
380
|                |                                                                                                                                                                 |
381
|                | ``add`` - add a new server to the replication list                                                                                                              |
382
|                | ``delete`` - remove a server from the replication list                                                                                                          |
383
|                | ``list`` - list all of the servers currently in the server list                                                                                                 |
384
|                | ``replicate`` - a Boolean flag (1 or 0) which determines if this server should copy files from the newly added server.                                          |
385
|                | ``server`` - the server to add/delete                                                                                                                           |
386
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
387
| read           | Sends docid to the remote host.                                                                                                                                 |
388
|                |                                                                                                                                                                 |
389
|                | ``docid`` - the docid of the document to read                                                                                                                   |
390
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
391
| start          | Start the Replication daemon with a time interval of deltaT.                                                                                                    |
392
|                |                                                                                                                                                                 |
393
|                | ``rate`` - The rate (in seconds) at which you want the replication daemon to check for updated documents. The value cannot be less than 30. The default is 1000 |
394
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
395
| stop           | Stop the Replication daemon. No parameters.                                                                                                                     |
396
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
397
| update         | Send a list of all documents on the local server along with their revision numbers. No parameters.                                                              |
398
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
399

    
400
Logging In
401
~~~~~~~~~~
402
To log in to Metacat, use the ``login`` action.
403

    
404
The following is an example of a Web form (see figure) that logs a user into 
405
Metact. Example HTML code is included below the screenshot.
406

    
407
.. figure:: images/screenshots/image039.jpg
408
   :align: center
409
   
410
   Logging into Metacat using an HTML form.
411

    
412
::
413

    
414
  <html>
415
  <body>
416
  <form name="loginform" method="post"action="http://yourserver.com/yourcontext/servlet/metacat" 
417
  target="_top" onsubmit="return submitform(this);" id="loginform">
418
    <input type="hidden" name="action" value="login"> <input type=
419
    "hidden" name="username" value=""> <input type="hidden" name=
420
    "qformat" value="xml"> <input type="hidden" name=
421
    "enableediting" value="false">
422

    
423
    <table>
424
      <tr valign="middle">
425
        <td align="left" valign="middle" class="text_plain">
426
        username:</td>
427

    
428
        <td width="173" align="left" class="text_plain" style=
429
        "padding-top: 2px; padding-bottom: 2px;"><input name="uid"
430
        type="text" style="width: 140px;" value=""></td>
431
      </tr>
432

    
433
      <tr valign="middle">
434
        <td height="28" align="left" valign="middle" class=
435
        "text_plain">organization:</td>
436

    
437
        <td align="left" class="text_plain" style=
438
        "padding-top: 2px; padding-bottom: 2px;"><select name=
439
        "organization" style="width:140px;">
440
          <option value=""    selected>&#8212; choose one &#8212;</option>
441
          <option value="NCEAS">NCEAS</option>
442
          <option value="LTER">LTER</option>
443
          <option value="UCNRS">UCNRS</option>
444
          <option value="PISCO">PISCO</option>
445
          <option value="OBFS">OBFS</option>
446
          <option value="OSUBS">OSUBS</option>
447
          <option value="SAEON">SAEON</option>
448
          <option value="SANParks">SANParks</option>
449
          <option value="SDSC">SDSC</option>
450
          <option value="KU">KU</option>
451
          <option value="unaffiliated">unaffiliated</option>
452
        </select></td>
453
      </tr>
454

    
455
      <tr valign="middle">
456
        <td width="85" align="left" valign="middle" class=
457
        "text_plain">password:</td>
458

    
459
        <td colspan="2" align="left" class="text_plain" style=
460
        "padding-top: 2px; padding-bottom: 2px;">
461
          <table width="100%" border="0" cellpadding="0"
462
          cellspacing="0">
463
            <tr>
464
              <td width="150" align="left"><input name="password"
465
              type="password" maxlength="50" style="width:140px;"
466
              value=""></td>
467

    
468
              <td align="center" class="buttonBG_login">
469
              <input type="submit" name="loginAction" value="Login"
470
              class="button_login"></td>
471

    
472
              <td align="left">&nbsp;</td>
473
            </tr>
474
          </table>
475
        </td>
476
      </tr>
477
    </table>
478
  </form>
479
  </body>
480
  </html>
481

    
482
Inserting, Updating, and Deleting XML and Data Documents
483
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
484
Adding, editing, and deleting XML documents in Metacat can be accomplished 
485
using the insert, update, and delete actions, respectively. Before you can 
486
insert, delete, or update documents, you must log in to Metacat using the 
487
login action. See Logging in for an example.
488

    
489
``insert``
490
   Insert a new XML or data document into Metacat. You must specify a document ID.
491
   
492
``update``
493
   Update an existing Metacat document. The original document is archived, 
494
   then overwritten.
495

    
496
``delete``
497
   Archive a document and move the pointer in xml_documents to xml_revisions, 
498
   effectively "deleting" the document from public view, but preserving the 
499
   revision for the revision history. No further updates will be allowed for
500
   the Metacat document that was "deleted". All revisions of this identifier are no longer 
501
   public. 
502

    
503
.. warning::
504
   It is not possible to "delete" one revision without "deleting" all 
505
   revisions of a given identifier.
506

    
507
The following is an example of a Web form (see figure) that can perform all 
508
three tasks. Example HTML code is included in the sidebar.
509

    
510
.. figure:: images/screenshots/image041.jpg
511
   :align: center
512
   
513
   An example of a Web form used to insert, delete, or update XML documents in Metacat.
514

    
515
::
516

    
517
  <html>
518
    <head>
519
    <title>MetaCat</title>
520
    </head>
521
    <body class="emlbody">
522
    <b>MetaCat XML Loader</b>
523
    <p>
524
    Upload, Change, or Delete an XML document using this form.
525
    </p>
526
    <form action="http://yourserver.com/yourcontext/servlet/metacat" method="POST">
527
      <strong>1. Choose an action: </strong>
528
      <input type="radio" name="action" value="insert" checked> Insert
529
      <input type="radio" name="action" value="update"> Update
530
      <input type="radio" name="action" value="delete"> Delete
531
      <input type="submit" value="Process Action">
532
      <br />
533
      <strong>2. Provide a Document ID </strong>
534
      <input type="text" name="docid"> (optional for Insert)
535
         <input type="checkbox" name="public" value="yes" checked><strong>Public Document</strong>
536
      <br />
537
      <strong>3. Provide XML text </strong> (not needed for Delete)<br/>
538
      <textarea name="doctext" cols="65" rows="15"></textarea><br/>
539
      <strong>4. Provide DTD text for upload </strong> (optional; not needed for Delete)
540
      <textarea name="dtdtext" cols="65" rows="15"></textarea>
541
    </form>
542
    </body>
543
  </html>
544

    
545
Searching Metacat
546
~~~~~~~~~~~~~~~~~
547
To search Metacat use the ``query`` or ``squery`` actions. 
548

    
549
``query``:   
550
   Perform a free text query. Specify the returndoctype, qformat, returnfield, 
551
   operator, searchmode, anyfield, and (optionally) a querytitle and doctype. 
552

    
553
``squery``:
554
   Perform a structured query by submitting an XML pathquery document to the 
555
   Metacat server.
556
 
557

    
558
When Metacat receives a query via HTTP (screenshot below), the server creates a 
559
"pathquery" document, which is an XML document populated with the specified 
560
search criteria. The pathquery document is then translated into 
561
SQL statements that are executed against the database. Results are translated 
562
into an XML "resultset" document, which can be returned as XML or transformed 
563
into HTML and returned (specify which you would prefer with the returnfield 
564
parameter). You can also opt to submit a pathquery document directly, 
565
using an squery action.
566

    
567
.. figure:: images/screenshots/image043.jpg
568
   :align: center
569
   
570
   Example of a basic search form using a query action. The HTML code used to create the form is displayed below.
571

    
572
::
573

    
574
  <html>
575
  <head>
576
  <title>Search</title>
577
  </head>
578
  <body>
579
  <form method="POST" action="http://panucci.nceas.ucsb.edu/knb/servlet/metacat">
580

    
581
  Search for:
582

    
583
  <input name="action" value="query" type="hidden">
584
  <input name="operator" value="INTERSECT" type="hidden">
585
  <input name="anyfield" type="text" value=" " size="40">
586
  <input name="qformat" value="html" type="hidden">
587
  
588
  <input name="returnfield" value="creator/individualName/surName" type="hidden">
589
  <input name="returnfield" value="creator/individualName/givenName" type="hidden">
590
  <input name="returnfield" value="creator/organizationName" type="hidden">
591
  <input name="returnfield" value="dataset/title" type="hidden">
592
  <input name="returnfield" value="keyword" type="hidden">
593

    
594
  <input name="returndoctype" value="eml://ecoinformatics.org/eml-2.0.1" type="hidden">
595

    
596
  <input value="Start Search" type="submit">
597

    
598
  </form>
599
  </body>
600
  </html>
601
  
602
Metacat's pathquery document can query specific fields of any XML document. 
603
The pathquery can also be used to specify which fields from each hit are 
604
returned and displayed in the search result set.
605

    
606
::
607

    
608
  <pathquery version="1.0">
609
      <meta_file_id>unspecified</meta_file_id>
610
      <querytitle>unspecified</querytitle>
611
      <returnfield>dataset/title</returnfield>
612
      <returnfield>keyword</returnfield>
613
      <returnfield>dataset/creator/individualName/surName</returnfield>
614
      <returndoctype>eml://ecoinformatics.org/eml-2.1.0</returndoctype>      
615
      <returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>
616
      <returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>
617
      <querygroup operator="UNION">
618
        <queryterm casesensitive="true" searchmode="contains">
619
          <value>Charismatic megafauna</value>
620
           <pathexpr>dataset/title</pathexpr>
621
         </queryterm>
622
        <queryterm casesensitive="false" searchmode="starts-with">
623
           <value>sea otter</value>
624
           <pathexpr>keyword</pathexpr>
625
        </queryterm>
626
        <queryterm casesensitive="false" searchmode="contains">
627
          <value>Enhydra</value>
628
          <pathexpr>abstract/para</pathexpr>
629
        </queryterm>
630
       </querygroup>
631
   </pathquery>
632
  </pathquery>
633
  
634
Each ``<returnfield>`` parameter specifies a field that the database will 
635
return (in addition to the fields Metacat returns by default) for each search 
636
result. 
637

    
638
The ``<returndoctype>`` field limits the type of returned documents 
639
(eg, eml://ecoinformatics.org/eml-2.0.1 and/or eml://ecoinformatics.org/eml-2.0.0). 
640
If no returndoctype element is specified, all document types are returned. 
641

    
642
A ``<querygroup>`` creates an AND or an OR statement that applies to the 
643
nested ``<queryterm>`` tags. The querygroup operator can be UNION or INTERSECT. 
644
A ``<queryterm>`` defines the actual field (contained in ``<pathexpr>`` tags) 
645
against which the query (contained in the ``<value>`` tags) is being performed. 
646

    
647
The ``<pathexpr>`` can also contain a document type keyword contained in 
648
``<returndoc>`` tags. The specified document type applies only to documents 
649
that are packaged together (e.g., a data set and its corresponding metadata file). 
650
If Metacat identifies the search term in a packaged document, the servlet will 
651
check to see if that document's type matches the specified one. If not, 
652
Metacat will check if one of the other documents in the package matches. If so, 
653
Metacat will return the matching document. For more information about packages, 
654
please see the developer documentation.
655

    
656
After Metacat has processed a Pathquery document, it returns a resultset document.
657

    
658
::
659

    
660
  <resultset>
661
        <query>
662
          <pathquery version="1.0">
663
             <meta_file_id>unspecified</meta_file_id>
664
             <querytitle>unspecified</querytitle>
665
             <returnfield>dataset/title</returnfield>
666
             <returnfield>keyword</returnfield>
667
             <returnfield>dataset/creator/individualName/surName</returnfield>
668
             <returndoctype>eml://ecoinformatics.org/eml-2.1.0</returndoctype>
669
             <returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>
670
             <returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>
671
             <querygroup operator="UNION">
672
                  <queryterm casesensitive="true" searchmode="contains">
673
                       <value>Charismatic megafauna</value>
674
                       <pathexpr>dataset/title</pathexpr>
675
                   </queryterm>
676
                   <queryterm casesensitive="false" searchmode="starts-with">
677
                      <value>sea otter</value>
678
                      <pathexpr>keyword</pathexpr>
679
                   </queryterm>
680
                   <queryterm casesensitive="false" searchmode="contains">
681
                      <value>Enhydra</value>
682
                      <pathexpr>abstract/para</pathexpr>
683
                   </queryterm>
684
            </querygroup>
685
          </pathquery>
686
         </query>  
687
       
688
         <document>
689
           <docid>nrs.569.3</docid>
690
           <docname>eml</docname>
691
           <doctype>eml://ecoinformatics.org/eml-2.0.0</doctype>
692
           <createdate>2012-06-06</createdate>
693
           <updatedate>2012-06-06</updatedate>
694
           <param name="dataset/title">Marine Mammal slides</param>
695
           <param name="creator/individualName/surName">Bancroft</param>
696
         </document>
697
 
698
         <document>
699
           <docid>knb-lter-sbc.61.1</docid>
700
           <docname>eml</docname>
701
           <doctype>eml://ecoinformatics.org/eml-2.1.0</doctype>
702
           <createdate>2012-06-06</createdate>
703
           <updatedate>2012-06-06</updatedate>
704
           <param name="dataset/creator/individualName/surName">Nelson</param>
705
           <param name="dataset/creator/individualName/surName">Harrer</param>
706
           <param name="dataset/creator/individualName/surName">Reed</param>
707
           <param name="dataset/title">SBC LTER: Reef: Sightings of Sea Otters (Enhydra lutris) near Santa Barbara and Channel Islands, ongoing since 2007</param>
708
         </document>
709
      .....  
710
  </resultset>
711

    
712
When Metacat returns a resultset document, the servlet always includes the 
713
pathquery used to create it. The pathquery XML is contained in the <query> tag, 
714
the first element in the resultset.
715

    
716
Each XML document returned by the query is represented by a ``<document>`` tag. By 
717
default, Metacat will return the docid, docname, doctype, doctitle, createdate 
718
and updatedate for each search result. If the user specified additional return 
719
fields in the pathquery using ``<returnfield>`` tags (e.g., dataset/title to return 
720
the document title), the additional fields are returned in ``<param>`` tags. 
721

    
722
Metacat can return the XML resultset to your client as either XML or HTML.
723

    
724
Paged Query Returns
725
~~~~~~~~~~~~~~~~~~~
726
Dividing large search result sets over a number of pages speeds load-time and 
727
makes the result sets more readable to users (Figure 4.12). To break your search 
728
results into pages, use the query action's optional pagestart and pagesize 
729
parameters. The pagesize parameter indicates how many results should be 
730
returned for a given page. The pagestart parameter indicates which page you 
731
are currently viewing.
732

    
733
.. figure:: images/screenshots/image045.jpg
734
   :align: center
735
   
736
   An example of paged search results. 
737

    
738
When a paged query is performed, the query's resultset contains four extra 
739
fields: pagestart, pagesize, nextpage, and previouspage (Figure 4.13).  The 
740
nextpage and previouspage fields help Metacat generate navigational links in 
741
the rendered resultset using XSLT to transform the XML to HTML. 
742

    
743
:: 
744

    
745
  <!-- An example of an XML resultset that include support for page breaks. 
746
       The pagestart parameter will always indicate the page you are currently viewing.
747
  -->
748
  <resultset>
749
      <pagestart>1</pagestart>
750
      <pagesize>10</pagesize>
751
      <nextpage>2</nextpage>
752
      <previouspage>0</previouspage>
753
      <query> ...</query>
754
      <document>...</document>
755
      <document>...</document>
756
    </resultset>
757

    
758
The HTML search results displayed in the figure were rendered using Kepler's XSLT, 
759
which can be found in lib/style/skins/kepler. Kepler's XSLT uses the four extra 
760
resultset fields to render the "Next" and "Previous" links.
761

    
762
::
763
  
764
  <a href="metacat?action=query&operator=INTERSECT&enableediting=false&anyfield=actor&qformat=kepler&pagestart=0&pagesize=10">Previous Page</a>
765
  <a href="metacat?action=query&operator=INTERSECT&enableediting=false&anyfield=actor&qformat=kepler&pagestart=2&pagesize=10">Next Page</a>
766
  
767
In the example above, the current page is 1, and the previous page (page 0) and next page (page 2) pages are indicated by the values of the pagestart parameters.
768

    
769
Reading Data and Metadata
770
~~~~~~~~~~~~~~~~~~~~~~~~~
771
To read data or metadata from Metacat, use the ``read`` action. The ``read`` action 
772
takes two parameters: ``docid``, which specifies the document ID of the document 
773
to return, and ``qformat``, which specifies the return format for the document 
774
(``html`` or ``xml`` or the name of a configured style-set, e.g., ``default``). If ``qformat`` 
775
is set to ``xml``, Metacat will return the XML document untransformed. If the 
776
return format is set to ``html``, Metacat will transform the XML document into 
777
HTML using the default XSLT style sheet (specified in the Metacat 
778
configuration). If the name of a style-set is specified, Metacat will use the 
779
XSLT styles specified in the set to transform the XML.
780

    
781
.. figure:: images/screenshots/image047.jpg
782
   :align: center
783
   
784
   The same document displayed using different qformat parameters (from left 
785
   to right: the default style-set, XML, and HTML). 
786

    
787
Note that the ``read`` action can be used to read both data files and metadata files. 
788
To read a data file, you could use the following request::
789

    
790
  http://yourserver.com/yourcontext/metacat?action=read&docid=nceas.55&qformat=default
791

    
792
Where ``nceas.55`` is the docid of the data file stored in the Metacat and 
793
``default`` is the name of the style (you could also use "html" or "xml" or the 
794
name of a customized skin).
795

    
796
::
797
  
798
  <html>
799
  <head>
800
    <title>Read Document</title>
801
  </head>
802
  <body>
803
    <form method="POST" action="http://your.server/your.context/servlet/metacat">
804
      <input name="action" value="read" type="hidden">
805
      <input name="docid" type="text" value="" size="40">
806
      <input name="qformat" value="default" type="hidden">
807
      <input value="Read" type="submit">
808
    </form>
809
  </body>
810
  </html>
811
  
812
Using the EarthGrid API (aka EcoGrid)
813
-------------------------------------
814

    
815
.. Note::
816

    
817
  The EarthGrid/EcoGrid web service API is *deprecated* as of Metacat 2.0.0 and 
818
  will be removed from a future version of Metacat.  Its functionality is being 
819
  replaced by the standardized DataONE REST service interface. The EarthGrid API
820
  will be completely removed by the end of 2013.
821
   
822
The EarthGrid (aka EcoGrid) provides access to disparate data on different 
823
networks (e.g., KNB, GBIF, GEON) and storage systems (e.g., Metacat and SRB), 
824
allowing scientists access to a wide variety of data and analytic resources 
825
(e.g., data, metadata, analytic workflows and processors) networked at different 
826
sites and at different organizations via the internet. 
827

    
828
Because Metacat supports the EarthGrid API (see table), it can query the 
829
distributed EarthGrid, retrieve metadata and data results, and write new and 
830
updated metadata and data back to the grid nodes.
831

    
832
For more information about each EarthGrid service and its WSDL file, navigate 
833
to the "services" page on your Metacat server 
834
(e.g., http://knb.ecoinformatics.org/knb/services). 
835
Note that the AdminService and Version service that appear on this page are 
836
not part of EarthGrid.
837

    
838
EarthGrid/EcoGrid API Summary
839

    
840
+----------------------------+-----------------------------------------------------------------------------------------------------+
841
| Service                    | Description                                                                                         |
842
+============================+=====================================================================================================+
843
| AuthenticationQueryService | Search for and retrieve protected metadata and data from the EarthGrid as an authenticated user.    |
844
|                            |                                                                                                     |
845
|                            | Methods: ``query``, ``get``                                                                         |
846
+----------------------------+-----------------------------------------------------------------------------------------------------+
847
| AuthenticationService      | Log in and out of the EarthGrid                                                                     |
848
|                            |                                                                                                     |
849
|                            | Methods: ``login``, ``logout``                                                                      |
850
+----------------------------+-----------------------------------------------------------------------------------------------------+
851
| IdentifierService          | List, lookup, validate, and add Life Science Identifiers (LSIDs) to the EarthGrid                   |
852
|                            |                                                                                                     |
853
|                            | Methods: ``isRegistered``, ``addLSID``, ``getNextRevision``, ``getNextObject``, ``getAllIds``       |
854
+----------------------------+-----------------------------------------------------------------------------------------------------+
855
| PutService                 | Write metadata to the EarthGrid                                                                     |
856
|                            |                                                                                                     |
857
|                            | Methods: ``put``                                                                                    |
858
+----------------------------+-----------------------------------------------------------------------------------------------------+
859
| QueryService               | Search for and retrieve metadata from the EarthGrid                                                 |
860
|                            |                                                                                                     |
861
|                            | Methods: ``query``, ``get``                                                                         |
862
+----------------------------+-----------------------------------------------------------------------------------------------------+
863
| RegistryService            | Add, update, remove, and search for registered EarthGrid services.                                  |
864
|                            | Note: The WSDL for this  service is found under http://ecogrid.ecoinformatics.org/registry/services |
865
|                            |                                                                                                     |
866
|                            | Methods: ``add``, ``update``, ``remove``, ``list``, ``query``                                       |
867
+----------------------------+-----------------------------------------------------------------------------------------------------+
868

    
869
Using Morpho
870
------------
871
Morpho is a desktop tool created to facilitate the creation, storage, and 
872
retrieval of metadata. Morpho interfaces with any Metacat server, allowing 
873
users to upload, download, store, query and view relevant metadata and data 
874
using the network. Users can authorize the public or only selected colleagues 
875
to view their data files. 
876

    
877
Morpho is part of the Knowledge Network for Biocomplexity (KNB), a national 
878
network intended to facilitate ecological and environmental research on 
879
biocomplexity. To use Morpho with your Metacat, set the Metacat URL in the 
880
Morpho Preferences to point to your Metacat server.
881

    
882
.. figure:: images/screenshots/image049.png
883
   :align: center
884
   
885
   Set the Metacat URL in the Morpho preferences to point to your Metacat.
886

    
887
For more information about Morpho, please see: http://knb.ecoinformatics.org/morphoportal.jsp
888

    
889
Creating Your Own Client
890
------------------------
891

    
892
.. Note::
893

    
894
  NOTE: The Client API (and underlying servlet implementation) has been 
895
  deprecated as of Metacat 2.0.0. Future development should utilize the DataONE 
896
  REST service methods. The Client API will be completely removed by the end of 2013.
897
  
898
Metacat's client API is available in Java and Perl (the Java interface is 
899
described in this section and further detailed in the appendix). Some of the 
900
API is also available in Python and Ruby. The API allows client applications 
901
to easily authenticate users and perform basic Metacat operations such as 
902
reading metadata and data files; inserting, updating, and deleting files; and 
903
searching for packages based on metadata matches. 
904

    
905
The Client API is defined by the interface edu.ucsb.nceas.metacat.client.Metacat, 
906
and all operations are fully defined in the javadoc_ documentation. To use the 
907
client API, include the ``metacat-client.jar``, ``utilities.jar``, ``commons-io-2.0.jar``, and 
908
``httpclient.jar`` in your classpath. After including these classes, you can 
909
begin using the API methods (see the next table). 
910

    
911
.. _javadoc: http://knb.ecoinformatics.org/software/metacat/dev/api/index.html
912

    
913
The following code block displays a typical session for reading a document 
914
from Metacat using the Java client API.
915

    
916
::
917
  
918
  String metacatUrl = "http://foo.com/context/metacat";
919
  String username = "uid=jones,o=NCEAS,dc=ecoinformatics,dc=org";
920
  String password = "neverHarcodeAPasswordInCode";
921
  try {
922
      Metacat m = MetacatFactory.createMetacatConnection(metacatUrl);
923
      m.login(username, password);
924
      Reader r = m.read("testdocument.1.1");
925
      // Do whatever you want with Reader r
926
  } catch (MetacatAuthException mae) {
927
      handleError("Authorization failed:\n" + mae.getMessage());
928
  } catch (MetacatInaccessibleException mie) {
929
      handleError("Metacat Inaccessible:\n" + mie.getMessage());
930
  } catch (Exception e) {
931
      handleError("General exception:\n" + e.getMessage());
932
  }
933
  
934
  Operations provided by Client API  (Metacat.java class)
935
  
936
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
937
| Method               | Parameters and Throws                                                                                                                                                                                       | Description                                                                                                                               |
938
+======================+=============================================================================================================================================================================================================+===========================================================================================================================================+
939
| delete               | ``public String delete(String docid) throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException;``                                                                                   | Delete an XML document in the repository.                                                                                                 |
940
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
941
| getAllDocids         | ``public Vector getAllDocids(String scope) throws MetacatException;``                                                                                                                                       | Return a list of all docids that match a given scope. If scope is null, return all docids registered in the system.                       |
942
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
943
| getLastDocid         | ``public String getLastDocid(String scope) throws MetacatException;``                                                                                                                                       | Return the highest document ID for a given scope.  Used by clients to determine the next free identifier in a sequence for a given scope. |
944
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
945
| getloggedinuserinfo  | ``public String getloggedinuserinfo() throws MetacatInaccessibleException;``                                                                                                                                | Return the logged in user for this session.                                                                                               |
946
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
947
| getNewestDocRevision | ``public int getNewestDocRevision(String docId) throws MetacatException;``                                                                                                                                  | Return the latest revision of specified the document from Metacat                                                                         |
948
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
949
| getSessonId          | ``public String getSessionId();``                                                                                                                                                                           | Return the session identifier for this session.                                                                                           |
950
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
951
| insert               | ``public String insert(String docid, Reader xmlDocument, Reader schema) throws InsufficientKarmaException, MetacatException, IOException, MetacatInaccessibleException;``                                   | Insert an XML document into the repository.                                                                                               |
952
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
953
| isRegistered         | ``public boolean isRegistered(String docid) throws MetacatException;``                                                                                                                                      | Return true if given docid is registered; false if not.                                                                                   |
954
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
955
| login                | ``public String login(String username, String password) throws MetacatAuthException, MetacatInaccessibleException;``                                                                                        | Log in to a Metacat server.                                                                                                               |
956
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
957
| logout               | ``public String logout() throws MetacatInaccessibleException, MetacatException;``                                                                                                                           | Log out of a Metacat server.                                                                                                              |
958
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
959
| query                | ``public Reader query(Reader xmlQuery) throws MetacatInaccessibleException, IOException;``                                                                                                                  | Query the Metacat repository and return the result set as a Reader.                                                                       |
960
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
961
| query                | ``public Reader query(Reader xmlQuery, String qformat) throws MetacatInaccessibleException, IOException;``                                                                                                  | Query the Metacat repository with the given metacat-compatible query format and return the result set as a Reader.                        |
962
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
963
| read                 | ``public Reader read(String docid) throws InsufficientKarmaException, MetacatInaccessibleException, DocumentNotFoundException, MetacatException;``                                                          | Read an XML document from the Metacat server.                                                                                             |
964
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
965
| readInlineData       | ``public Reader readInlineData(String inlinedataid) throws InsufficientKarmaException, MetacatInaccessibleException, MetacatException;``                                                                    | Read inline data from the Metacat server session.                                                                                         |
966
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
967
| setAccess            | ``public String setAccess(String _docid, String _principal, String _permission, String _permType, String _permOrder ); throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException;`` | Set permissions for an XML document in the Metacat repository.                                                                            |
968
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
969
| setMetacatUrl        | ``public void setMetacatUrl(String metacatUrl);``                                                                                                                                                           | Set the MetacatUrl to which connections should be made.                                                                                   |
970
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
971
| setSessionId         | ``public void setSessionId(String sessionId);``                                                                                                                                                             | Set the session identifier for this session.                                                                                              |
972
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
973
| update               | ``public String update(String docid, Reader xmlDocument, Reader schema) throws InsufficientKarmaException, MetacatException, IOException, MetacatInaccessibleException;``                                   | Update an XML document in the repository by providing a new version of the XML document.                                                  |
974
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
975
| upload               | ``public String upload(String docid, File file) throws InsufficientKarmaException, MetacatException, IOException, MetacatInaccessibleException;``                                                           | Upload a data document into the repository.                                                                                               |
976
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
977
| upload               | ``public String publicupload(String docid, String fileName, InputStream fileData, int size) throws InsufficientKarmaException, MetacatException, IOException, MetacatInaccessibleException;``               | Upload a data document into the repository.                                                                                               |
978
+----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
979
  
(22-22/22)