Project

General

Profile

« Previous | Next » 

Revision 1382

Added by Jing Tao almost 22 years ago

New class to wrap documentimple.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImplWrapper.java
1
/**
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
 *    Release: @release@
9
 *
10
 *   '$Author$'
11
 *     '$Date$'
12
 * '$Revision$'
13
 *
14
 * This program is free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 */
28

  
29
package edu.ucsb.nceas.metacat;
30

  
31
import java.io.Reader;
32
import org.xml.sax.ContentHandler;
33
import org.xml.sax.DTDHandler;
34
import org.xml.sax.EntityResolver;
35
import org.xml.sax.ErrorHandler;
36
import org.xml.sax.InputSource;
37
import org.xml.sax.XMLReader;
38
import org.xml.sax.SAXException;
39
import org.xml.sax.SAXParseException;
40
import org.xml.sax.helpers.XMLReaderFactory;
41

  
42
/**
43
 * This class a wrapper class for documentimpl for insert or update. It will 
44
 * provide deferent parser base on xml document validation by dtd or schema
45
 */
46

  
47
public class DocumentImplWrapper
48
{
49
  
50
   /* Attributes */
51
   private String    ruleBase               = null;
52
   private boolean   needValidation         = false;
53
  
54
   
55
   /**
56
    *  Constructor of DocumentImpleWrapper
57
    *  @param myRuleBase  the xml is base on DTD or Schema
58
    *  @param validation  if the xml document need to be validated
59
    */
60
  public DocumentImplWrapper(String myRuleBase, boolean validation)
61
  {
62
     ruleBase       = myRuleBase;
63
     needValidation = validation;
64
       
65
  }//Constructor
66

  
67
  public String write(DBConnection conn,Reader xml,String pub,Reader dtd,
68
                      String action, String docid, String user, String[] groups)
69
                      throws Exception
70
  {
71
    return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user, 
72
                              groups, ruleBase, needValidation);
73
  }
74
  
75
  public static String writeReplication(DBConnection conn, Reader xml, 
76
                                        String pub, Reader dtd, String action, 
77
                                        String accnum, String user,
78
                                        String[] groups,String homeServer, 
79
                                        String notifyServer)
80
                                        throws Exception
81
  {
82
    //we don't need to check validation in replciation
83
    // so rule base is null and need validation is false
84
    return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, 
85
                                        accnum, user, groups, homeServer, 
86
                                        notifyServer, null, false);
87
  }
88
}//DocumentImple
0 89

  

Also available in: Unified diff