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: 2010-01-22 10:06:28 -0800 (Fri, 22 Jan 2010) $'
|
11
|
* '$Revision: 5199 $'
|
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.database.DBConnection;
|
33
|
|
34
|
//import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
|
35
|
|
36
|
/**
|
37
|
* This class a wrapper class for documentimpl for insert or update. It will
|
38
|
* provide deferent parser base on xml document validation by dtd or schema
|
39
|
*/
|
40
|
|
41
|
public class DocumentImplWrapper {
|
42
|
|
43
|
/* Attributes */
|
44
|
private String ruleBase = null;
|
45
|
private boolean needValidation = false;
|
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
|
ruleBase = myRuleBase;
|
54
|
needValidation = validation;
|
55
|
|
56
|
}//Constructor
|
57
|
|
58
|
public String write(DBConnection conn, String xml, String pub, Reader dtd,
|
59
|
String action, String docid, String user, String[] groups) throws Exception {
|
60
|
return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user, groups,
|
61
|
ruleBase, needValidation);
|
62
|
}
|
63
|
|
64
|
public String writeReplication(DBConnection conn, String xml, String pub, Reader dtd,
|
65
|
String action, String accnum, String user, String[] groups,
|
66
|
String homeServer, String notifyServer, String createDate, String updateDate)
|
67
|
throws Exception {
|
68
|
//we don't need to check validation in replication
|
69
|
// so rule base is null and need validation is false (first false)
|
70
|
// this method is for force replication. so the table name is xml_documents
|
71
|
// and timed replication is false (last false)
|
72
|
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, accnum, user,
|
73
|
groups, homeServer, notifyServer, ruleBase, false,
|
74
|
DocumentImpl.DOCUMENTTABLE, false, createDate, updateDate);
|
75
|
// last false means is not timed replication
|
76
|
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* Constructor with tableName - this doc is in xml_documents or xml_revsions
|
81
|
* If in xml_revisions, it need a special handler.
|
82
|
* @param conn
|
83
|
* @param xml
|
84
|
* @param pub
|
85
|
* @param dtd
|
86
|
* @param action
|
87
|
* @param accnum
|
88
|
* @param user
|
89
|
* @param groups
|
90
|
* @param homeServer
|
91
|
* @param notifyServer
|
92
|
* @param tableName
|
93
|
* @return
|
94
|
* @throws Exception
|
95
|
*/
|
96
|
public String writeReplication(DBConnection conn, String xml, String pub, Reader dtd,
|
97
|
String action, String accnum, String user, String[] groups,
|
98
|
String homeServer, String notifyServer, String tableName,
|
99
|
boolean timedReplication, String createDate, String updateDate)
|
100
|
throws Exception {
|
101
|
//we don't need to check validation in replication
|
102
|
// so rule base is null and need validation is false
|
103
|
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, accnum, user,
|
104
|
groups, homeServer, notifyServer, ruleBase, false, tableName,
|
105
|
timedReplication, createDate, updateDate);
|
106
|
}
|
107
|
|
108
|
}
|