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