Project

General

Profile

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