Index: src/edu/ucsb/nceas/metacat/QuerySpecification.java
===================================================================
--- src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 744)
+++ src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 745)
@@ -50,17 +50,26 @@
  */
 public class QuerySpecification extends DefaultHandler {
  
+  /** flag determining whether extended query terms are present */
   private boolean containsExtendedSQL=false;
- 
-  // Query data structures
+  /** Identifier for this query document */
   private String meta_file_id;
+  /** Title of this query */
+  private String queryTitle;
+  /** List of document types to be returned using package back tracing */
   private Vector returnDocList;
+  /** List of document types to be searched */
   private Vector filterDocList;
+  /** List of fields to be returned in result set */
   private Vector returnFieldList;
+  /** List of users owning documents to be searched */
   private Vector ownerList;
+  /** List of sites/scopes used to constrain search */
   private Vector siteList;
+  /** The root query group that contains the recursive query constraints */
   private QueryGroup query = null;
 
+  // Query data structures used temporarily during XML parsing
   private Stack elementStack;
   private Stack queryStack;
   private String currentValue;
@@ -166,6 +175,71 @@
   }
   
   /**
+   * Accessor method to return the identifier of this Query
+   */
+  public String getIdentifier()
+  {
+    return meta_file_id;
+  }
+
+  /**
+   * method to set the identifier of this query
+   */
+  public void setIdentifier(String id) {
+    this.meta_file_id = id;
+  }
+
+  /**
+   * Accessor method to return the title of this Query
+   */
+  public String getQueryTitle()
+  {
+    return queryTitle;
+  }
+
+  /**
+   * method to set the title of this query
+   */
+  public void setQueryTitle(String title)
+  {
+    this.queryTitle = title;
+  }
+
+  /**
+   * Accessor method to return a vector of the return document types as
+   * defined in the &lt;returndoctype&gt; tag in the pathquery dtd.
+   */
+  public Vector getReturnDocList()
+  {
+    return this.returnDocList;
+  }
+
+  /**
+   * method to set the list of return docs of this query
+   */
+  public void setReturnDocList(Vector returnDocList)
+  {
+    this.returnDocList = returnDocList;
+  }
+
+  /**
+   * Accessor method to return a vector of the filter doc types as
+   * defined in the &lt;filterdoctype&gt; tag in the pathquery dtd.
+   */
+  public Vector getFilterDocList()
+  {
+    return this.filterDocList;
+  }
+
+  /**
+   * method to set the list of filter docs of this query
+   */
+  public void setFilterDocList(Vector filterDocList)
+  {
+    this.filterDocList = filterDocList;
+  }
+
+  /**
    * Accessor method to return a vector of the extended return fields as
    * defined in the &lt;returnfield&gt; tag in the pathquery dtd.
    */
@@ -175,6 +249,56 @@
   }
 
   /**
+   * method to set the list of fields to be returned by this query
+   */
+  public void setReturnFieldList(Vector returnFieldList)
+  {
+    this.returnFieldList = returnFieldList;
+  }
+
+  /**
+   * Accessor method to return a vector of the owner fields as
+   * defined in the &lt;owner&gt; tag in the pathquery dtd.
+   */
+  public Vector getOwnerList()
+  {
+    return this.ownerList;
+  }
+
+  /**
+   * method to set the list of owners used to constrain this query
+   */
+  public void setOwnerList(Vector ownerList)
+  {
+    this.ownerList = ownerList;
+  }
+
+  /**
+   * Accessor method to return a vector of the site fields as
+   * defined in the &lt;site&gt; tag in the pathquery dtd.
+   */
+  public Vector getSiteList()
+  {
+    return this.siteList;
+  }
+
+  /**
+   * method to set the list of sites used to constrain this query
+   */
+  public void setSiteList(Vector siteList)
+  {
+    this.siteList = siteList;
+  }
+
+  /**
+   * get the QueryGroup used to express query constraints
+   */
+  public QueryGroup getQueryGroup()
+  {
+    return query;
+  }
+
+  /**
    * Set up the SAX parser for reading the XML serialized query
    */
   private XMLReader initializeParser() {
@@ -272,6 +396,8 @@
     String currentTag = currentNode.getTagName();
     if (currentTag.equals("meta_file_id")) {
       meta_file_id = inputString;
+    } else if (currentTag.equals("querytitle")) {
+      queryTitle = inputString;
     } else if (currentTag.equals("value")) {
       currentValue = inputString;
     } else if (currentTag.equals("pathexpr")) {
@@ -278,6 +404,8 @@
       currentPathexpr = inputString;
     } else if (currentTag.equals("returndoctype")) {
       returnDocList.add(inputString);
+    } else if (currentTag.equals("filterdoctype")) {
+      filterDocList.add(inputString);
     } else if (currentTag.equals("returnfield")) {
       returnFieldList.add(inputString);
       containsExtendedSQL = true;
Index: src/edu/ucsb/nceas/metacat/DBQuery.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 744)
+++ src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 745)
@@ -176,17 +176,17 @@
     this.parserName = parserName;
   }
   
