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
import org.xml.sax.ContentHandler;
32
import org.xml.sax.DTDHandler;
33
import org.xml.sax.EntityResolver;
34
import org.xml.sax.ErrorHandler;
35
import org.xml.sax.InputSource;
36
import org.xml.sax.XMLReader;
37
import org.xml.sax.SAXException;
38
import org.xml.sax.SAXParseException;
39
import org.xml.sax.helpers.XMLReaderFactory;
40
41 3034 perry
//import edu.ucsb.nceas.metacat.spatial.MetacatSpatialDocument;
42 2912 harris
43 1382 tao
/**
44
 * This class a wrapper class for documentimpl for insert or update. It will
45
 * provide deferent parser base on xml document validation by dtd or schema
46
 */
47
48
public class DocumentImplWrapper
49
{
50
51
   /* Attributes */
52
   private String    ruleBase               = null;
53
   private boolean   needValidation         = false;
54
55
56
   /**
57
    *  Constructor of DocumentImpleWrapper
58
    *  @param myRuleBase  the xml is base on DTD or Schema
59
    *  @param validation  if the xml document need to be validated
60
    */
61
  public DocumentImplWrapper(String myRuleBase, boolean validation)
62
  {
63
     ruleBase       = myRuleBase;
64
     needValidation = validation;
65
66
  }//Constructor
67
68
  public String write(DBConnection conn,Reader xml,String pub,Reader dtd,
69 3230 tao
                      String action, String docid, String user, String[] groups)
70 1382 tao
                      throws Exception
71
  {
72
    return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user,
73 3230 tao
                              groups, ruleBase, needValidation);
74 1382 tao
  }
75
76 1560 tao
  public String writeReplication(DBConnection conn, Reader xml,
77 1382 tao
                                        String pub, Reader dtd, String action,
78
                                        String accnum, String user,
79
                                        String[] groups,String homeServer,
80 2622 tao
                                        String notifyServer, String createDate,
81 3230 tao
                                        String updateDate)
82 1382 tao
                                        throws Exception
83
  {
84
    //we don't need to check validation in replciation
85 2608 tao
    // so rule base is null and need validation is false (first false)
86
    // this method is for force replication. so the table name is xml_documents
87
     // and timed replication is false (last false)
88 1382 tao
    return DocumentImpl.writeReplication(conn, xml, pub, dtd, action,
89
                                        accnum, user, groups, homeServer,
90 2608 tao
                                        notifyServer, ruleBase, false,
91 2622 tao
                                        DocumentImpl.DOCUMENTTABLE, false,
92 3230 tao
                                        createDate, updateDate);
93 2608 tao
                                        // last false means is not timed replication
94
95 1382 tao
  }
96 2608 tao
97
  /**
98
   * Constructor with tableName - this doc is in xml_documents or xml_revsions
99
   * If in xml_revisions, it need a special handler.
100
   * @param conn
101
   * @param xml
102
   * @param pub
103
   * @param dtd
104
   * @param action
105
   * @param accnum
106
   * @param user
107
   * @param groups
108
   * @param homeServer
109
   * @param notifyServer
110
   * @param tableName
111
   * @return
112
   * @throws Exception
113
   */
114
  public String writeReplication(DBConnection conn, Reader xml,
115
          String pub, Reader dtd, String action,
116
          String accnum, String user,
117
          String[] groups,String homeServer,
118 2622 tao
          String notifyServer, String tableName,
119 3230 tao
          boolean timedReplication, String createDate, String updateDate)
120 2608 tao
          throws Exception
121
  {
122
   //we don't need to check validation in replciation
123
   // so rule base is null and need validation is false
124
   return DocumentImpl.writeReplication(conn, xml, pub, dtd, action,
125
          accnum, user, groups, homeServer,
126 2622 tao
          notifyServer, ruleBase, false, tableName,
127 3230 tao
          timedReplication, createDate, updateDate);
128 2608 tao
  }
129 1382 tao
}//DocumentImple