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