|
From: <tr...@us...> - 2003-06-27 02:06:01
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal
In directory sc8-pr-cvs1:/tmp/cvs-serv31771/src/com/babeldoc/sql/journal
Modified Files:
GenericSqlJournal.java MySqlJournal.java OracleJournal.java
Log Message:
Reformatted and updated license header
Index: GenericSqlJournal.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal/GenericSqlJournal.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** GenericSqlJournal.java 29 May 2003 00:17:22 -0000 1.6
--- GenericSqlJournal.java 27 Jun 2003 02:05:58 -0000 1.7
***************
*** 1,22 ****
! /*
! * $Header$
! * $DateTime: 2002/07/21 17:01:20 $
*
*
! * babeldoc: universal document processor
*
! * This program is free software; you can redistribute it and/or
! * modify it under the terms of the GNU General Public License
! * as published by the Free Software Foundation; either version 2
[...1409 lines suppressed...]
! }
! pstmt.setString(3, key);
! pstmt.setString(4, value);
! pstmt.executeUpdate();
}
} catch (Exception e) {
! LogService.getInstance().logError(e);
! throw new SQLException(e.toString());
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
! } catch (Exception e) {
! LogService.getInstance().logError(I18n.get("sql.403"), e);
}
}
}
}
Index: MySqlJournal.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal/MySqlJournal.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MySqlJournal.java 29 May 2003 00:17:23 -0000 1.5
--- MySqlJournal.java 27 Jun 2003 02:05:58 -0000 1.6
***************
*** 1,22 ****
! /*
! * $Header$
! * $DateTime: 2002/07/23 23:18:23 $
*
*
! * babeldoc: universal document processor
*
! * This program is free software; you can redistribute it and/or
! * modify it under the terms of the GNU General Public License
! * as published by the Free Software Foundation; either version 2
! * of the License, or (at your option) any later version.
*
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.babeldoc.sql.journal;
--- 1,66 ----
! /* ====================================================================
! * The Apache Software License, Version 1.1
*
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
*
! * Redistribution and use in source and binary forms, with or without
! * modification, are permitted provided that the following conditions
! * are met:
*
! * 1. Redistributions of source code must retain the above copyright
! * notice, this list of conditions and the following disclaimer.
*
! * 2. Redistributions in binary form must reproduce the above copyright
! * notice, this list of conditions and the following disclaimer in
! * the documentation and/or other materials provided with the
! * distribution.
! *
! * 3. The end-user documentation included with the redistribution,
! * if any, must include the following acknowledgment:
! * "This product includes software developed by the
! * Apache Software Foundation (http://www.apache.org/)."
! * Alternately, this acknowledgment may appear in the software itself,
! * if and wherever such third-party acknowledgments normally appear.
! *
! * 4. The names "Apache" and "Apache Software Foundation" must
! * not be used to endorse or promote products derived from this
! * software without prior written permission. For written
! * permission, please contact ap...@ap....
! *
! * 5. Products derived from this software may not be called "Apache",
! * nor may "Apache" appear in their name, without prior written
! * permission of the Apache Software Foundation.
! *
! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! * SUCH DAMAGE.
! * ====================================================================
! *
! * This software consists of voluntary contributions made by many
! * individuals on behalf of the Apache Software Foundation. For more
! * information on the Apache Software Foundation, please see
! * <http://www.apache.org/>.
! *
! * Portions of this software are based upon public domain software
! * originally written at the National Center for Supercomputing Applications,
! * University of Illinois, Urbana-Champaign.
! * ====================================================================
! *
! * Babeldoc: The Universal Document Processor
! *
! * $Header$
! * $DateTime$
! * $Author$
*
*/
package com.babeldoc.sql.journal;
***************
*** 24,32 ****
--- 68,79 ----
import com.babeldoc.core.I18n;
import com.babeldoc.core.LogService;
+ import com.babeldoc.core.pipeline.PipelineDocument;
import com.babeldoc.core.journal.query.JournalQuery;
+
import com.babeldoc.sql.util.SqlQueryManager;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
***************
*** 36,43 ****
/**
! * The MySqlJournal provides an implementation of the journal for MySQL databases.
! * Most of the implementation is in the GenericSqlJournal. I suspect that other
! * than the screwy oracle implementation lots of databases can use this implemenation
! * since it seems to follow the standards (!) for writing binary objects to databases.
*
* @author bmcdonald
--- 83,91 ----
/**
! * The MySqlJournal provides an implementation of the journal for MySQL
! * databases. Most of the implementation is in the GenericSqlJournal. I
! * suspect that other than the screwy oracle implementation lots of databases
! * can use this implemenation since it seems to follow the standards (!) for
! * writing binary objects to databases.
*
* @author bmcdonald
***************
*** 45,59 ****
*/
public class MySqlJournal extends GenericSqlJournal {
! public final static String DELTA_MAKEROW = "journalAddBlankDataRow-mysql";
/**
* writeDelta - Write a document to the rdbms.
* @param con the connection
* @param id the log id
* @param step the log step
*/
protected void writeDelta(Connection con, long id, long step,
! com.babeldoc.core.pipeline.PipelineDocument doc) throws SQLException {
!
String insertStmt = SqlQueryManager.getSqlQuery(DELTA_MAKEROW);
PreparedStatement pstmt = null;
--- 93,143 ----
*/
public class MySqlJournal extends GenericSqlJournal {
! public static final String DELTA_MAKEROW = "journalAddBlankDataRow-mysql";
!
! /**
! * getTicketsProcessQueryString concoct the query string from the bits and
! * pieces. Calls back to the getTicketsProcess...
! *
! * @param jQuery
! *
! * @return
! */
! protected StringBuffer getTicketsProcessQueryString(JournalQuery jQuery) {
! boolean whereAdded;
!
! StringBuffer query = new StringBuffer(SqlQueryManager.getSqlQuery(
! LOG_QUERY_TICKETS));
!
! whereAdded = getTicketsProcessDates(jQuery.getStartDate(),
! jQuery.getEndDate(), query);
! whereAdded = getTicketsProcessJournalOperations(whereAdded, query,
! jQuery.getJournalOperations());
! getTicketsProcessQueryOptions(jQuery.getQueryOptions(), query);
!
! // Limit stuff
! if (jQuery.getStartIndex() > 0) {
! query.append(" limit " + jQuery.getStartIndex() + ", " +
! jQuery.getNumResults());
!
! // HACK ALERT - need to do this to stop the parent skipping
! // on the result set.
! jQuery.setStartIndex(0);
! }
!
! return query;
! }
/**
* writeDelta - Write a document to the rdbms.
+ *
* @param con the connection
* @param id the log id
* @param step the log step
+ * @param doc DOCUMENT ME!
+ *
+ * @throws SQLException DOCUMENT ME!
*/
protected void writeDelta(Connection con, long id, long step,
! PipelineDocument doc) throws SQLException {
String insertStmt = SqlQueryManager.getSqlQuery(DELTA_MAKEROW);
PreparedStatement pstmt = null;
***************
*** 98,133 ****
}
}
- }
-
- /**
- * getTicketsProcessQueryString concoct the query string from the bits and
- * pieces. Calls back to the getTicketsProcess...
- *
- * @param jQuery
- * @return
- */
- protected StringBuffer getTicketsProcessQueryString(JournalQuery jQuery) {
- boolean whereAdded;
-
- StringBuffer query = new StringBuffer(SqlQueryManager.getSqlQuery(
- LOG_QUERY_TICKETS));
-
- whereAdded = getTicketsProcessDates(jQuery.getStartDate(),
- jQuery.getEndDate(), query);
- whereAdded = getTicketsProcessJournalOperations(whereAdded, query,
- jQuery.getJournalOperations());
- getTicketsProcessQueryOptions(jQuery.getQueryOptions(), query);
-
- // Limit stuff
- if (jQuery.getStartIndex() > 0) {
- query.append(" limit " + jQuery.getStartIndex() + ", " +
- jQuery.getNumResults());
-
- // HACK ALERT - need to do this to stop the parent skipping
- // on the result set.
- jQuery.setStartIndex(0);
- }
-
- return query;
}
}
--- 182,185 ----
Index: OracleJournal.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal/OracleJournal.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OracleJournal.java 22 May 2003 03:20:32 -0000 1.4
--- OracleJournal.java 27 Jun 2003 02:05:58 -0000 1.5
***************
*** 1,58 ****
! /*
! * $Header$
! * $DateTime: 2002/07/07 18:09:19 $
*
*
! * babeldoc: universal document processor
*
! * This program is free software; you can redistribute it and/or
! * modify it under the terms of the GNU General Public License
! * as published by the Free Software Foundation; either version 2
! * of the License, or (at your option) any later version.
*
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package com.babeldoc.sql.journal;
import com.babeldoc.core.LogService;
import com.babeldoc.sql.util.SqlQueryManager;
import oracle.sql.BLOB;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.sql.*;
/**
! * <p>Title: OracleJournal</p>
! * <p>Description: Provides oracle specific code for writing blobs down
! * to the rdbms. It would have been nice if it was available from the jdbc sdk
! * but alas, it is not.</p>
*
* @author bmcdonald
* @version 1.0
*/
! public class OracleJournal extends GenericSqlJournal {
! public final static String DELTA_MAKEROW = "journalAddBlankDataRow-oracle";
! public final static String SELECT_BLOB = "journalSelectBlobForUpdate-oracle";
/**
* writeDelta - this method involves lots of db specific trickery (in this
* case ORACLE).
* @param con the connection
* @param id the log id
* @param step the log step
* @param doc the object to write out
*/
! protected void writeDelta(Connection con, long id, long step, com.babeldoc.core.pipeline.PipelineDocument doc)
! throws SQLException {
!
LogService.getInstance().logDebug("[Oracle.writeDelta] called");
String insertStmt = SqlQueryManager.getSqlQuery(DELTA_MAKEROW);
String selectBlobStmt = SqlQueryManager.getSqlQuery(SELECT_BLOB);
--- 1,116 ----
! /* ====================================================================
! * The Apache Software License, Version 1.1
*
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
*
! * Redistribution and use in source and binary forms, with or without
! * modification, are permitted provided that the following conditions
! * are met:
*
! * 1. Redistributions of source code must retain the above copyright
! * notice, this list of conditions and the following disclaimer.
*
! * 2. Redistributions in binary form must reproduce the above copyright
! * notice, this list of conditions and the following disclaimer in
! * the documentation and/or other materials provided with the
! * distribution.
! *
! * 3. The end-user documentation included with the redistribution,
! * if any, must include the following acknowledgment:
! * "This product includes software developed by the
! * Apache Software Foundation (http://www.apache.org/)."
! * Alternately, this acknowledgment may appear in the software itself,
! * if and wherever such third-party acknowledgments normally appear.
! *
! * 4. The names "Apache" and "Apache Software Foundation" must
! * not be used to endorse or promote products derived from this
! * software without prior written permission. For written
! * permission, please contact ap...@ap....
! *
! * 5. Products derived from this software may not be called "Apache",
! * nor may "Apache" appear in their name, without prior written
! * permission of the Apache Software Foundation.
! *
! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! * SUCH DAMAGE.
! * ====================================================================
! *
! * This software consists of voluntary contributions made by many
! * individuals on behalf of the Apache Software Foundation. For more
! * information on the Apache Software Foundation, please see
! * <http://www.apache.org/>.
! *
! * Portions of this software are based upon public domain software
! * originally written at the National Center for Supercomputing Applications,
! * University of Illinois, Urbana-Champaign.
! * ====================================================================
! *
! * Babeldoc: The Universal Document Processor
! *
! * $Header$
! * $DateTime$
! * $Author$
*
*/
package com.babeldoc.sql.journal;
import com.babeldoc.core.LogService;
+ import com.babeldoc.core.pipeline.PipelineDocument;
+
import com.babeldoc.sql.util.SqlQueryManager;
+
import oracle.sql.BLOB;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
+
import java.sql.*;
+
/**
! * <p>
! * Title: OracleJournal
! * </p>
! *
! * <p>
! * Description: Provides oracle specific code for writing blobs down to the
! * rdbms. It would have been nice if it was available from the jdbc sdk but
! * alas, it is not.
! * </p>
*
* @author bmcdonald
* @version 1.0
*/
! public class OracleJournal
! extends GenericSqlJournal {
! public static final String DELTA_MAKEROW = "journalAddBlankDataRow-oracle";
! public static final String SELECT_BLOB = "journalSelectBlobForUpdate-oracle";
/**
* writeDelta - this method involves lots of db specific trickery (in this
* case ORACLE).
+ *
* @param con the connection
* @param id the log id
* @param step the log step
* @param doc the object to write out
+ *
+ * @throws SQLException DOCUMENT ME!
*/
! protected void writeDelta(Connection con, long id, long step,
! PipelineDocument doc) throws SQLException {
LogService.getInstance().logDebug("[Oracle.writeDelta] called");
+
String insertStmt = SqlQueryManager.getSqlQuery(DELTA_MAKEROW);
String selectBlobStmt = SqlQueryManager.getSqlQuery(SELECT_BLOB);
***************
*** 60,63 ****
--- 118,122 ----
ResultSet rset = null;
OutputStream ostream = null;
+
try {
LogService.getInstance().logDebug("[Oracle.writeDelta] Creating journal row");
***************
*** 76,86 ****
--- 135,148 ----
//getLog().debug("Getting blob");
rset.next();
+
Blob blob = rset.getBlob(1);
//getLog().debug("Streaming out blob");
ostream = ((BLOB) blob).getBinaryOutputStream();
+
ObjectOutputStream oostream = new ObjectOutputStream(ostream);
oostream.writeObject(doc);
writeExtraData(con, id, step, doc);
+
//must be closed before commit
oostream.close();
***************
*** 88,101 ****
LogService.getInstance().logDebug("Commited");
-
} catch (Exception e) {
! com.babeldoc.core.LogService.getInstance().logError("Error updating document", e);
con.rollback();
throw new SQLException(e.toString());
} finally {
try {
! if (pstmt != null) pstmt.close();
! if (rset != null) rset.close();
! if (ostream != null) ostream.close();
} catch (Exception e) {
com.babeldoc.core.LogService.getInstance().logError("Closing objects", e);
--- 150,171 ----
LogService.getInstance().logDebug("Commited");
} catch (Exception e) {
! com.babeldoc.core.LogService.getInstance().logError("Error updating document",
! e);
con.rollback();
throw new SQLException(e.toString());
} finally {
try {
! if (pstmt != null) {
! pstmt.close();
! }
!
! if (rset != null) {
! rset.close();
! }
!
! if (ostream != null) {
! ostream.close();
! }
} catch (Exception e) {
com.babeldoc.core.LogService.getInstance().logError("Closing objects", e);
|