Revision 4335
Added by daigle over 16 years ago
src/edu/ucsb/nceas/metacat/QuerySpecification.java | ||
---|---|---|
33 | 33 |
import java.io.Reader; |
34 | 34 |
import java.io.StringReader; |
35 | 35 |
import java.util.Enumeration; |
36 |
import java.util.Hashtable; |
|
37 | 36 |
import java.util.Stack; |
38 | 37 |
import java.util.Vector; |
39 | 38 |
|
40 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
|
41 | 39 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
42 | 40 |
|
43 | 41 |
import org.apache.log4j.Logger; |
... | ... | |
109 | 107 |
|
110 | 108 |
private String accNumberSeparator = null; |
111 | 109 |
|
112 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
113 |
|
|
114 | 110 |
private boolean percentageSearch = false; |
115 | 111 |
|
116 | 112 |
private String userName = null; |
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
36 | 36 |
import javax.servlet.*; |
37 | 37 |
import javax.servlet.http.*; |
38 | 38 |
|
39 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase;
|
|
39 |
import edu.ucsb.nceas.metacat.service.DatabaseService;
|
|
40 | 40 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
41 | 41 |
import edu.ucsb.nceas.metacat.service.SessionService; |
42 | 42 |
import edu.ucsb.nceas.metacat.util.LDAPUtil; |
43 | 43 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
44 | 44 |
import edu.ucsb.nceas.metacat.util.SessionData; |
45 | 45 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
46 |
import edu.ucsb.nceas.utilities.FileUtil; |
|
47 | 46 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
48 | 47 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
49 | 48 |
|
... | ... | |
52 | 51 |
|
53 | 52 |
public class MetacatReplication extends HttpServlet implements Runnable |
54 | 53 |
{ |
54 |
|
|
55 |
private static final long serialVersionUID = -2898600143193513155L; |
|
55 | 56 |
private long timeInterval; |
56 | 57 |
private Date firstTime; |
57 | 58 |
private boolean timedReplicationIsOn = false; |
58 | 59 |
Timer replicationDaemon; |
59 | 60 |
private Vector fileLocks = new Vector(); |
60 | 61 |
private Thread lockThread = null; |
61 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
62 | 62 |
public static final String FORCEREPLICATEDELETE = "forcereplicatedelete"; |
63 | 63 |
private static final String TIMEREPLICATION = "replication.timedreplication"; |
64 | 64 |
private static final String TIMEREPLICATIONINTERVAl = "replication.timedreplicationinterval"; |
... | ... | |
407 | 407 |
pstmt = dbConn.prepareStatement("INSERT INTO xml_replication " + |
408 | 408 |
"(server, last_checked, replicate, datareplicate, hub) " + |
409 | 409 |
"VALUES ('" + server + "', "+ |
410 |
dbAdapter.toDate("01/01/1980", "MM/DD/YYYY")
|
|
410 |
DatabaseService.getDBAdapter().toDate("01/01/1980", "MM/DD/YYYY")
|
|
411 | 411 |
+ ", '" + |
412 | 412 |
replicate +"', '" +dataReplicate+"', '" |
413 | 413 |
+ hub +"')"); |
... | ... | |
1213 | 1213 |
|
1214 | 1214 |
// Get correct docid that reside on this server according the requesting |
1215 | 1215 |
// server's replicate and data replicate value in xml_replication table |
1216 |
docsql.append(dbAdapter.getReplicationDocumentListSQL());
|
|
1216 |
docsql.append(DatabaseService.getDBAdapter().getReplicationDocumentListSQL());
|
|
1217 | 1217 |
//docsql.append("select docid, rev, doctype from xml_documents where (docid not in (select a.docid from xml_documents a, xml_revisions b where a.docid=b.docid and a.rev<=b.rev)) "); |
1218 | 1218 |
revisionSql.append("select docid, rev, doctype from xml_revisions "); |
1219 | 1219 |
// If the localhost is not a hub to the remote server, only replicate |
src/edu/ucsb/nceas/metacat/IndexingTimerTask.java | ||
---|---|---|
33 | 33 |
import java.util.Vector; |
34 | 34 |
import java.util.Iterator; |
35 | 35 |
|
36 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
|
36 | 37 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
37 | 38 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
38 | 39 |
|
... | ... | |
89 | 90 |
} |
90 | 91 |
|
91 | 92 |
String xmlDocumentsCheck = |
92 |
MetaCatUtil.dbAdapter.getLeftJoinQuery("a.docid, a.rev", "xml_documents",
|
|
93 |
DatabaseService.getDBAdapter().getLeftJoinQuery("a.docid, a.rev", "xml_documents",
|
|
93 | 94 |
"xml_index", "a.docid = b.docid", nonJoinCriteria); |
94 | 95 |
|
95 | 96 |
PreparedStatement xmlDocCheck = dbConn.prepareStatement(xmlDocumentsCheck); |
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
41 | 41 |
import java.sql.ResultSet; |
42 | 42 |
import java.sql.SQLException; |
43 | 43 |
import java.sql.Statement; |
44 |
import java.util.Enumeration; |
|
45 | 44 |
import java.util.Hashtable; |
46 | 45 |
import java.util.HashMap; |
47 | 46 |
import java.util.Iterator; |
... | ... | |
49 | 48 |
import java.util.TreeSet; |
50 | 49 |
import java.util.Vector; |
51 | 50 |
|
52 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase;
|
|
51 |
import edu.ucsb.nceas.metacat.service.DatabaseService;
|
|
53 | 52 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
54 | 53 |
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester; |
55 | 54 |
import edu.ucsb.nceas.metacat.util.LDAPUtil; |
... | ... | |
63 | 62 |
import org.xml.sax.EntityResolver; |
64 | 63 |
import org.xml.sax.ErrorHandler; |
65 | 64 |
import org.xml.sax.InputSource; |
66 |
import org.xml.sax.SAXException; |
|
67 | 65 |
import org.xml.sax.XMLReader; |
68 | 66 |
import org.xml.sax.helpers.XMLReaderFactory; |
69 | 67 |
|
... | ... | |
127 | 125 |
static final int ALL = 1; |
128 | 126 |
static final int WRITE = 2; |
129 | 127 |
static final int READ = 4; |
130 |
protected static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
131 | 128 |
protected DBConnection connection = null; |
132 | 129 |
//protected String updatedVersion = null; |
133 | 130 |
protected String docname = null; |
... | ... | |
459 | 456 |
|
460 | 457 |
PreparedStatement pstmt = null; |
461 | 458 |
int revision = (new Integer(rev)).intValue(); |
462 |
String sqlDateString = dbAdapter.getDateTimeFunction();
|
|
459 |
String sqlDateString = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
463 | 460 |
if (createDate == null) |
464 | 461 |
{ |
465 | 462 |
createDate = sqlDateString; |
466 | 463 |
} |
467 | 464 |
else |
468 | 465 |
{ |
469 |
createDate = dbAdapter.toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
466 |
createDate = DatabaseService.getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
470 | 467 |
} |
471 | 468 |
|
472 | 469 |
if (updateDate == null) |
... | ... | |
475 | 472 |
} |
476 | 473 |
else |
477 | 474 |
{ |
478 |
updateDate = dbAdapter.toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
475 |
updateDate = DatabaseService.getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
479 | 476 |
} |
480 | 477 |
try |
481 | 478 |
{ |
... | ... | |
1001 | 998 |
} else { |
1002 | 999 |
out = new PrintWriter(pw); |
1003 | 1000 |
} |
1004 |
|
|
1001 |
|
|
1005 | 1002 |
// Here add code to handle subtree access control |
1006 | 1003 |
/* |
1007 | 1004 |
* PermissionController control = new PermissionController(docid); |
... | ... | |
1258 | 1255 |
// Any other types of nodes are not handled. |
1259 | 1256 |
// Probably should throw an exception here to indicate this |
1260 | 1257 |
} |
1258 |
|
|
1261 | 1259 |
out.flush(); |
1262 | 1260 |
} |
1263 | 1261 |
|
... | ... | |
1863 | 1861 |
String nodeprefix = null; |
1864 | 1862 |
String nodedata = null; |
1865 | 1863 |
float nodedatanumerical = -1; |
1866 |
String quotechar = dbAdapter.getStringDelimiter();
|
|
1864 |
String quotechar = DatabaseService.getDBAdapter().getStringDelimiter();
|
|
1867 | 1865 |
String table = "xml_nodes"; |
1868 | 1866 |
//System.out.println("in getNodeREcorelist !!!!!!!!!!!for root node id "+rootnodeid); |
1869 | 1867 |
try { |
... | ... | |
1950 | 1948 |
String catalogid, int serverCode, String createDate, String updateDate) throws SQLException, Exception |
1951 | 1949 |
{ |
1952 | 1950 |
//System.out.println("!!!!!!!!1write document to db " +docid +"."+rev); |
1953 |
String sysdate = dbAdapter.getDateTimeFunction();
|
|
1951 |
String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
1954 | 1952 |
if (createDate == null) |
1955 | 1953 |
{ |
1956 | 1954 |
createDate = sysdate; |
1957 | 1955 |
} |
1958 | 1956 |
else |
1959 | 1957 |
{ |
1960 |
createDate = dbAdapter.toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
1958 |
createDate = DatabaseService.getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
1961 | 1959 |
} |
1962 | 1960 |
if (updateDate == null) |
1963 | 1961 |
{ |
... | ... | |
1965 | 1963 |
} |
1966 | 1964 |
else |
1967 | 1965 |
{ |
1968 |
updateDate = dbAdapter.toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
1966 |
updateDate = DatabaseService.getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
1969 | 1967 |
} |
1970 | 1968 |
DocumentImpl thisdoc = null; |
1971 | 1969 |
|
... | ... | |
3187 | 3185 |
private static void archiveDocAndNodesRevison(DBConnection dbconn, String docid, |
3188 | 3186 |
String user, long rootNodeId) throws Exception |
3189 | 3187 |
{ |
3190 |
String sysdate = dbAdapter.getDateTimeFunction();
|
|
3188 |
String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
3191 | 3189 |
//DBConnection conn = null; |
3192 | 3190 |
//int serialNumber = -1; |
3193 | 3191 |
PreparedStatement pstmt = null; |
... | ... | |
3273 | 3271 |
/** Save a document entry in the xml_revisions table */ |
3274 | 3272 |
private static void archiveDocRevision(String docid, String user, DBConnection conn) throws Exception |
3275 | 3273 |
{ |
3276 |
String sysdate = dbAdapter.getDateTimeFunction();
|
|
3274 |
String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
3277 | 3275 |
PreparedStatement pstmt = null; |
3278 | 3276 |
|
3279 | 3277 |
// create a record in xml_revisions table |
... | ... | |
3521 | 3519 |
.prepareStatement("INSERT INTO xml_replication " |
3522 | 3520 |
+ "(server, last_checked, replicate, datareplicate, hub) " |
3523 | 3521 |
+ "VALUES ('" + server + "', " |
3524 |
+ dbAdapter.toDate("01/01/1980", "MM/DD/YYYY")
|
|
3522 |
+ DatabaseService.getDBAdapter().toDate("01/01/1980", "MM/DD/YYYY")
|
|
3525 | 3523 |
+ ", '" + replicate + "', '" + dataReplicate |
3526 | 3524 |
+ "','" + hub + "')"); |
3527 | 3525 |
|
... | ... | |
3717 | 3715 |
|
3718 | 3716 |
if (createDate == null) |
3719 | 3717 |
{ |
3720 |
createDate = dbAdapter.getDateTimeFunction();
|
|
3718 |
createDate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
3721 | 3719 |
} |
3722 | 3720 |
else |
3723 | 3721 |
{ |
3724 |
createDate = dbAdapter.toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
3722 |
createDate = DatabaseService.getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
|
|
3725 | 3723 |
} |
3726 | 3724 |
logMetacat.info("the create date is "+createDate); |
3727 | 3725 |
if (updateDate == null) |
3728 | 3726 |
{ |
3729 |
updateDate = dbAdapter.getDateTimeFunction();
|
|
3727 |
updateDate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
3730 | 3728 |
} |
3731 | 3729 |
else |
3732 | 3730 |
{ |
3733 |
updateDate = dbAdapter.toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
3731 |
updateDate = DatabaseService.getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
|
|
3734 | 3732 |
} |
3735 | 3733 |
logMetacat.info("the update date is "+updateDate); |
3736 | 3734 |
PreparedStatement pstmt = null; |
src/edu/ucsb/nceas/metacat/ReplicationHandler.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
package edu.ucsb.nceas.metacat; |
28 | 28 |
|
29 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase;
|
|
29 |
import edu.ucsb.nceas.metacat.service.DatabaseService;
|
|
30 | 30 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
31 | 31 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
32 | 32 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
64 | 64 |
int serverCheckCode = 1; |
65 | 65 |
ReplicationServerList serverList = null; |
66 | 66 |
//PrintWriter out; |
67 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
67 |
// private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
|
|
68 | 68 |
private static Logger logMetacat = Logger.getLogger(ReplicationHandler.class); |
69 | 69 |
private static int DOCINSERTNUMBER = 1; |
70 | 70 |
private static int DOCERRORNUMBER = 1; |
... | ... | |
613 | 613 |
sql.append(datestr).append("', 'YY-MM-DD HH24:MI:SS') where "); |
614 | 614 |
sql.append("server like '").append(server).append("'");*/ |
615 | 615 |
sql.append("update xml_replication set last_checked = "); |
616 |
sql.append(dbAdapter.toDate(datestr, "MM/DD/YY HH24:MI:SS"));
|
|
616 |
sql.append(DatabaseService.getDBAdapter().toDate(datestr, "MM/DD/YY HH24:MI:SS"));
|
|
617 | 617 |
sql.append(" where server like '").append(server).append("'"); |
618 | 618 |
pstmt = dbConn.prepareStatement(sql.toString()); |
619 | 619 |
|
src/edu/ucsb/nceas/metacat/DBSAXNode.java | ||
---|---|---|
27 | 27 |
package edu.ucsb.nceas.metacat; |
28 | 28 |
|
29 | 29 |
import java.sql.*; |
30 |
import java.io.IOException; |
|
31 | 30 |
import java.util.Hashtable; |
32 | 31 |
import java.util.Enumeration; |
33 |
//import oracle.jdbc.driver.*; |
|
34 | 32 |
import org.apache.log4j.Logger; |
35 | 33 |
import org.xml.sax.SAXException; |
36 | 34 |
|
37 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
|
38 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
|
35 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
|
39 | 36 |
|
40 | 37 |
/** |
41 | 38 |
* A Class that represents an XML node and its contents and |
... | ... | |
45 | 42 |
|
46 | 43 |
private DBConnection connection; |
47 | 44 |
private DBSAXNode parentNode; |
48 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
49 | 45 |
private Logger logMetacat = Logger.getLogger(DBSAXNode.class); |
50 | 46 |
|
51 | 47 |
/** |
... | ... | |
207 | 203 |
pstmt.close(); |
208 | 204 |
|
209 | 205 |
// get the generated unique id afterward |
210 |
nid = dbAdapter.getUniqueID(connection.getConnections(), "xml_nodes");
|
|
206 |
nid = DatabaseService.getDBAdapter().getUniqueID(connection.getConnections(), "xml_nodes");
|
|
211 | 207 |
//should incease connection usage!!!!!! |
212 | 208 |
|
213 | 209 |
|
... | ... | |
339 | 335 |
pstmt.close(); |
340 | 336 |
|
341 | 337 |
// get the generated unique id afterward |
342 |
nid = dbAdapter.getUniqueID(connection.getConnections(), "xml_nodes");
|
|
338 |
nid = DatabaseService.getDBAdapter().getUniqueID(connection.getConnections(), "xml_nodes");
|
|
343 | 339 |
//should incease connection usage!!!!!! |
344 | 340 |
|
345 | 341 |
} catch (SQLException e) { |
src/edu/ucsb/nceas/metacat/service/DatabaseService.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: A Class that implements database utility methods |
|
4 |
* Copyright: 2008 Regents of the University of California and the |
|
5 |
* National Center for Ecological Analysis and Synthesis |
|
6 |
* Authors: Michael Daigle |
|
7 |
* |
|
8 |
* '$Author: daigle $' |
|
9 |
* '$Date: 2008-08-22 16:23:38 -0700 (Fri, 22 Aug 2008) $' |
|
10 |
* '$Revision: 4297 $' |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or modify |
|
13 |
* it under the terms of the GNU General Public License as published by |
|
14 |
* the Free Software Foundation; either version 2 of the License, or |
|
15 |
* (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
25 |
*/ |
|
26 |
|
|
27 |
package edu.ucsb.nceas.metacat.service; |
|
28 |
|
|
29 |
import org.apache.log4j.Logger; |
|
30 |
|
|
31 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
|
32 |
|
|
33 |
public class DatabaseService implements ServiceInterface { |
|
34 |
|
|
35 |
private static DatabaseService databaseService = null; |
|
36 |
private static AbstractDatabase dbAdapter; |
|
37 |
private static Logger logMetacat = Logger.getLogger(DatabaseService.class); |
|
38 |
|
|
39 |
/** |
|
40 |
* private constructor since this is a singleton |
|
41 |
*/ |
|
42 |
private DatabaseService() { |
|
43 |
// Determine our db adapter class and create an instance of that class |
|
44 |
try { |
|
45 |
dbAdapter = (AbstractDatabase) createObject(PropertyService.getProperty("database.adapter")); |
|
46 |
} catch (Exception e) { |
|
47 |
logMetacat.error("Could not create dbAdaptor" + e.getMessage()); |
|
48 |
e.printStackTrace(); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Get the single instance of AuthAdmin. |
|
54 |
* |
|
55 |
* @return the single instance of AuthAdmin |
|
56 |
*/ |
|
57 |
public static DatabaseService getInstance() { |
|
58 |
if (databaseService == null) { |
|
59 |
databaseService = new DatabaseService(); |
|
60 |
} |
|
61 |
return databaseService; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Instantiate a class using the name of the class at runtime |
|
66 |
* |
|
67 |
* @param className the fully qualified name of the class to instantiate |
|
68 |
*/ |
|
69 |
public static Object createObject(String className) throws Exception { |
|
70 |
|
|
71 |
Object object = null; |
|
72 |
try { |
|
73 |
Class classDefinition = Class.forName(className); |
|
74 |
object = classDefinition.newInstance(); |
|
75 |
} catch (InstantiationException e) { |
|
76 |
throw e; |
|
77 |
} catch (IllegalAccessException e) { |
|
78 |
throw e; |
|
79 |
} catch (ClassNotFoundException e) { |
|
80 |
throw e; |
|
81 |
} |
|
82 |
return object; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* gets the database adapter |
|
87 |
* |
|
88 |
* @return AbstractDatabase object for this application's database adapter. |
|
89 |
*/ |
|
90 |
public static AbstractDatabase getDBAdapter() { |
|
91 |
return dbAdapter; |
|
92 |
} |
|
93 |
|
|
94 |
} |
|
0 | 95 |
src/edu/ucsb/nceas/metacat/AccessionNumber.java | ||
---|---|---|
31 | 31 |
import java.sql.ResultSet; |
32 | 32 |
import java.sql.SQLException; |
33 | 33 |
|
34 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
|
35 | 34 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
36 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
|
37 | 35 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
38 | 36 |
|
39 | 37 |
/** |
... | ... | |
46 | 44 |
*/ |
47 | 45 |
public class AccessionNumber { |
48 | 46 |
|
49 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
50 |
|
|
51 | 47 |
private String sitecode = null; |
52 | 48 |
private String sep = null; |
53 | 49 |
private String docid = null; |
src/edu/ucsb/nceas/metacat/util/MetaCatUtil.java | ||
---|---|---|
32 | 32 |
import java.io.IOException; |
33 | 33 |
import java.io.PrintWriter; |
34 | 34 |
import java.net.MalformedURLException; |
35 |
import java.util.HashMap; |
|
36 | 35 |
import java.util.Hashtable; |
37 |
import java.util.Properties; |
|
38 | 36 |
import java.util.Stack; |
39 | 37 |
import java.util.Vector; |
40 |
import java.util.regex.PatternSyntaxException; |
|
41 | 38 |
|
42 | 39 |
import org.apache.log4j.Logger; |
43 | 40 |
|
... | ... | |
69 | 66 |
private static char separator = '.'; |
70 | 67 |
|
71 | 68 |
static { |
72 |
// Determine our db adapter class and create an instance of that class |
|
73 | 69 |
try { |
74 |
dbAdapter = (AbstractDatabase) createObject(PropertyService.getProperty("database.adapter")); |
|
75 |
} catch (Exception e) { |
|
76 |
System.err.println("Error in MetaCatUtil static block:" |
|
77 |
+ e.getMessage()); |
|
78 |
e.printStackTrace(); |
|
79 |
} |
|
80 |
|
|
81 |
try { |
|
82 | 70 |
separator = PropertyService.getProperty("document.accNumSeparator").charAt(0); |
83 | 71 |
} catch (PropertyNotFoundException pnfe) { |
84 | 72 |
logMetacat.error("Could not retrieve account number separator. " |
85 | 73 |
+ "Separator set to '.' : " + pnfe.getMessage()); |
86 | 74 |
} |
87 | 75 |
} |
88 |
|
|
89 |
/** |
|
90 |
* Instantiate a class using the name of the class at runtime |
|
91 |
* |
|
92 |
* @param className the fully qualified name of the class to instantiate |
|
93 |
*/ |
|
94 |
public static Object createObject(String className) throws Exception |
|
95 |
{ |
|
96 | 76 |
|
97 |
Object object = null; |
|
98 |
try { |
|
99 |
Class classDefinition = Class.forName(className); |
|
100 |
object = classDefinition.newInstance(); |
|
101 |
} catch (InstantiationException e) { |
|
102 |
throw e; |
|
103 |
} catch (IllegalAccessException e) { |
|
104 |
throw e; |
|
105 |
} catch (ClassNotFoundException e) { |
|
106 |
throw e; |
|
107 |
} |
|
108 |
return object; |
|
109 |
} |
|
110 |
|
|
111 | 77 |
/** |
112 | 78 |
* Utility method to parse the query part of a URL into parameters. This |
113 | 79 |
* method assumes the format of the query par tof the url is an ampersand |
src/edu/ucsb/nceas/metacat/ReplicationServerList.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package edu.ucsb.nceas.metacat; |
29 | 29 |
|
30 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
|
31 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
|
30 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
|
32 | 31 |
|
33 | 32 |
import java.util.Vector; |
34 | 33 |
import java.sql.*; |
... | ... | |
42 | 41 |
public class ReplicationServerList |
43 | 42 |
{ |
44 | 43 |
private static Vector serverList = null; //Vector to store server list |
45 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
|
46 | 44 |
private static Logger logMetacat = Logger.getLogger(ReplicationServer.class); |
47 | 45 |
|
48 | 46 |
/** |
... | ... | |
456 | 454 |
pStmt = dbConn.prepareStatement("INSERT INTO xml_replication " + |
457 | 455 |
"(server, last_checked, replicate, datareplicate, hub) "+ |
458 | 456 |
"VALUES ('" + givenServerName + "', "+ |
459 |
dbAdapter.toDate("01/01/1980","MM/DD/YYYY") + ", '" +
|
|
457 |
DatabaseService.getDBAdapter().toDate("01/01/1980","MM/DD/YYYY") + ", '" +
|
|
460 | 458 |
replicate +"', '"+dataReplicate+"','"+ hub + "')"); |
461 | 459 |
pStmt.execute(); |
462 | 460 |
|
src/edu/ucsb/nceas/metacat/AccessControlList.java | ||
---|---|---|
47 | 47 |
import org.xml.sax.helpers.XMLReaderFactory; |
48 | 48 |
import org.xml.sax.helpers.DefaultHandler; |
49 | 49 |
|
50 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
|
50 | 51 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
51 | 52 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
52 | 53 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
... | ... | |
62 | 63 |
{ |
63 | 64 |
|
64 | 65 |
|
65 |
private static String sysdate = MetaCatUtil.dbAdapter.getDateTimeFunction();
|
|
66 |
private static String isnull = MetaCatUtil.dbAdapter.getIsNULLFunction();
|
|
66 |
private static String sysdate = DatabaseService.getDBAdapter().getDateTimeFunction();
|
|
67 |
private static String isnull = DatabaseService.getDBAdapter().getIsNULLFunction();
|
|
67 | 68 |
|
68 | 69 |
private DBConnection connection; |
69 | 70 |
private String parserName; |
Also available in: Unified diff
Move the DBAdaptor accessor into a DatabaseService class