1
|
/**
|
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: daigle $'
|
9
|
* '$Date: 2008-10-29 11:43:02 -0700 (Wed, 29 Oct 2008) $'
|
10
|
* '$Revision: 4486 $'
|
11
|
*
|
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
|
*/
|
26
|
|
27
|
package edu.ucsb.nceas.metacat;
|
28
|
|
29
|
import java.util.Vector;
|
30
|
import java.util.Hashtable;
|
31
|
|
32
|
import org.xml.sax.Attributes;
|
33
|
import org.xml.sax.SAXException;
|
34
|
import org.xml.sax.helpers.DefaultHandler;
|
35
|
|
36
|
/**
|
37
|
* A Class implementing callback bethods for the SAX parser to
|
38
|
* call when processing the XML messages from the replication handler
|
39
|
*/
|
40
|
public class DocInfoHandler extends DefaultHandler
|
41
|
{
|
42
|
private Hashtable<String,String> docinfo = new Hashtable<String,String>();
|
43
|
// private Hashtable<String, Vector<AccessControlForSingleFile>> accessControlInfo =
|
44
|
// new Hashtable<String, Vector<AccessControlForSingleFile>>();
|
45
|
private String currentTag = null;
|
46
|
|
47
|
private Vector<AccessControlForSingleFile> accessControlList = new Vector<AccessControlForSingleFile>();
|
48
|
|
49
|
public DocInfoHandler()
|
50
|
{
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* capture the name of the tag.
|
55
|
*/
|
56
|
public void startElement(String uri, String localName, String qName,
|
57
|
Attributes attributes) throws SAXException
|
58
|
{
|
59
|
currentTag = localName;
|
60
|
}
|
61
|
|
62
|
public void endElement (String uri, String localName, String qName)
|
63
|
throws SAXException
|
64
|
{
|
65
|
if (localName.equals("access")) {
|
66
|
//harvest the latest values from the Map
|
67
|
String docid = (String) docinfo.get("docid");
|
68
|
String principal = (String) docinfo.get("principal");
|
69
|
String permission = (String) docinfo.get("permission");
|
70
|
String permType = (String) docinfo.get("permType");
|
71
|
String permOrder = (String) docinfo.get("permOrder");
|
72
|
AccessControlForSingleFile acfsf = null;
|
73
|
try {
|
74
|
acfsf = new AccessControlForSingleFile(docid, principal, permission, permType, permOrder);
|
75
|
} catch (Exception e) {
|
76
|
// TODO Auto-generated catch block
|
77
|
e.printStackTrace();
|
78
|
}
|
79
|
accessControlList.add(acfsf);
|
80
|
}
|
81
|
// //save the list when we are done
|
82
|
// if (localName.equals("accessControl")) {
|
83
|
// accessControlInfo.put("accessControl", accessControlList);
|
84
|
// }
|
85
|
}
|
86
|
|
87
|
/**
|
88
|
* put the content and the name of the tag into the hashtable. the name of
|
89
|
* the tag is the key.
|
90
|
*/
|
91
|
public void characters(char[] ch, int start, int length) throws SAXException
|
92
|
{
|
93
|
docinfo.put(currentTag, new String(ch, start, length));
|
94
|
}
|
95
|
|
96
|
public Hashtable<String,String> getDocInfo()
|
97
|
{
|
98
|
return docinfo;
|
99
|
}
|
100
|
|
101
|
public Vector<AccessControlForSingleFile> getAccessControlList() {
|
102
|
return accessControlList;
|
103
|
}
|
104
|
}
|