Project

General

Profile

« Previous | Next » 

Revision 5199

Added by daigle over 14 years ago

Reformat file. No code change.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImplWrapper.java
38 38
 * provide deferent parser base on xml document validation by dtd or schema
39 39
 */
40 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
41
public class DocumentImplWrapper {
60 42

  
61
  public String write(DBConnection conn, String xml, String pub, Reader dtd,
62
                      String action, String docid, String user, String[] groups)
63
                      throws Exception
64
  {
65
    return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user, 
66
                              groups, ruleBase, needValidation);
67
  }
68
  
69
  public String writeReplication(DBConnection conn, String xml, 
70
                                        String pub, Reader dtd, String action, 
71
                                        String accnum, String user,
72
                                        String[] groups,String homeServer, 
73
                                        String notifyServer, String createDate,
74
                                        String updateDate)
75
                                        throws Exception
76
  {
77
    //we don't need to check validation in replication
78
    // 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
    return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, 
82
                                        accnum, user, groups, homeServer, 
83
                                        notifyServer, ruleBase, false, 
84
                                        DocumentImpl.DOCUMENTTABLE, false, 
85
                                        createDate, updateDate);
86
                                        // last false means is not timed replication
87
                         
88
  }
89
  
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, String xml, 
108
          String pub, Reader dtd, String action, 
109
          String accnum, String user,
110
          String[] groups,String homeServer, 
111
          String notifyServer, String tableName, 
112
          boolean timedReplication, String createDate, String updateDate)
113
          throws Exception
114
  {
115
   //we don't need to check validation in replication
116
   // 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
          notifyServer, ruleBase, false, tableName, 
120
          timedReplication, createDate, updateDate);
121
  }
43
	/* Attributes */
44
	private String ruleBase = null;
45
	private boolean needValidation = false;
122 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
		ruleBase = myRuleBase;
54
		needValidation = validation;
55

  
56
	}//Constructor
57

  
58
	public String write(DBConnection conn, String xml, String pub, Reader dtd,
59
			String action, String docid, String user, String[] groups) throws Exception {
60
		return DocumentImpl.write(conn, xml, pub, dtd, action, docid, user, groups,
61
				ruleBase, needValidation);
62
	}
63

  
64
	public String writeReplication(DBConnection conn, String xml, String pub, Reader dtd,
65
			String action, String accnum, String user, String[] groups,
66
			String homeServer, String notifyServer, String createDate, String updateDate)
67
			throws Exception {
68
		//we don't need to check validation in replication
69
		// so rule base is null and need validation is false (first false)
70
		// this method is for force replication. so the table name is xml_documents
71
		// and timed replication is false (last false)
72
		return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, accnum, user,
73
				groups, homeServer, notifyServer, ruleBase, false,
74
				DocumentImpl.DOCUMENTTABLE, false, createDate, updateDate);
75
		// last false means is not timed replication
76

  
77
	}
78

  
79
	/**
80
	 * Constructor with tableName - this doc is in xml_documents or xml_revsions
81
	 * If in xml_revisions, it need a special handler.
82
	 * @param conn
83
	 * @param xml
84
	 * @param pub
85
	 * @param dtd
86
	 * @param action
87
	 * @param accnum
88
	 * @param user
89
	 * @param groups
90
	 * @param homeServer
91
	 * @param notifyServer
92
	 * @param tableName
93
	 * @return
94
	 * @throws Exception
95
	 */
96
	public String writeReplication(DBConnection conn, String xml, String pub, Reader dtd,
97
			String action, String accnum, String user, String[] groups,
98
			String homeServer, String notifyServer, String tableName,
99
			boolean timedReplication, String createDate, String updateDate)
100
			throws Exception {
101
		//we don't need to check validation in replication
102
		// so rule base is null and need validation is false
103
		return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, accnum, user,
104
				groups, homeServer, notifyServer, ruleBase, false, tableName,
105
				timedReplication, createDate, updateDate);
106
	}
107

  
123 108
}

Also available in: Unified diff