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