-  public Hashtable findDocuments(Reader xmlquery, String user, String group,
-                                 boolean useXMLIndex)
+  /** 
+   * routine to search the elements and attributes looking to match query
+   *
+   * @param xmlquery the xml serialization of the query (@see pathquery.dtd)
+   * @param user the username of the user
+   * @param group the group of the user
+   */
+  public Hashtable findDocuments(Reader xmlquery, String user, String group)
   {
-    return findDocuments(xmlquery, user, group, null, useXMLIndex);
+    return findDocuments(xmlquery, user, group, true);
   }
-  
-  public Hashtable findDocuments(Reader xmlquery, String user, String group,
-                                 String[] returndoc)
-  {
-    return findDocuments(xmlquery, user, group, returndoc, true);
-  }
 
   /** 
    * routine to search the elements and attributes looking to match query
@@ -194,10 +194,10 @@
    * @param xmlquery the xml serialization of the query (@see pathquery.dtd)
    * @param user the username of the user
    * @param group the group of the user
-   * @param returndoc an array of document types to backtrack against.
+   * @param useXMLIndex flag whether to search using the path index
    */
   public Hashtable findDocuments(Reader xmlquery, String user, String group,
-                                 String[] returndoc, boolean useXMLIndex)
+                                 boolean useXMLIndex)
   {
       Hashtable   docListResult = new Hashtable();
       PreparedStatement pstmt = null;
@@ -212,17 +212,7 @@
       Connection dbconn = null;
       int rev = 0;
       StringBuffer document = null; 
-      Vector returndocVec = new Vector();
       
-      //add the returndoc elements to a vector for easier manipulation
-      if (returndoc != null)
-      {
-        for(int i=0; i<returndoc.length; i++)
-        {
-          returndocVec.add(new String((String)returndoc[i]));
-        }
-      }
-      
       try {
         if (conn == null || conn.isClosed()) {
           dbconn = util.openDBConnection();
@@ -253,10 +243,12 @@
           updateDate = rs.getString(5);
           rev = rs.getInt(6);
 
-          //if there are returndocs to match, backtracking can be performed
-          // If no package exists, do not return the document
+          // if there are returndocs to match, backtracking can be performed
+          // otherwise, just return the document that was hit
+          Vector returndocVec = qspec.getReturnDocList();
           if (returndocVec.size() != 0 && !returndocVec.contains(doctype))
           { 
+            MetaCatUtil.debugMessage("Back tracing now...");
             String sep = util.getOption("accNumSeparator");
             StringBuffer btBuf = new StringBuffer();
             btBuf.append("select docid from xml_relation where ");
Index: src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 744)
+++ src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 745)
@@ -480,13 +480,8 @@
     String xmlquery = ((String[])params.get("query"))[0];
     String qformat = ((String[])params.get("qformat"))[0];
     String resultdoc = null;
-    String[] returndoc = null;
-    if(params.contains("returndoctype"))
-    {
-      returndoc = (String[])params.get("returndoctype");
-    }
     
-    Hashtable doclist = runQuery(xmlquery, user, group, returndoc);
+    Hashtable doclist = runQuery(xmlquery, user, group);
 
     resultdoc = createResultDocument(doclist, transformQuery(xmlquery));
     
@@ -513,18 +508,8 @@
                  HttpServletResponse response, String user, String group)
   {
     //create the query and run it
-    String[] returndoc = null;
-    if(params.containsKey("returndoctype"))
-    {
-      returndoc = (String[])params.get("returndoctype");
-      if (((String)returndoc[0]).equals("any") ||
-          ((String)returndoc[0]).equals("ANY") ||
-          ((String)returndoc[0]).equals("")) {
-        returndoc = null;
-      }
-    }
     String xmlquery = DBQuery.createSQuery(params);
-    Hashtable doclist = runQuery(xmlquery, user, group, returndoc);
+    Hashtable doclist = runQuery(xmlquery, user, group);
     String qformat = ((String[])params.get("qformat"))[0];
     String resultdoc = null;
     
@@ -579,8 +564,7 @@
    *
    * @param xmlquery the query to run
    */
-  private Hashtable runQuery(String xmlquery, String user, String group, 
-                             String[] returndoc)
+  private Hashtable runQuery(String xmlquery, String user, String group)
   {
     Hashtable doclist=null;
     Connection conn = null;
@@ -588,8 +572,7 @@
     {
       conn = util.getConnection();
       DBQuery queryobj = new DBQuery(conn, saxparser);
-      doclist = queryobj.findDocuments(new StringReader(xmlquery),user,group,
-                                       returndoc);
+      doclist = queryobj.findDocuments(new StringReader(xmlquery),user,group);
       util.returnConnection(conn);
       return doclist;
     } 
