edu.ucsb.nceas.metacat
Class MetaCatServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--edu.ucsb.nceas.metacat.MetaCatServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class MetaCatServlet
extends javax.servlet.http.HttpServlet

A metadata catalog server implemented as a Java Servlet

Valid parameters are:
action=query -- query the values of all elements and attributes and return a result set of nodes
action=squery -- structured query (see pathquery.dtd)
action= -- export a zip format for data packadge
action=read -- read any metadata/data file from Metacat and from Internet
action=insert -- insert an XML document into the database store
action=update -- update an XML document that is in the database store
action=delete -- delete an XML document from the database store
action=validate -- vallidate the xml contained in valtext
doctype -- document type list returned by the query (publicID)
qformat=xml -- display resultset from query in XML
qformat=html -- display resultset from query in HTML
qformat=zip -- zip resultset from query
docid=34 -- display the document with the document ID number 34
doctext -- XML text of the document to load into the database
acltext -- XML access text for a document to load into the database
dtdtext -- XML DTD text for a new DTD to load into Metacat XML Catalog
query -- actual query text (to go with 'action=query' or 'action=squery')
valtext -- XML text to be validated
abstractpath -- XPath in metadata document to read from
action=getaccesscontrol -- retrieve acl info for Metacat document
action=getdoctypes -- retrieve all doctypes (publicID)
action=getdtdschema -- retrieve a DTD or Schema file
action=getdataguide -- retrieve a Data Guide
action=getprincipals -- retrieve a list of principals in XML
datadoc -- data document name (id)

The particular combination of parameters that are valid for each particular action value is quite specific. This documentation will be reorganized to reflect this information.

See Also:
Serialized Form

Field Summary
static java.lang.String EML2KEYWORD
           
static java.lang.String NONAMESPACELOCATION
           
static java.lang.String SCHEMALOCATIONKEYWORD
           
 
Constructor Summary
MetaCatServlet()
           
 
Method Summary
protected  java.lang.String createResultDocument(java.util.Hashtable doclist, java.lang.String xmlquery)
          Transforms a hashtable of documents to an xml or html result.
 void destroy()
          Close all db connections from the pool
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle "GET" method requests from HTTP clients
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle "POST" method requests from HTTP clients
protected  void handleQuery(java.io.PrintWriter out, java.util.Hashtable params, javax.servlet.http.HttpServletResponse response, java.lang.String user, java.lang.String[] groups, java.lang.String sessionid)
          Create the xml query, execute it and display the results.
protected  void handleSQuery(java.io.PrintWriter out, java.util.Hashtable params, javax.servlet.http.HttpServletResponse response, java.lang.String user, java.lang.String[] groups, java.lang.String sessionid)
          Retreive the squery xml, execute it and display it
 void init(javax.servlet.ServletConfig config)
          Initialize the servlet by creating appropriate database connections
protected  java.lang.String transformQuery(java.util.Hashtable params)
          Removes the tag from the beginning of xmlquery so it can properly be placed in the tag of the resultset.
protected  java.lang.String transformQuery(java.lang.String xmlquery)
          removes the tag from the beginning.
protected  void transformResultset(java.lang.String resultdoc, javax.servlet.http.HttpServletResponse response, java.io.PrintWriter out, java.lang.String qformat, java.lang.String sessionid)
          Transorms an xml resultset document to html and sends it to the browser
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMALOCATIONKEYWORD

public static final java.lang.String SCHEMALOCATIONKEYWORD
See Also:
Constant Field Values

NONAMESPACELOCATION

public static final java.lang.String NONAMESPACELOCATION
See Also:
Constant Field Values

EML2KEYWORD

public static final java.lang.String EML2KEYWORD
See Also:
Constant Field Values
Constructor Detail

MetaCatServlet

public MetaCatServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize the servlet by creating appropriate database connections

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
javax.servlet.ServletException

destroy

public void destroy()
Close all db connections from the pool

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Handle "GET" method requests from HTTP clients

Overrides:
doGet in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Handle "POST" method requests from HTTP clients

Overrides:
doPost in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

handleSQuery

protected void handleSQuery(java.io.PrintWriter out,
                            java.util.Hashtable params,
                            javax.servlet.http.HttpServletResponse response,
                            java.lang.String user,
                            java.lang.String[] groups,
                            java.lang.String sessionid)
Retreive the squery xml, execute it and display it

Parameters:
out - the output stream to the client
params - the Hashtable of parameters that should be included in the squery.
response - the response object linked to the client

handleQuery

protected void handleQuery(java.io.PrintWriter out,
                           java.util.Hashtable params,
                           javax.servlet.http.HttpServletResponse response,
                           java.lang.String user,
                           java.lang.String[] groups,
                           java.lang.String sessionid)
Create the xml query, execute it and display the results.

Parameters:
out - the output stream to the client
params - the Hashtable of parameters that should be included in the squery.
response - the response object linked to the client

transformQuery

protected java.lang.String transformQuery(java.util.Hashtable params)
Removes the tag from the beginning of xmlquery so it can properly be placed in the tag of the resultset. This method is overwritable so that other applications can customize the structure of what is in the tag.


transformQuery

protected java.lang.String transformQuery(java.lang.String xmlquery)
removes the tag from the beginning. This takes a string as a param instead of a hashtable.

Parameters:
xmlquery - a string representing a query.

transformResultset

protected void transformResultset(java.lang.String resultdoc,
                                  javax.servlet.http.HttpServletResponse response,
                                  java.io.PrintWriter out,
                                  java.lang.String qformat,
                                  java.lang.String sessionid)
Transorms an xml resultset document to html and sends it to the browser

Parameters:
resultdoc - the string representation of the document that needs to be transformed.
response - the HttpServletResponse object bound to the client.
out - the output stream to the client
qformat - the name of the style-set to use for transformations

createResultDocument

protected java.lang.String createResultDocument(java.util.Hashtable doclist,
                                                java.lang.String xmlquery)
Transforms a hashtable of documents to an xml or html result.



Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.