1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Purpose: A Class that loads eml-access.xml file containing ACL
|
4
|
* for a metadata document into relational DB
|
5
|
* Copyright: 2000 Regents of the University of California and the
|
6
|
* National Center for Ecological Analysis and Synthesis
|
7
|
* Authors: Jing Tao
|
8
|
*
|
9
|
* '$Author: daigle $'
|
10
|
* '$Date: 2008-11-03 10:59:59 -0800 (Mon, 03 Nov 2008) $'
|
11
|
* '$Revision: 4499 $'
|
12
|
*
|
13
|
* This program is free software; you can redistribute it and/or modify
|
14
|
* it under the terms of the GNU General Public License as published by
|
15
|
* the Free Software Foundation; either version 2 of the License, or
|
16
|
* (at your option) any later version.
|
17
|
*
|
18
|
* This program is distributed in the hope that it will be useful,
|
19
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
* GNU General Public License for more details.
|
22
|
*
|
23
|
* You should have received a copy of the GNU General Public License
|
24
|
* along with this program; if not, write to the Free Software
|
25
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26
|
*/
|
27
|
|
28
|
package edu.ucsb.nceas.metacat;
|
29
|
|
30
|
import java.io.Reader;
|
31
|
|
32
|
//import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
|
33
|
|
34
|
/**
|
35
|
* This class a wrapper class for documentimpl for insert or update. It will
|
36
|
* provide deferent parser base on xml document validation by dtd or schema
|
37
|
*/
|
38
|
|
39
|
public class DocumentImplWrapper
|
40
|
{
|
41
|
|
42
|
/* Attributes */
|
43
|
private String ruleBase = null;
|
44
|
private boolean needValidation = false;
|
45
|
|
46
|
|
47
|
/**
|
48
|
* Constructor of DocumentImpleWrapper
|
49
|
* @param myRuleBase the xml is base on DTD or Schema
|
50
|
* @param validation if the xml document need to be validated
|
51
|
*/
|
52
|
public DocumentImplWrapper(String myRuleBase, boolean validation)
|
53
|
{
|
54
|
ruleBase = myRuleBase;
|
55
|
needValidation = validation;
|
56
|
|
57
|
}//Constructor
|
58
|
|
59
|
public String write(DBConnection conn,Reader xml,String pub,Reader dtd,
|
60
|
String action, String docid, String user, String[] groups)
|
61
|
throws Exception
|
62
|
{
|
63
|
return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user,
|
64
|
groups, ruleBase, needValidation);
|
65
|
}
|
66
|
|
67
|
public String writeReplication(DBConnection conn, Reader xml,
|
68
|
String pub, Reader dtd, String action,
|
69
|
String accnum, String user,
|
70
|
String[] groups,String homeServer,
|
71
|
String notifyServer, String createDate,
|
72
|
String updateDate)
|
73
|
throws Exception
|
74
|
{
|
75
|
//we don't need to check validation in replication
|
76
|
// so rule base is null and need validation is false (first false)
|
77
|
// this method is for force replication. so the table name is xml_documents
|
78
|
// and timed replication is false (last false)
|
79
|
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action,
|
80
|
accnum, user, groups, homeServer,
|
81
|
notifyServer, ruleBase, false,
|
82
|
DocumentImpl.DOCUMENTTABLE, false,
|
83
|
createDate, updateDate);
|
84
|
// last false means is not timed replication
|
85
|
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* Constructor with tableName - this doc is in xml_documents or xml_revsions
|
90
|
* If in xml_revisions, it need a special handler.
|
91
|
* @param conn
|
92
|
* @param xml
|
93
|
* @param pub
|
94
|
* @param dtd
|
95
|
* @param action
|
96
|
* @param accnum
|
97
|
* @param user
|
98
|
* @param groups
|
99
|
* @param homeServer
|
100
|
* @param notifyServer
|
101
|
* @param tableName
|
102
|
* @return
|
103
|
* @throws Exception
|
104
|
*/
|
105
|
public String writeReplication(DBConnection conn, Reader xml,
|
106
|
String pub, Reader dtd, String action,
|
107
|
String accnum, String user,
|
108
|
String[] groups,String homeServer,
|
109
|
String notifyServer, String tableName,
|
110
|
boolean timedReplication, String createDate, String updateDate)
|
111
|
throws Exception
|
112
|
{
|
113
|
//we don't need to check validation in replication
|
114
|
// so rule base is null and need validation is false
|
115
|
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action,
|
116
|
accnum, user, groups, homeServer,
|
117
|
notifyServer, ruleBase, false, tableName,
|
118
|
timedReplication, createDate, updateDate);
|
119
|
}
|
120
|
|
121
|
}
|