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