1 |
562
|
berkley
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Purpose: a class to handle document info request xml strings
|
4 |
|
|
* Copyright: 2000 Regents of the University of California and the
|
5 |
|
|
* National Center for Ecological Analysis and Synthesis
|
6 |
|
|
* Authors: Chad Berkley
|
7 |
|
|
*
|
8 |
|
|
* '$Author$'
|
9 |
|
|
* '$Date$'
|
10 |
|
|
* '$Revision$'
|
11 |
669
|
jones
|
*
|
12 |
|
|
* This program is free software; you can redistribute it and/or modify
|
13 |
|
|
* it under the terms of the GNU General Public License as published by
|
14 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
15 |
|
|
* (at your option) any later version.
|
16 |
|
|
*
|
17 |
|
|
* This program is distributed in the hope that it will be useful,
|
18 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
|
|
* GNU General Public License for more details.
|
21 |
|
|
*
|
22 |
|
|
* You should have received a copy of the GNU General Public License
|
23 |
|
|
* along with this program; if not, write to the Free Software
|
24 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
25 |
562
|
berkley
|
*/
|
26 |
|
|
|
27 |
|
|
package edu.ucsb.nceas.metacat;
|
28 |
|
|
|
29 |
|
|
import java.sql.*;
|
30 |
|
|
import java.util.Stack;
|
31 |
|
|
import java.util.Vector;
|
32 |
|
|
import java.util.Enumeration;
|
33 |
|
|
import java.util.EmptyStackException;
|
34 |
|
|
import java.util.Hashtable;
|
35 |
|
|
|
36 |
|
|
import org.xml.sax.Attributes;
|
37 |
|
|
import org.xml.sax.SAXException;
|
38 |
|
|
import org.xml.sax.SAXParseException;
|
39 |
|
|
import org.xml.sax.ext.DeclHandler;
|
40 |
|
|
import org.xml.sax.ext.LexicalHandler;
|
41 |
|
|
import org.xml.sax.helpers.DefaultHandler;
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* A Class implementing callback bethods for the SAX parser to
|
45 |
|
|
* call when processing the XML messages from the replication handler
|
46 |
|
|
*/
|
47 |
|
|
public class DocInfoHandler extends DefaultHandler
|
48 |
|
|
{
|
49 |
|
|
private Hashtable docinfo = new Hashtable();
|
50 |
|
|
private String currentTag = null;
|
51 |
|
|
|
52 |
4448
|
leinfelder
|
private Vector accessControlList = new Vector();
|
53 |
4419
|
leinfelder
|
|
54 |
562
|
berkley
|
public DocInfoHandler()
|
55 |
|
|
{
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
/**
|
59 |
|
|
* capture the name of the tag.
|
60 |
|
|
*/
|
61 |
|
|
public void startElement(String uri, String localName, String qName,
|
62 |
|
|
Attributes attributes) throws SAXException
|
63 |
|
|
{
|
64 |
|
|
currentTag = localName;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
4419
|
leinfelder
|
public void endElement (String uri, String localName, String qName)
|
68 |
|
|
throws SAXException
|
69 |
|
|
{
|
70 |
4446
|
leinfelder
|
if (localName.equals("access")) {
|
71 |
4419
|
leinfelder
|
//harvest the latest values from the Map
|
72 |
|
|
String docid = (String) docinfo.get("docid");
|
73 |
|
|
String principal = (String) docinfo.get("principal");
|
74 |
|
|
String permission = (String) docinfo.get("permission");
|
75 |
|
|
String permType = (String) docinfo.get("permType");
|
76 |
|
|
String permOrder = (String) docinfo.get("permOrder");
|
77 |
|
|
AccessControlForSingleFile acfsf = null;
|
78 |
|
|
try {
|
79 |
|
|
acfsf = new AccessControlForSingleFile(docid, principal, permission, permType, permOrder);
|
80 |
|
|
} catch (Exception e) {
|
81 |
|
|
// TODO Auto-generated catch block
|
82 |
|
|
e.printStackTrace();
|
83 |
|
|
}
|
84 |
4448
|
leinfelder
|
accessControlList.add(acfsf);
|
85 |
4419
|
leinfelder
|
}
|
86 |
|
|
//save the list when we are done
|
87 |
4448
|
leinfelder
|
if (localName.equals("accessControl")) {
|
88 |
|
|
docinfo.put("accessControl", accessControlList);
|
89 |
4419
|
leinfelder
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
562
|
berkley
|
/**
|
93 |
|
|
* put the content and the name of the tag into the hashtable. the name of
|
94 |
|
|
* the tag is the key.
|
95 |
|
|
*/
|
96 |
|
|
public void characters(char[] ch, int start, int length) throws SAXException
|
97 |
|
|
{
|
98 |
|
|
docinfo.put(currentTag, new String(ch, start, length));
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
public Hashtable getDocInfo()
|
102 |
|
|
{
|
103 |
|
|
return docinfo;
|
104 |
|
|
}
|
105 |
|
|
}
|