Revision 4698
Added by daigle almost 16 years ago
src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java | ||
---|---|---|
48 | 48 |
import org.xml.sax.SAXException; |
49 | 49 |
|
50 | 50 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
51 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
51 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
52 | 52 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
53 | 53 |
|
54 | 54 |
/** |
... | ... | |
354 | 354 |
// initialize namespace hash for in line data |
355 | 355 |
inlineDataNameSpace = new Hashtable<String, String>(); |
356 | 356 |
// initialize file writer |
357 |
String docidWithoutRev = MetaCatUtil.getDocIdFromString(docid);
|
|
357 |
String docidWithoutRev = MetacatUtil.getDocIdFromString(docid);
|
|
358 | 358 |
String seperator = "."; |
359 | 359 |
try { |
360 | 360 |
seperator = PropertyService.getProperty("document.accNumSeparator"); |
... | ... | |
397 | 397 |
&& (processAdditionalAccess || processOtherAccess || processTopLevelAccess)) { |
398 | 398 |
// stored the pull out nodes into storedNode stack |
399 | 399 |
NodeRecord nodeElement = new NodeRecord(-2, -2, -2, "TEXT", null, |
400 |
null, MetaCatUtil.normalize(textBuffer.toString()));
|
|
400 |
null, MetacatUtil.normalize(textBuffer.toString()));
|
|
401 | 401 |
storedAccessNodeStack.push(nodeElement); |
402 | 402 |
|
403 | 403 |
} |
... | ... | |
639 | 639 |
&& (processAdditionalAccess || processOtherAccess || processTopLevelAccess)) { |
640 | 640 |
// stored the pull out nodes into storedNode stack |
641 | 641 |
NodeRecord nodeElement = new NodeRecord(-2, -2, -2, "ELEMENT", localName, |
642 |
prefix, MetaCatUtil.normalize(null));
|
|
642 |
prefix, MetacatUtil.normalize(null));
|
|
643 | 643 |
storedAccessNodeStack.push(nodeElement); |
644 | 644 |
for (int i = 0; i < atts.getLength(); i++) { |
645 | 645 |
String attributeName = atts.getQName(i); |
646 | 646 |
String attributeValue = atts.getValue(i); |
647 | 647 |
NodeRecord nodeAttribute = new NodeRecord(-2, -2, -2, "ATTRIBUTE", |
648 |
attributeName, null, MetaCatUtil.normalize(attributeValue));
|
|
648 |
attributeName, null, MetacatUtil.normalize(attributeValue));
|
|
649 | 649 |
storedAccessNodeStack.push(nodeAttribute); |
650 | 650 |
} |
651 | 651 |
|
... | ... | |
966 | 966 |
data = (textBuffer.toString()).trim(); |
967 | 967 |
handleOnlineUrlDataFile(data); |
968 | 968 |
/* |
969 |
* if (data != null && (data.indexOf(MetaCatUtil
|
|
969 |
* if (data != null && (data.indexOf(MetacatUtil
|
|
970 | 970 |
* .getProperty("httpserver")) != -1 || data |
971 |
* .indexOf(MetaCatUtil .getProperty("server")) != -1)) { //
|
|
972 |
* Get docid from url String dataId = MetaCatUtil
|
|
971 |
* .indexOf(MetacatUtil .getProperty("server")) != -1)) { //
|
|
972 |
* Get docid from url String dataId = MetacatUtil
|
|
973 | 973 |
* .getDocIdWithRevFromOnlineURL(data); // add to vector |
974 | 974 |
* onlineDataFileIdVector.add(dataId); }//if |
975 | 975 |
*/ |
... | ... | |
1000 | 1000 |
&& (processAdditionalAccess || processOtherAccess || processTopLevelAccess)) { |
1001 | 1001 |
// stored the pull out nodes into storedNode stack |
1002 | 1002 |
NodeRecord nodeElement = new NodeRecord(-2, -2, -2, "TEXT", null, |
1003 |
null, MetaCatUtil.normalize(textBuffer.toString()));
|
|
1003 |
null, MetacatUtil.normalize(textBuffer.toString()));
|
|
1004 | 1004 |
storedAccessNodeStack.push(nodeElement); |
1005 | 1005 |
|
1006 | 1006 |
} |
... | ... | |
1188 | 1188 |
&& (processAdditionalAccess || processOtherAccess || processTopLevelAccess)) { |
1189 | 1189 |
// stored the pull out nodes into storedNode stack |
1190 | 1190 |
NodeRecord nodeElement = new NodeRecord(-2, -2, -2, "COMMENT", null, |
1191 |
null, MetaCatUtil.normalize(str));
|
|
1191 |
null, MetacatUtil.normalize(str));
|
|
1192 | 1192 |
storedAccessNodeStack.push(nodeElement); |
1193 | 1193 |
|
1194 | 1194 |
} |
... | ... | |
1312 | 1312 |
&& (processAdditionalAccess || processOtherAccess || processTopLevelAccess)) { |
1313 | 1313 |
// stored the pull out nodes into storedNode stack |
1314 | 1314 |
NodeRecord nodeElement = new NodeRecord(-2, -2, -2, "TEXT", null, |
1315 |
null, MetaCatUtil.normalize(data));
|
|
1315 |
null, MetacatUtil.normalize(data));
|
|
1316 | 1316 |
storedAccessNodeStack.push(nodeElement); |
1317 | 1317 |
|
1318 | 1318 |
} |
... | ... | |
1430 | 1430 |
Stack<NodeRecord> newStack = accessObj |
1431 | 1431 |
.getStoredTmpNodeStack(); |
1432 | 1432 |
// revise order |
1433 |
newStack = MetaCatUtil.reviseStack(newStack);
|
|
1433 |
newStack = MetacatUtil.reviseStack(newStack);
|
|
1434 | 1434 |
// go throught the vector of |
1435 | 1435 |
// unChangeableAccessSubtreevector |
1436 | 1436 |
// and find the one whose id is as same as |
... | ... | |
1794 | 1794 |
throw new SAXException("The access object is null"); |
1795 | 1795 |
} |
1796 | 1796 |
// get rid of rev from dataId |
1797 |
// dataId = MetaCatUtil.getDocIdFromString(dataId);
|
|
1797 |
// dataId = MetacatUtil.getDocIdFromString(dataId);
|
|
1798 | 1798 |
String permOrder = accessSection.getPermissionOrder(); |
1799 | 1799 |
String sql = null; |
1800 | 1800 |
PreparedStatement pstmt = null; |
... | ... | |
2171 | 2171 |
} |
2172 | 2172 |
|
2173 | 2173 |
// if the url is not in ecogrid protocol, null will be returned |
2174 |
String accessionNumber = MetaCatUtil.getAccessionNumberFromEcogridIdentifier(url);
|
|
2174 |
String accessionNumber = MetacatUtil.getAccessionNumberFromEcogridIdentifier(url);
|
|
2175 | 2175 |
if (accessionNumber == null) { |
2176 | 2176 |
// the accession number is null if the url does not references a |
2177 | 2177 |
// local data file (url would start with "ecogrid://" |
... | ... | |
2180 | 2180 |
} else { |
2181 | 2181 |
// handle ecogrid protocol |
2182 | 2182 |
// get rid of revision number to get the docid. |
2183 |
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accessionNumber);
|
|
2183 |
String docid = MetacatUtil.getDocIdFromAccessionNumber(accessionNumber);
|
|
2184 | 2184 |
|
2185 | 2185 |
currentDistributionSection |
2186 | 2186 |
.setDistributionType(DistributionSection.DATA_DISTRIBUTION); |
src/edu/ucsb/nceas/metacat/RemoteDocument.java | ||
---|---|---|
27 | 27 |
package edu.ucsb.nceas.metacat; |
28 | 28 |
|
29 | 29 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
30 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
30 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
31 | 31 |
import edu.ucsb.nceas.utilities.HttpMessage; |
32 | 32 |
import javax.servlet.ServletOutputStream; |
33 | 33 |
|
... | ... | |
215 | 215 |
|
216 | 216 |
// If replication doc home server is local host. throws a exception |
217 | 217 |
if (replicationDocHomeServer. |
218 |
equals(MetaCatUtil.getLocalReplicationServerName()))
|
|
218 |
equals(MetacatUtil.getLocalReplicationServerName()))
|
|
219 | 219 |
{ |
220 | 220 |
throw new Exception ("Couldn't find the docid: " |
221 | 221 |
+docIdWithoutRevision+"."+revision); |
lib/index.jsp | ||
---|---|---|
1 |
<%@ page language="java" import="edu.ucsb.nceas.metacat.util.MetaCatUtil" %>
|
|
1 |
<%@ page language="java" import="edu.ucsb.nceas.metacat.util.MetacatUtil" %>
|
|
2 | 2 |
<% |
3 | 3 |
/** |
4 | 4 |
* '$RCSfile$' |
... | ... | |
45 | 45 |
String addedParams = ""; |
46 | 46 |
String redirectURI = ""; |
47 | 47 |
|
48 |
if (MetaCatUtil.isMetacatConfigured()) {
|
|
48 |
if (MetacatUtil.isMetacatConfigured()) {
|
|
49 | 49 |
//if qformat has not been set, set its value to "DEFAULT_STYLE" |
50 | 50 |
if (qformat==null) { |
51 | 51 |
qformat = DEFAULT_STYLE; |
lib/style/skins/esa/ESAHeader.jsp | ||
---|---|---|
1 | 1 |
<%@page contentType="text/html"%> |
2 | 2 |
<%@page pageEncoding="UTF-8"%> |
3 |
<%@page import="edu.ucsb.nceas.metacat.util.MetaCatUtil"%>
|
|
3 |
<%@page import="edu.ucsb.nceas.metacat.util.MetacatUtil"%>
|
|
4 | 4 |
<%@ include file="../../common/common-settings.jsp"%> |
5 | 5 |
<%@ include file="../../common/configure-check.jsp"%> |
6 | 6 |
|
lib/style/common/configure-check.jsp | ||
---|---|---|
1 | 1 |
<%@ page errorPage="jsperrorpage.html"%> |
2 |
<%@page import="edu.ucsb.nceas.metacat.util.MetaCatUtil"%>
|
|
2 |
<%@page import="edu.ucsb.nceas.metacat.util.MetacatUtil"%>
|
|
3 | 3 |
<% |
4 | 4 |
/** |
5 | 5 |
* '$RCSfile$' |
... | ... | |
27 | 27 |
%> |
28 | 28 |
|
29 | 29 |
<% |
30 |
if (!MetaCatUtil.isMetacatConfigured()) {
|
|
30 |
if (!MetacatUtil.isMetacatConfigured()) {
|
|
31 | 31 |
%> |
32 | 32 |
<jsp:forward page="/metacat" /> |
33 | 33 |
<% |
src/edu/ucsb/nceas/metacat/QuerySpecification.java | ||
---|---|---|
36 | 36 |
import java.util.Stack; |
37 | 37 |
import java.util.Vector; |
38 | 38 |
|
39 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
39 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
40 | 40 |
|
41 | 41 |
import org.apache.log4j.Logger; |
42 | 42 |
import org.xml.sax.Attributes; |
... | ... | |
629 | 629 |
queryTitle = textBuffer.toString().trim(); |
630 | 630 |
} else if (leaving.getTagName().equals("value")) { |
631 | 631 |
currentValue = textBuffer.toString().trim(); |
632 |
currentValue = MetaCatUtil.normalize(currentValue);
|
|
632 |
currentValue = MetacatUtil.normalize(currentValue);
|
|
633 | 633 |
} else if (leaving.getTagName().equals("pathexpr")) { |
634 | 634 |
currentPathexpr = textBuffer.toString().trim(); |
635 | 635 |
} else if (leaving.getTagName().equals("returndoctype")) { |
... | ... | |
645 | 645 |
} |
646 | 646 |
String normalizedXML = textBuffer.toString().trim(); |
647 | 647 |
logMetacat.debug("================before normailze "+normalizedXML); |
648 |
normalizedXML = MetaCatUtil.normalize(normalizedXML);
|
|
648 |
normalizedXML = MetacatUtil.normalize(normalizedXML);
|
|
649 | 649 |
logMetacat.debug("================after normailze "+normalizedXML); |
650 | 650 |
xml.append(normalizedXML); |
651 | 651 |
xml.append("</"); |
... | ... | |
985 | 985 |
{ |
986 | 986 |
elementVector.add(path); |
987 | 987 |
} |
988 |
if(!MetaCatUtil.pathsForIndexing.contains(path)){
|
|
988 |
if(!MetacatUtil.pathsForIndexing.contains(path)){
|
|
989 | 989 |
usePathIndex = false; |
990 | 990 |
} |
991 | 991 |
|
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
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.AuthUtil; |
43 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
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 | 46 |
import edu.ucsb.nceas.utilities.FileUtil; |
... | ... | |
626 | 626 |
logMetacat.info("Force replication action: "+dbaction); |
627 | 627 |
// sending back read request to remote server |
628 | 628 |
URL u = new URL("https://" + server + "?server=" |
629 |
+MetaCatUtil.getLocalReplicationServerName()
|
|
629 |
+MetacatUtil.getLocalReplicationServerName()
|
|
630 | 630 |
+"&action=read&docid=" + docid); |
631 | 631 |
String xmldoc = MetacatReplication.getURLContent(u); |
632 | 632 |
|
633 | 633 |
// get the document info from server |
634 | 634 |
URL docinfourl = new URL("https://" + server + |
635 |
"?server="+MetaCatUtil.getLocalReplicationServerName()
|
|
635 |
"?server="+MetacatUtil.getLocalReplicationServerName()
|
|
636 | 636 |
+"&action=getdocumentinfo&docid=" + docid); |
637 | 637 |
|
638 | 638 |
String docInfoStr = MetacatReplication.getURLContent(docinfourl); |
... | ... | |
793 | 793 |
try |
794 | 794 |
{ |
795 | 795 |
//docid was switch to two parts uinque code and rev |
796 |
//String uniqueCode=MetaCatUtil.getDocIdFromString(docid);
|
|
797 |
//int rev=MetaCatUtil.getVersionFromString(docid);
|
|
796 |
//String uniqueCode=MetacatUtil.getDocIdFromString(docid);
|
|
797 |
//int rev=MetacatUtil.getVersionFromString(docid);
|
|
798 | 798 |
if(params.containsKey("dbaction")) |
799 | 799 |
{ |
800 | 800 |
dbaction = ((String[])params.get("dbaction"))[0]; |
... | ... | |
810 | 810 |
logMetacat.info("Force replication action: "+dbaction); |
811 | 811 |
// get the document info from server |
812 | 812 |
URL docinfourl = new URL("https://" + server + |
813 |
"?server="+MetaCatUtil.getLocalReplicationServerName()
|
|
813 |
"?server="+MetacatUtil.getLocalReplicationServerName()
|
|
814 | 814 |
+"&action=getdocumentinfo&docid=" + docid); |
815 | 815 |
|
816 | 816 |
String docInfoStr = MetacatReplication.getURLContent(docinfourl); |
... | ... | |
849 | 849 |
//Get data file and store it into local file system. |
850 | 850 |
// sending back readdata request to server |
851 | 851 |
URL url = new URL("https://" + server + "?server=" |
852 |
+MetaCatUtil.getLocalReplicationServerName()
|
|
852 |
+MetacatUtil.getLocalReplicationServerName()
|
|
853 | 853 |
+"&action=readdata&docid=" + docid); |
854 | 854 |
String datafilePath = PropertyService.getProperty("application.datafilepath"); |
855 | 855 |
|
... | ... | |
1041 | 1041 |
filepath = PropertyService.getProperty("application.datafilepath"); |
1042 | 1042 |
String server = params.get("server")[0]; |
1043 | 1043 |
URL u = new URL("https://" + server + "?server=" |
1044 |
+MetaCatUtil.getLocalReplicationServerName()
|
|
1044 |
+MetacatUtil.getLocalReplicationServerName()
|
|
1045 | 1045 |
+"&action=test"); |
1046 | 1046 |
String test = MetacatReplication.getURLContent(u); |
1047 | 1047 |
//couldn't pass the test |
... | ... | |
1146 | 1146 |
//in the key store, this is security issue |
1147 | 1147 |
String server = params.get("server")[0]; |
1148 | 1148 |
URL u = new URL("https://" + server + "?server=" |
1149 |
+MetaCatUtil.getLocalReplicationServerName()
|
|
1149 |
+MetacatUtil.getLocalReplicationServerName()
|
|
1150 | 1150 |
+"&action=test"); |
1151 | 1151 |
String test = MetacatReplication.getURLContent(u); |
1152 | 1152 |
//couldn't pass the test |
... | ... | |
1242 | 1242 |
//try to open a https stream to test if the request server's public key |
1243 | 1243 |
//in the key store, this is security issue |
1244 | 1244 |
URL u = new URL("https://" + server + "?server=" |
1245 |
+MetaCatUtil.getLocalReplicationServerName()
|
|
1245 |
+MetacatUtil.getLocalReplicationServerName()
|
|
1246 | 1246 |
+"&action=test"); |
1247 | 1247 |
String test = MetacatReplication.getURLContent(u); |
1248 | 1248 |
//couldn't pass the test |
... | ... | |
1278 | 1278 |
|
1279 | 1279 |
// Append local server's name and replication servlet to doclist |
1280 | 1280 |
doclist.append("<?xml version=\"1.0\"?><replication>"); |
1281 |
doclist.append("<server>").append(MetaCatUtil.getLocalReplicationServerName());
|
|
1281 |
doclist.append("<server>").append(MetacatUtil.getLocalReplicationServerName());
|
|
1282 | 1282 |
//doclist.append(util.getProperty("replicationpath")); |
1283 | 1283 |
doclist.append("</server><updates>"); |
1284 | 1284 |
|
... | ... | |
1325 | 1325 |
while(tablehasrows) |
1326 | 1326 |
{ |
1327 | 1327 |
String recordDoctype = rs.getString(3); |
1328 |
Vector<String> packagedoctypes = MetaCatUtil.getOptionList(
|
|
1328 |
Vector<String> packagedoctypes = MetacatUtil.getOptionList(
|
|
1329 | 1329 |
PropertyService.getProperty("xml.packagedoctype")); |
1330 | 1330 |
//if this is a package file, put it at the end |
1331 | 1331 |
//because if a package file is read before all of the files it |
... | ... | |
1373 | 1373 |
String recordDoctype = rs.getString(3); |
1374 | 1374 |
if(!recordDoctype.equals("BIN")) |
1375 | 1375 |
{ //don't replicate data files |
1376 |
Vector<String> packagedoctypes = MetaCatUtil.getOptionList(
|
|
1376 |
Vector<String> packagedoctypes = MetacatUtil.getOptionList(
|
|
1377 | 1377 |
PropertyService.getProperty("xml.packagedoctype")); |
1378 | 1378 |
if(recordDoctype != null && !packagedoctypes.contains(recordDoctype)) |
1379 | 1379 |
{ //if this is a package file, put it at the end |
... | ... | |
1777 | 1777 |
Hashtable<String,String> sl = new Hashtable<String,String>(); |
1778 | 1778 |
DBConnection dbConn = null; |
1779 | 1779 |
int serialNumber = -1; |
1780 |
docId=MetaCatUtil.getDocIdFromString(docId);
|
|
1780 |
docId=MetacatUtil.getDocIdFromString(docId);
|
|
1781 | 1781 |
PreparedStatement pstmt=null; |
1782 | 1782 |
int serverLocation; |
1783 | 1783 |
try |
... | ... | |
1868 | 1868 |
int serialNumber = -1; |
1869 | 1869 |
PreparedStatement pstmt = null; |
1870 | 1870 |
int serverCode = 1; |
1871 |
String docId=MetaCatUtil.getDocIdFromString(accNum);
|
|
1871 |
String docId=MetacatUtil.getDocIdFromString(accNum);
|
|
1872 | 1872 |
|
1873 | 1873 |
try |
1874 | 1874 |
{ |
src/edu/ucsb/nceas/metacat/SubTree.java | ||
---|---|---|
36 | 36 |
import org.apache.log4j.Logger; |
37 | 37 |
import org.xml.sax.SAXException; |
38 | 38 |
|
39 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
39 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
40 | 40 |
|
41 | 41 |
/** |
42 | 42 |
* A Class that represents an XML Subtree |
... | ... | |
220 | 220 |
nodename = rs.getString(5); |
221 | 221 |
nodeprefix = rs.getString(6); |
222 | 222 |
nodedata = rs.getString(7); |
223 |
nodedata = MetaCatUtil.normalize(nodedata);
|
|
223 |
nodedata = MetacatUtil.normalize(nodedata);
|
|
224 | 224 |
// add the data to the node record list hashtable |
225 | 225 |
NodeRecord currentRecord = new NodeRecord(nodeid,parentnodeid,nodeindex, |
226 | 226 |
nodetype, nodename, nodeprefix, nodedata); |
src/edu/ucsb/nceas/metacat/IndexingQueue.java | ||
---|---|---|
34 | 34 |
import java.lang.Comparable; |
35 | 35 |
|
36 | 36 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
37 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
37 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
38 | 38 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
39 | 39 |
|
40 | 40 |
import org.apache.log4j.Logger; |
src/edu/ucsb/nceas/metacat/DocumentIdQuery.java | ||
---|---|---|
31 | 31 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
32 | 32 |
|
33 | 33 |
/** |
34 |
* Generate a pathquery document representing a metacat query for a list of
|
|
34 |
* Generate a pathquery document representing a metacat query for a list of |
|
35 | 35 |
* document IDs. |
36 | 36 |
*/ |
37 |
public class DocumentIdQuery |
|
38 |
{ |
|
37 |
public class DocumentIdQuery { |
|
39 | 38 |
|
40 |
|
|
41 |
/** |
|
42 |
* Create an squery parameters table using an already-initialized hashtable |
|
43 |
* |
|
44 |
* @param docidList an array of document identifiers to search for |
|
45 |
* @param params the hashtable to add the query parameters to. |
|
46 |
* |
|
47 |
*/ |
|
48 |
public static Hashtable createDocidQueryParams(String[] docidList, Hashtable params) |
|
49 |
{ |
|
50 |
params = getDefaultQueryParams(); |
|
51 |
if (docidList != null) { |
|
52 |
params.put("/eml/@packageId", docidList); |
|
53 |
} |
|
54 |
return params; |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* Create an squery using some preset values for the query parameters, only |
|
60 |
* passing in the document ids to be searched. |
|
61 |
* |
|
62 |
* @param docidList an array of document identifiers to search for |
|
63 |
*/ |
|
64 |
public static String createDocidQuery(String[] docidList) throws PropertyNotFoundException |
|
65 |
{ |
|
66 |
String pathQuery = ""; |
|
67 |
Hashtable params = getDefaultQueryParams(); |
|
68 |
if (docidList != null) { |
|
69 |
params.put("/eml/@packageId", docidList); |
|
70 |
} |
|
71 |
|
|
72 |
pathQuery = DBQuery.createSQuery(params); |
|
73 |
return pathQuery; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Create a paramter list containing default parameters for a query |
|
78 |
* |
|
79 |
* @return Hashtable containing the default parameters |
|
80 |
*/ |
|
81 |
public static Hashtable getDefaultQueryParams() |
|
82 |
{ |
|
83 |
Hashtable params = new Hashtable(); |
|
84 |
|
|
85 |
String[] operator = new String[1]; |
|
86 |
operator[0] = "UNION"; |
|
87 |
params.put("operator", operator); |
|
88 |
|
|
89 |
String[] doctypes = new String[5]; |
|
90 |
doctypes[0] = "eml://ecoinformatics.org/eml-2.0.1"; |
|
91 |
doctypes[1] = "eml://ecoinformatics.org/eml-2.0.0"; |
|
92 |
doctypes[2] = "-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN"; |
|
93 |
doctypes[3] = "-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN"; |
|
94 |
doctypes[4] = "metadata"; |
|
95 |
params.put("returndoctype", doctypes); |
|
96 |
|
|
97 |
String[] fields = new String[11]; |
|
98 |
fields[0]="originator/individualName/surName"; |
|
99 |
fields[1]="originator/individualName/givenName"; |
|
100 |
fields[2]="creator/individualName/surName"; |
|
101 |
fields[3]="creator/individualName/givenName"; |
|
102 |
fields[4]="originator/organizationName"; |
|
103 |
fields[5]="creator/organizationName"; |
|
104 |
fields[6]="dataset/title"; |
|
105 |
fields[7]="keyword"; |
|
106 |
fields[8]="idinfo/citation/citeinfo/title"; |
|
107 |
fields[9]="idinfo/citation/citeinfo/origin"; |
|
108 |
fields[10]="idinfo/keywords/theme/themekey"; |
|
109 |
params.put("returnfield", fields); |
|
110 |
|
|
111 |
return params; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Main method used for testing the class output |
|
116 |
* |
|
117 |
* @param args no arguments used in this main method |
|
118 |
*/ |
|
119 |
public static void main(String[] args) |
|
120 |
{ |
|
121 |
String CONFIG_DIR = "lib"; |
|
122 |
File dirPath = new File(CONFIG_DIR); |
|
123 |
try { |
|
124 |
PropertyService.getInstance(dirPath.getPath()); |
|
125 |
} catch (ServiceException ioe) { |
|
126 |
System.err.println("Error in loading properties: " |
|
127 |
+ ioe.getMessage()); |
|
128 |
} |
|
129 |
|
|
130 |
String[] ids = new String[3]; |
|
131 |
ids[0] = "ces_dataset.23.1"; |
|
132 |
ids[1] = "knb-lter-vcr.97.1"; |
|
133 |
ids[2] = "obfs.400.1"; |
|
134 |
|
|
135 |
String pathquery = null; |
|
136 |
try { |
|
137 |
pathquery = createDocidQuery(ids); |
|
138 |
} catch (PropertyNotFoundException pnfe) { |
|
139 |
System.out.println("Could not create doc id query: " + pnfe.getMessage()); |
|
140 |
} |
|
141 |
System.out.println(pathquery); |
|
142 |
} |
|
39 |
/** |
|
40 |
* Create an squery parameters table using an already-initialized hashtable |
|
41 |
* |
|
42 |
* @param docidList |
|
43 |
* an array of document identifiers to search for |
|
44 |
* @param params |
|
45 |
* the hashtable to add the query parameters to. |
|
46 |
* |
|
47 |
*/ |
|
48 |
public static Hashtable createDocidQueryParams(String[] docidList, Hashtable params) { |
|
49 |
params = getDefaultQueryParams(); |
|
50 |
if (docidList != null) { |
|
51 |
params.put("/eml/@packageId", docidList); |
|
52 |
} |
|
53 |
return params; |
|
54 |
} |
|
143 | 55 |
|
56 |
/** |
|
57 |
* Create an squery using some preset values for the query parameters, only |
|
58 |
* passing in the document ids to be searched. |
|
59 |
* |
|
60 |
* @param docidList |
|
61 |
* an array of document identifiers to search for |
|
62 |
*/ |
|
63 |
public static String createDocidQuery(String[] docidList) |
|
64 |
throws PropertyNotFoundException { |
|
65 |
String pathQuery = ""; |
|
66 |
Hashtable params = getDefaultQueryParams(); |
|
67 |
if (docidList != null) { |
|
68 |
params.put("/eml/@packageId", docidList); |
|
69 |
} |
|
70 |
|
|
71 |
pathQuery = DBQuery.createSQuery(params); |
|
72 |
return pathQuery; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Create a paramter list containing default parameters for a query |
|
77 |
* |
|
78 |
* @return Hashtable containing the default parameters |
|
79 |
*/ |
|
80 |
public static Hashtable getDefaultQueryParams() { |
|
81 |
Hashtable params = new Hashtable(); |
|
82 |
|
|
83 |
String[] operator = new String[1]; |
|
84 |
operator[0] = "UNION"; |
|
85 |
params.put("operator", operator); |
|
86 |
|
|
87 |
String[] doctypes = new String[5]; |
|
88 |
doctypes[0] = "eml://ecoinformatics.org/eml-2.0.1"; |
|
89 |
doctypes[1] = "eml://ecoinformatics.org/eml-2.0.0"; |
|
90 |
doctypes[2] = "-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN"; |
|
91 |
doctypes[3] = "-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN"; |
|
92 |
doctypes[4] = "metadata"; |
|
93 |
params.put("returndoctype", doctypes); |
|
94 |
|
|
95 |
String[] fields = new String[11]; |
|
96 |
fields[0] = "originator/individualName/surName"; |
|
97 |
fields[1] = "originator/individualName/givenName"; |
|
98 |
fields[2] = "creator/individualName/surName"; |
|
99 |
fields[3] = "creator/individualName/givenName"; |
|
100 |
fields[4] = "originator/organizationName"; |
|
101 |
fields[5] = "creator/organizationName"; |
|
102 |
fields[6] = "dataset/title"; |
|
103 |
fields[7] = "keyword"; |
|
104 |
fields[8] = "idinfo/citation/citeinfo/title"; |
|
105 |
fields[9] = "idinfo/citation/citeinfo/origin"; |
|
106 |
fields[10] = "idinfo/keywords/theme/themekey"; |
|
107 |
params.put("returnfield", fields); |
|
108 |
|
|
109 |
return params; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Main method used for testing the class output |
|
114 |
* |
|
115 |
* @param args |
|
116 |
* no arguments used in this main method |
|
117 |
*/ |
|
118 |
public static void main(String[] args) { |
|
119 |
String CONFIG_DIR = "lib"; |
|
120 |
File dirPath = new File(CONFIG_DIR); |
|
121 |
try { |
|
122 |
PropertyService.getInstance(); |
|
123 |
} catch (ServiceException ioe) { |
|
124 |
System.err.println("Error in loading properties: " + ioe.getMessage()); |
|
125 |
} |
|
126 |
|
|
127 |
String[] ids = new String[3]; |
|
128 |
ids[0] = "ces_dataset.23.1"; |
|
129 |
ids[1] = "knb-lter-vcr.97.1"; |
|
130 |
ids[2] = "obfs.400.1"; |
|
131 |
|
|
132 |
String pathquery = null; |
|
133 |
try { |
|
134 |
pathquery = createDocidQuery(ids); |
|
135 |
} catch (PropertyNotFoundException pnfe) { |
|
136 |
System.out.println("Could not create doc id query: " + pnfe.getMessage()); |
|
137 |
} |
|
138 |
System.out.println(pathquery); |
|
139 |
} |
|
140 |
|
|
144 | 141 |
} |
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
78 | 78 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
79 | 79 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
80 | 80 |
import edu.ucsb.nceas.metacat.service.ServiceException; |
81 |
import edu.ucsb.nceas.metacat.service.ServiceService; |
|
81 | 82 |
import edu.ucsb.nceas.metacat.service.SessionService; |
82 | 83 |
import edu.ucsb.nceas.metacat.service.SkinPropertyService; |
83 | 84 |
import edu.ucsb.nceas.metacat.service.XMLSchemaService; |
84 | 85 |
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester; |
85 | 86 |
import edu.ucsb.nceas.metacat.spatial.SpatialQuery; |
86 | 87 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
87 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
88 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
88 | 89 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
89 | 90 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
90 | 91 |
import edu.ucsb.nceas.metacat.util.SessionData; |
... | ... | |
163 | 164 |
public static final String NONAMESPACELOCATION = ":noNamespaceSchemaLocation"; |
164 | 165 |
public static final String EML2KEYWORD = ":eml"; |
165 | 166 |
public static final String XMLFORMAT = "xml"; |
166 |
private static final String CONFIG_DIR = "WEB-INF"; |
|
167 | 167 |
private static final String FALSE = "false"; |
168 | 168 |
private static final String TRUE = "true"; |
169 | 169 |
|
... | ... | |
176 | 176 |
super.init(config); |
177 | 177 |
|
178 | 178 |
ServletContext context = config.getServletContext(); |
179 |
|
|
179 |
|
|
180 |
ServiceService serviceService = ServiceService.getInstance(context); |
|
181 |
logMetacat.debug("ServiceService singleton created " + serviceService); |
|
182 |
|
|
180 | 183 |
// Initialize the properties file |
181 |
String dirPath = context.getRealPath(CONFIG_DIR);
|
|
184 |
String dirPath = ServiceService.getRealConfigDir();
|
|
182 | 185 |
|
183 | 186 |
String LOG_CONFIG_NAME = dirPath + "/log4j.properties"; |
184 | 187 |
PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME); |
185 | 188 |
|
186 |
PropertyService propertyService = PropertyService.getInstance(dirPath); |
|
187 |
logMetacat.debug("PropertyService singleton created " + propertyService); |
|
189 |
// Register preliminary services |
|
190 |
ServiceService.registerService("PropertyService", PropertyService.getInstance()); |
|
191 |
ServiceService.registerService("SkinPropertyService", SkinPropertyService.getInstance()); |
|
192 |
ServiceService.registerService("SessionService", SessionService.getInstance()); |
|
188 | 193 |
|
189 |
SkinPropertyService skinPropertyService = SkinPropertyService.getInstance(context); |
|
190 |
logMetacat.debug("PropertyService singleton created " + skinPropertyService); |
|
191 |
|
|
192 |
SessionService sessionService = SessionService.getInstance(); |
|
193 |
logMetacat.debug("SessionService singleton created " + sessionService); |
|
194 |
|
|
195 |
|
|
196 | 194 |
// Check to see if the user has requested to bypass configuration |
197 | 195 |
// (dev option) and check see if metacat has been configured. |
198 | 196 |
// If both are false then stop the initialization |
199 |
if (!MetaCatUtil.bypassConfiguration() && !MetaCatUtil.isMetacatConfigured()) {
|
|
197 |
if (!MetacatUtil.bypassConfiguration() && !MetacatUtil.isMetacatConfigured()) {
|
|
200 | 198 |
return; |
201 | 199 |
} |
202 | 200 |
|
... | ... | |
207 | 205 |
"Service problem while intializing MetaCat Servlet: " + se.getMessage(); |
208 | 206 |
logMetacat.error(errorMessage); |
209 | 207 |
throw new ServletException(errorMessage); |
208 |
} catch (UtilException ue) { |
|
209 |
String errorMessage = |
|
210 |
"Utility problem while intializing MetaCat Servlet: " + ue.getMessage(); |
|
211 |
logMetacat.error(errorMessage); |
|
212 |
throw new ServletException(errorMessage); |
|
210 | 213 |
} |
211 | 214 |
} |
212 | 215 |
|
... | ... | |
221 | 224 |
public void initSecondHalf(ServletContext context) throws ServletException { |
222 | 225 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
223 | 226 |
|
224 |
try { |
|
225 |
DatabaseService databaseService = DatabaseService.getInstance(); |
|
226 |
logMetacat.debug("DatabaseService singleton created " + databaseService); |
|
227 |
try { |
|
228 |
ServiceService.registerService("DatabaseService", DatabaseService.getInstance()); |
|
227 | 229 |
|
228 | 230 |
// initialize DBConnection pool |
229 | 231 |
DBConnectionPool connPool = DBConnectionPool.getInstance(); |
230 | 232 |
logMetacat.debug("DBConnection pool initialized: " + connPool.toString()); |
231 | 233 |
|
232 |
XMLSchemaService xmlService = XMLSchemaService.getInstance(); |
|
233 |
logMetacat.debug("XMLService initialized: " + xmlService.toString()); |
|
234 |
ServiceService.registerService("XMLSchemaService", XMLSchemaService.getInstance()); |
|
234 | 235 |
|
235 | 236 |
// check if eml201 document were corrected or not. if not, correct |
236 | 237 |
// eml201 documents. |
... | ... | |
321 | 322 |
+ gpe.getMessage(); |
322 | 323 |
logMetacat.error(errorMessage); |
323 | 324 |
throw new ServletException(errorMessage); |
324 |
} |
|
325 |
} catch (ServiceException se) { |
|
326 |
String errorMessage = "Service problem while intializing MetaCat Servlet: " |
|
327 |
+ se.getMessage(); |
|
328 |
logMetacat.error(errorMessage); |
|
329 |
throw new ServletException(errorMessage); |
|
330 |
} |
|
325 | 331 |
} |
326 | 332 |
|
327 | 333 |
/** |
... | ... | |
358 | 364 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
359 | 365 |
|
360 | 366 |
try { |
361 |
MetaCatUtil.pathsForIndexing
|
|
362 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths"));
|
|
367 |
MetacatUtil.pathsForIndexing
|
|
368 |
= MetacatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths"));
|
|
363 | 369 |
|
364 |
MetaCatUtil.pathsForIndexing =
|
|
365 |
MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths"));
|
|
370 |
MetacatUtil.pathsForIndexing =
|
|
371 |
MetacatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths"));
|
|
366 | 372 |
} |
367 | 373 |
catch (PropertyNotFoundException pnfe) { |
368 |
MetaCatUtil.pathsForIndexing = null;
|
|
374 |
MetacatUtil.pathsForIndexing = null;
|
|
369 | 375 |
logMetacat.error("Could not find index paths. Setting " |
370 |
+ "MetaCatUtil.pathsForIndexing to null: " + pnfe.getMessage());
|
|
376 |
+ "MetacatUtil.pathsForIndexing to null: " + pnfe.getMessage());
|
|
371 | 377 |
} |
372 | 378 |
|
373 |
if (MetaCatUtil.pathsForIndexing != null) {
|
|
379 |
if (MetacatUtil.pathsForIndexing != null) {
|
|
374 | 380 |
|
375 | 381 |
logMetacat.debug("Indexing paths specified in metacat.properties...."); |
376 | 382 |
|
... | ... | |
380 | 386 |
PreparedStatement pstmt1 = null; |
381 | 387 |
ResultSet rs = null; |
382 | 388 |
|
383 |
for (int i = 0; i < MetaCatUtil.pathsForIndexing.size(); i++) {
|
|
389 |
for (int i = 0; i < MetacatUtil.pathsForIndexing.size(); i++) {
|
|
384 | 390 |
logMetacat.debug("Checking if '" |
385 |
+ (String) MetaCatUtil.pathsForIndexing.elementAt(i)
|
|
391 |
+ (String) MetacatUtil.pathsForIndexing.elementAt(i)
|
|
386 | 392 |
+ "' is indexed.... "); |
387 | 393 |
|
388 | 394 |
try { |
... | ... | |
393 | 399 |
|
394 | 400 |
pstmt = conn.prepareStatement( |
395 | 401 |
"SELECT * FROM xml_path_index " + "WHERE path = ?"); |
396 |
pstmt.setString(1, (String) MetaCatUtil.pathsForIndexing
|
|
402 |
pstmt.setString(1, (String) MetacatUtil.pathsForIndexing
|
|
397 | 403 |
.elementAt(i)); |
398 | 404 |
|
399 | 405 |
pstmt.execute(); |
... | ... | |
407 | 413 |
|
408 | 414 |
logMetacat.debug( |
409 | 415 |
"Inserting following path in xml_path_index: " |
410 |
+ (String)MetaCatUtil.pathsForIndexing
|
|
416 |
+ (String)MetacatUtil.pathsForIndexing
|
|
411 | 417 |
.elementAt(i)); |
412 |
if(((String)MetaCatUtil.pathsForIndexing.elementAt(i)).indexOf("@")<0){
|
|
418 |
if(((String)MetacatUtil.pathsForIndexing.elementAt(i)).indexOf("@")<0){
|
|
413 | 419 |
pstmt = conn.prepareStatement("SELECT DISTINCT n.docid, " |
414 | 420 |
+ "n.nodedata, n.nodedatanumerical, n.parentnodeid" |
415 | 421 |
+ " FROM xml_nodes n, xml_index i WHERE" |
... | ... | |
422 | 428 |
+ " i.path = ? and n.nodeid=i.nodeid and" |
423 | 429 |
+ " n.nodetype LIKE 'ATTRIBUTE' order by n.parentnodeid"); |
424 | 430 |
} |
425 |
pstmt.setString(1, (String) MetaCatUtil.
|
|
431 |
pstmt.setString(1, (String) MetacatUtil.
|
|
426 | 432 |
pathsForIndexing.elementAt(i)); |
427 | 433 |
pstmt.execute(); |
428 | 434 |
rs = pstmt.getResultSet(); |
... | ... | |
430 | 436 |
int count = 0; |
431 | 437 |
logMetacat.debug( |
432 | 438 |
"Executed the select statement for: " |
433 |
+ (String) MetaCatUtil.pathsForIndexing
|
|
439 |
+ (String) MetacatUtil.pathsForIndexing
|
|
434 | 440 |
.elementAt(i)); |
435 | 441 |
|
436 | 442 |
try { |
... | ... | |
449 | 455 |
+ " VALUES (?, ?, ?, ?, ?)"); |
450 | 456 |
|
451 | 457 |
pstmt1.setString(1, docid); |
452 |
pstmt1.setString(2, (String) MetaCatUtil.
|
|
458 |
pstmt1.setString(2, (String) MetacatUtil.
|
|
453 | 459 |
pathsForIndexing.elementAt(i)); |
454 | 460 |
pstmt1.setString(3, nodedata); |
455 | 461 |
pstmt1.setFloat(4, nodedatanumerical); |
... | ... | |
473 | 479 |
|
474 | 480 |
logMetacat.info("Indexed " + count |
475 | 481 |
+ " records from xml_nodes for '" |
476 |
+ (String) MetaCatUtil.pathsForIndexing.elementAt(i)
|
|
482 |
+ (String) MetacatUtil.pathsForIndexing.elementAt(i)
|
|
477 | 483 |
+ "'"); |
478 | 484 |
|
479 | 485 |
} else { |
... | ... | |
514 | 520 |
|
515 | 521 |
// Each time metacat is called, check to see if metacat has been |
516 | 522 |
// configured. If not then forward to the administration servlet |
517 |
if (!MetaCatUtil.isMetacatConfigured()) {
|
|
523 |
if (!MetacatUtil.isMetacatConfigured()) {
|
|
518 | 524 |
RequestUtil.forwardRequest(request, response, "/admin?action=configure"); |
519 | 525 |
return; |
520 | 526 |
} |
521 | 527 |
|
522 | 528 |
// if we get here, metacat is configured. If we have not completed the |
523 |
// second half of the intialization, do so now. This allows us to initially |
|
529 |
// second half of the initialization, do so now. This allows us to initially
|
|
524 | 530 |
// configure metacat without a restart. |
525 |
// TODO MCD eventually put in more intelligent reinitialization code so we |
|
526 |
// can change (some) properties without restarting metacat. |
|
527 | 531 |
if (!fullyInitialized) { |
528 | 532 |
initSecondHalf(request.getSession().getServletContext()); |
529 | 533 |
} |
... | ... | |
846 | 850 |
* out.println(" Ref: " + u.getRef()); String pquery = |
847 | 851 |
* u.getQuery(); out.println(" Query: " + pquery); |
848 | 852 |
* out.println(" Params: "); if (pquery != null) { Hashtable |
849 |
* qparams = MetaCatUtil.parseQuery(u.getQuery()); for
|
|
853 |
* qparams = MetacatUtil.parseQuery(u.getQuery()); for
|
|
850 | 854 |
* (Enumeration en = qparams.keys(); en .hasMoreElements();) { |
851 | 855 |
* String pname = (String) en.nextElement(); String pvalue = |
852 | 856 |
* (String) qparams.get(pname); out.println(" " + pname + ": " + |
... | ... | |
864 | 868 |
// TODO MCD this interface is for testing. It should go through a |
865 | 869 |
// ServiceService class and only work for an admin user. Move to the |
866 | 870 |
// MetacatAdminServlet |
867 |
XMLSchemaService.getInstance().refresh();
|
|
871 |
ServiceService.refreshService("XMLSchemaService");
|
|
868 | 872 |
return; |
869 | 873 |
}else { |
870 | 874 |
PrintWriter out = response.getWriter(); |
... | ... | |
891 | 895 |
String errorString = "Utility error: " + ue.getMessage(); |
892 | 896 |
logMetacat.error(errorString); |
893 | 897 |
throw new ServletException(errorString); |
898 |
} catch (ServiceException ue) { |
|
899 |
String errorString = "Service error: " + ue.getMessage(); |
|
900 |
logMetacat.error(errorString); |
|
901 |
throw new ServletException(errorString); |
|
894 | 902 |
} |
895 | 903 |
} |
896 | 904 |
|
... | ... | |
1221 | 1229 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
1222 | 1230 |
logMetacat.warn("Total search time for action 'squery': " |
1223 | 1231 |
+ (outPutTime - startTime)); |
1224 |
MetaCatUtil.writeDebugToFile("---------------------------------------------------------------------------------"+
|
|
1232 |
MetacatUtil.writeDebugToFile("---------------------------------------------------------------------------------"+
|
|
1225 | 1233 |
"-------------------------------------------------------------------------------Total search time for " |
1226 | 1234 |
+ (outPutTime - startTime)); |
1227 |
MetaCatUtil.writeDebugToDelimiteredFile(" "+ (outPutTime - startTime), true);
|
|
1235 |
MetacatUtil.writeDebugToDelimiteredFile(" "+ (outPutTime - startTime), true);
|
|
1228 | 1236 |
} |
1229 | 1237 |
|
1230 | 1238 |
/** |
... | ... | |
1250 | 1258 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
1251 | 1259 |
logMetacat.warn("Total search time for action 'query': " |
1252 | 1260 |
+ (outPutTime - startTime)); |
1253 |
MetaCatUtil.writeDebugToFile("---------------------------------------------------------------------------------"+
|
|
1261 |
MetacatUtil.writeDebugToFile("---------------------------------------------------------------------------------"+
|
|
1254 | 1262 |
"-------------------------------------------------------------------------------Total search time is " |
1255 | 1263 |
+ (outPutTime - startTime)); |
1256 |
MetaCatUtil.writeDebugToDelimiteredFile(" "+ (outPutTime - startTime), true);
|
|
1264 |
MetacatUtil.writeDebugToDelimiteredFile(" "+ (outPutTime - startTime), true);
|
|
1257 | 1265 |
|
1258 | 1266 |
//handleSQuery(out, params, response,user, groups, sessionid); |
1259 | 1267 |
} |
... | ... | |
1383 | 1391 |
throw new Exception("You didn't specify requested inlinedataid"); } |
1384 | 1392 |
|
1385 | 1393 |
// check for permission |
1386 |
docId = MetaCatUtil
|
|
1394 |
docId = MetacatUtil
|
|
1387 | 1395 |
.getDocIdWithoutRevFromInlineDataID(inlineDataId); |
1388 | 1396 |
PermissionController controller = new PermissionController(docId); |
1389 | 1397 |
// check top level read permission |
... | ... | |
1398 | 1406 |
Hashtable<String,String> unReadableInlineDataList = |
1399 | 1407 |
PermissionController.getUnReadableInlineDataIdList(docId, |
1400 | 1408 |
user, groups, false); |
1401 |
String inlineDataIdWithoutRev = MetaCatUtil.getInlineDataIdWithoutRev(inlineDataId);
|
|
1409 |
String inlineDataIdWithoutRev = MetacatUtil.getInlineDataIdWithoutRev(inlineDataId);
|
|
1402 | 1410 |
if (unReadableInlineDataList.containsValue(inlineDataIdWithoutRev)) { |
1403 | 1411 |
throw new Exception("User " + user |
1404 | 1412 |
+ " doesn't have permission " + " to read inlinedata " |
... | ... | |
1457 | 1465 |
} |
1458 | 1466 |
} |
1459 | 1467 |
|
1460 |
// /* |
|
1461 |
// * Get the nodeid from xml_nodes for the inlinedataid |
|
1462 |
// */ |
|
1463 |
// private long getInlineDataNodeId(String inLineDataId, String docId) |
|
1464 |
// throws SQLException { |
|
1465 |
// Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
|
1466 |
// long nodeId = 0; |
|
1467 |
// String INLINE = "inline"; |
|
1468 |
// boolean hasRow; |
|
1469 |
// PreparedStatement pStmt = null; |
|
1470 |
// DBConnection conn = null; |
|
1471 |
// int serialNumber = -1; |
|
1472 |
// String sql = "SELECT nodeid FROM xml_nodes WHERE docid=? AND nodedata=? " |
|
1473 |
// + "AND nodetype='TEXT' AND parentnodeid IN " |
|
1474 |
// + "(SELECT nodeid FROM xml_nodes WHERE docid=? AND " |
|
1475 |
// + "nodetype='ELEMENT' AND nodename='" + INLINE + "')"; |
|
1476 |
// |
|
1477 |
// try { |
|
1478 |
// //check out DBConnection |
|
1479 |
// conn = DBConnectionPool |
|
1480 |
// .getDBConnection("AccessControlList.isAllowFirst"); |
|
1481 |
// serialNumber = conn.getCheckOutSerialNumber(); |
|
1482 |
// |
|
1483 |
// pStmt = conn.prepareStatement(sql); |
|
1484 |
// //bind value |
|
1485 |
// pStmt.setString(1, docId);//docid |
|
1486 |
// pStmt.setString(2, inLineDataId);//inlinedataid |
|
1487 |
// pStmt.setString(3, docId); |
|
1488 |
// // excute query |
|
1489 |
// pStmt.execute(); |
|
1490 |
// ResultSet rs = pStmt.getResultSet(); |
|
1491 |
// hasRow = rs.next(); |
|
1492 |
// // get result |
|
1493 |
// if (hasRow) { |
|
1494 |
// nodeId = rs.getLong(1); |
|
1495 |
// }//if |
|
1496 |
// |
|
1497 |
// } catch (SQLException e) { |
|
1498 |
// throw e; |
|
1499 |
// } finally { |
|
1500 |
// try { |
|
1501 |
// pStmt.close(); |
|
1502 |
// } finally { |
|
1503 |
// DBConnectionPool.returnDBConnection(conn, serialNumber); |
|
1504 |
// } |
|
1505 |
// } |
|
1506 |
// logMetacat.debug("The nodeid for inlinedataid " + inLineDataId |
|
1507 |
// + " is: " + nodeId); |
|
1508 |
// return nodeId; |
|
1509 |
// } |
|
1510 |
|
|
1511 | 1468 |
/** |
1512 | 1469 |
* Handle the "read" request of metadata/data files from Metacat or any |
1513 | 1470 |
* files from Internet; transformed metadata XML document into HTML |
... | ... | |
1566 | 1523 |
try { |
1567 | 1524 |
|
1568 | 1525 |
URL murl = new URL(docs[i]); |
1569 |
Hashtable<String,String> murlQueryStr = MetaCatUtil.parseQuery(
|
|
1526 |
Hashtable<String,String> murlQueryStr = MetacatUtil.parseQuery(
|
|
1570 | 1527 |
murl.getQuery()); |
1571 | 1528 |
// case docid="http://.../?docid=aaa" |
1572 | 1529 |
// or docid="metacat://.../?docid=bbb" |
... | ... | |
2369 | 2326 |
// Delete from spatial cache if runningSpatialOption |
2370 | 2327 |
if ( PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { |
2371 | 2328 |
SpatialHarvester sh = new SpatialHarvester(); |
2372 |
sh.addToDeleteQue( MetaCatUtil.getSmartDocId( docid[0] ) );
|
|
2329 |
sh.addToDeleteQue( MetacatUtil.getSmartDocId( docid[0] ) );
|
|
2373 | 2330 |
sh.destroy(); |
2374 | 2331 |
} |
2375 | 2332 |
|
... | ... | |
2893 | 2850 |
String fileTempLocation; |
2894 | 2851 |
|
2895 | 2852 |
// the filePart will be clobbered on the next loop, save to disk |
2896 |
fileTempLocation = MetaCatUtil.writeTempFile(filePart, fileName);
|
|
2853 |
fileTempLocation = MetacatUtil.writeTempFile(filePart, fileName);
|
|
2897 | 2854 |
fileList.put(name, fileTempLocation); |
2898 | 2855 |
fileList.put("filename", fileName); |
2899 | 2856 |
fileList.put("name", fileTempLocation); |
... | ... | |
3064 | 3021 |
// copy file to desired output location |
3065 | 3022 |
try |
3066 | 3023 |
{ |
3067 |
MetaCatUtil.copyFile(tempFileName, newFileName);
|
|
3024 |
MetacatUtil.copyFile(tempFileName, newFileName);
|
|
3068 | 3025 |
} |
3069 | 3026 |
catch (IOException ioe) |
3070 | 3027 |
{ |
... | ... | |
3187 | 3144 |
if ( fileExists == false ) { |
3188 | 3145 |
// copy file to desired output location |
3189 | 3146 |
try { |
3190 |
MetaCatUtil.copyFile(tempFileName, newFileName);
|
|
3147 |
MetacatUtil.copyFile(tempFileName, newFileName);
|
|
3191 | 3148 |
} catch (IOException ioe) { |
3192 | 3149 |
logMetacat.error("IO Exception copying file: " + |
3193 | 3150 |
ioe.getMessage()); |
... | ... | |
3344 | 3301 |
Vector<String> packageSet = null; |
3345 | 3302 |
try { |
3346 | 3303 |
packageSet = |
3347 |
MetaCatUtil.getOptionList(PropertyService.getProperty("xml.packagedoctypeset"));
|
|
3304 |
MetacatUtil.getOptionList(PropertyService.getProperty("xml.packagedoctypeset"));
|
|
3348 | 3305 |
} catch (PropertyNotFoundException pnfe) { |
3349 | 3306 |
logMetacat.error("Could not find package doctype set. Setting to null: " |
3350 | 3307 |
+ pnfe.getMessage()); |
... | ... | |
3464 | 3421 |
int serialNumber = -1; |
3465 | 3422 |
|
3466 | 3423 |
// get rid of revision if access number has |
3467 |
docId = MetaCatUtil.getDocIdFromString(accessionNumber);
|
|
3424 |
docId = MetacatUtil.getDocIdFromString(accessionNumber);
|
|
3468 | 3425 |
try { |
3469 | 3426 |
//check out DBConnection |
3470 | 3427 |
conn = DBConnectionPool |
src/edu/ucsb/nceas/metacat/ContentTypeProvider.java | ||
---|---|---|
57 | 57 |
import org.ecoinformatics.eml.EMLParser; |
58 | 58 |
|
59 | 59 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
60 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
60 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
61 | 61 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
62 | 62 |
/** |
63 | 63 |
* This class will figure out which content type it is for a given data file. |
... | ... | |
121 | 121 |
*/ |
122 | 122 |
public ContentTypeProvider(String docIdWithRevision) |
123 | 123 |
{ |
124 |
dataFileId = MetaCatUtil.getDocIdFromString(docIdWithRevision);
|
|
124 |
dataFileId = MetacatUtil.getDocIdFromString(docIdWithRevision);
|
|
125 | 125 |
//get relative doclist for data file and package type |
126 | 126 |
Vector docLists = null; |
127 | 127 |
docLists = getRelativeDocIdList(dataFileId); |
... | ... | |
342 | 342 |
if (URLData.indexOf(DBSAXHandler.ECOGRID) != -1 ) |
343 | 343 |
{ |
344 | 344 |
// Get docid from url |
345 |
String docId = MetaCatUtil.
|
|
345 |
String docId = MetacatUtil.
|
|
346 | 346 |
getAccessionNumberFromEcogridIdentifier(URLData); |
347 | 347 |
// Get rid of revision |
348 |
docId = MetaCatUtil.getDocIdFromAccessionNumber(docId);
|
|
348 |
docId = MetacatUtil.getDocIdFromAccessionNumber(docId);
|
|
349 | 349 |
logMetacat.info("docid from url element in xml is: " + |
350 | 350 |
docId); |
351 | 351 |
//if this docid equals target one, we find it |
... | ... | |
403 | 403 |
}//while |
404 | 404 |
|
405 | 405 |
// set up data package type |
406 |
if ((MetaCatUtil.getOptionList(PropertyService.getProperty("xml.packagedoctype"))).
|
|
406 |
if ((MetacatUtil.getOptionList(PropertyService.getProperty("xml.packagedoctype"))).
|
|
407 | 407 |
contains(packType)) |
408 | 408 |
{ |
409 | 409 |
//this is beta4 or beta6 version |
410 | 410 |
logMetacat.warn("This is beta package"); |
411 | 411 |
packageType = BETA; |
412 | 412 |
} |
413 |
else if ((MetaCatUtil.getOptionList
|
|
413 |
else if ((MetacatUtil.getOptionList
|
|
414 | 414 |
(PropertyService.getProperty("xml.eml2_0_0namespace"))).contains(packType)) |
415 | 415 |
{ |
416 | 416 |
// this eml 2 document |
417 | 417 |
logMetacat.warn("This is EML2.0.0 package"); |
418 | 418 |
packageType = EML2; |
419 | 419 |
} |
420 |
else if ((MetaCatUtil.getOptionList
|
|
420 |
else if ((MetacatUtil.getOptionList
|
|
421 | 421 |
(PropertyService.getProperty("xml.eml2_0_1namespace"))).contains(packType)) |
422 | 422 |
{ |
423 | 423 |
// this eml 2 document |
... | ... | |
503 | 503 |
String packType = rs.getString(1); |
504 | 504 |
String targetId = rs.getString(2); |
505 | 505 |
// find physical document |
506 |
if ((MetaCatUtil.getOptionList(PropertyService.getProperty(targetType))).
|
|
506 |
if ((MetacatUtil.getOptionList(PropertyService.getProperty(targetType))).
|
|
507 | 507 |
contains(packType)) |
508 | 508 |
{ |
509 | 509 |
// assign physical document and jump out the while loop |
src/edu/ucsb/nceas/metacat/IndexingTimerTask.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
37 | 37 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
38 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
38 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
39 | 39 |
|
40 | 40 |
import org.apache.log4j.Logger; |
41 | 41 |
|
... | ... | |
60 | 60 |
|
61 | 61 |
dbConn = DBConnectionPool.getDBConnection("IndexingThread"); |
62 | 62 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
63 |
Vector indexNamespaces = MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexNamespaces"));
|
|
63 |
Vector indexNamespaces = MetacatUtil.getOptionList(PropertyService.getProperty("xml.indexNamespaces"));
|
|
64 | 64 |
String nonJoinCriteria = "b.docid is NULL"; |
65 | 65 |
boolean first = true; |
66 | 66 |
|
src/edu/ucsb/nceas/metacat/PermissionController.java | ||
---|---|---|
37 | 37 |
import org.apache.log4j.Logger; |
38 | 38 |
|
39 | 39 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
40 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
40 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
41 | 41 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
42 | 42 |
|
43 | 43 |
public class PermissionController |
... | ... | |
59 | 59 |
public PermissionController(String myDocid) throws McdbException |
60 | 60 |
{ |
61 | 61 |
// Get rid of rev number |
62 |
docId = MetaCatUtil.getSmartDocId(myDocid);
|
|
62 |
docId = MetacatUtil.getSmartDocId(myDocid);
|
|
63 | 63 |
//hasSubTreeAccessControl = checkSubTreeAccessControl(); |
64 | 64 |
} |
65 | 65 |
|
... | ... | |
76 | 76 |
} |
77 | 77 |
else |
78 | 78 |
{ |
79 |
docId = MetaCatUtil.getDocIdFromAccessionNumber(myDocid);
|
|
79 |
docId = MetacatUtil.getDocIdFromAccessionNumber(myDocid);
|
|
80 | 80 |
} |
81 | 81 |
} |
82 | 82 |
|
... | ... | |
431 | 431 |
*/ |
432 | 432 |
private boolean isAccessDocument(String docId) throws SQLException { |
433 | 433 |
// detele the rev number if docid contains it |
434 |
docId = MetaCatUtil.getDocIdFromString(docId);
|
|
434 |
docId = MetacatUtil.getDocIdFromString(docId);
|
|
435 | 435 |
PreparedStatement pStmt = null; |
436 | 436 |
DBConnection conn = null; |
437 | 437 |
int serialNumber = -1; |
... | ... | |
453 | 453 |
|
454 | 454 |
// if it is an access document |
455 | 455 |
if (doctype != null |
456 |
&& ((MetaCatUtil.getOptionList(PropertyService
|
|
456 |
&& ((MetacatUtil.getOptionList(PropertyService
|
|
457 | 457 |
.getProperty("xml.accessdoctype")).contains(doctype)))) { |
458 | 458 |
|
459 | 459 |
return true; |
... | ... | |
1106 | 1106 |
{ |
1107 | 1107 |
logMetacat.info("Put subtree id " + subTreeId + |
1108 | 1108 |
" and " + "inline data file name " + |
1109 |
MetaCatUtil.
|
|
1109 |
MetacatUtil.
|
|
1110 | 1110 |
getInlineDataIdWithoutRev(fileId) + |
1111 | 1111 |
" into " + "un" + permission + |
1112 | 1112 |
" hash"); |
1113 |
unAccessibleIdList.put(subTreeId, MetaCatUtil.
|
|
1113 |
unAccessibleIdList.put(subTreeId, MetacatUtil.
|
|
1114 | 1114 |
getInlineDataIdWithoutRev(fileId)); |
1115 | 1115 |
} |
1116 | 1116 |
} |
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
59 | 59 |
import edu.ucsb.nceas.metacat.service.XMLSchemaService; |
60 | 60 |
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester; |
61 | 61 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
62 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
62 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
63 | 63 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
64 | 64 |
import edu.ucsb.nceas.utilities.FileUtil; |
65 | 65 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
183 | 183 |
{ |
184 | 184 |
try { |
185 | 185 |
//this.conn = conn; |
186 |
this.docid = MetaCatUtil.getDocIdFromAccessionNumber(accNum);
|
|
187 |
this.rev = MetaCatUtil.getRevisionFromAccessionNumber(accNum);
|
|
186 |
this.docid = MetacatUtil.getDocIdFromAccessionNumber(accNum);
|
|
187 |
this.rev = MetacatUtil.getRevisionFromAccessionNumber(accNum);
|
|
188 | 188 |
|
189 | 189 |
// Look up the document information |
190 | 190 |
getDocumentInfo(docid, rev); |
... | ... | |
334 | 334 |
serialNumber = conn.getCheckOutSerialNumber(); |
335 | 335 |
conn.setAutoCommit(false); |
336 | 336 |
String action = null; |
337 |
String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
|
|
338 |
int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
|
|
337 |
String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnum);
|
|
338 |
int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
|
|
339 | 339 |
action = checkRevInXMLDocuments(docIdWithoutRev, userSpecifyRev); |
340 | 340 |
logMetacat.warn("after check rev, the action is "+action); |
341 | 341 |
if (action.equals("UPDATE")) |
... | ... | |
414 | 414 |
serialNumber = conn.getCheckOutSerialNumber(); |
415 | 415 |
conn.setAutoCommit(false); |
416 | 416 |
String action = null; |
417 |
String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
|
|
418 |
int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
|
|
417 |
String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnum);
|
|
418 |
int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
|
|
419 | 419 |
if (tableName.equals(DOCUMENTTABLE)) |
420 | 420 |
{ |
421 | 421 |
action = checkRevInXMLDocuments(docIdWithoutRev, userSpecifyRev); |
... | ... | |
743 | 743 |
throws Exception |
744 | 744 |
{ |
745 | 745 |
boolean flag = true; |
746 |
String docid = MetaCatUtil.getDocIdFromString(accnum);
|
|
747 |
int rev = MetaCatUtil.getVersionFromString(accnum);
|
|
746 |
String docid = MetacatUtil.getDocIdFromString(accnum);
|
|
747 |
int rev = MetacatUtil.getVersionFromString(accnum);
|
|
748 | 748 |
|
749 | 749 |
if (serverCode == 1) { |
750 | 750 |
flag = true; |
... | ... | |
764 | 764 |
.getServerNameForServerCode(serverCode); |
765 | 765 |
MetacatReplication.replLog("attempting to lock " + accnum); |
766 | 766 |
URL u = new URL("https://" + server + "?server=" |
767 |
+ MetaCatUtil.getLocalReplicationServerName()
|
|
767 |
+ MetacatUtil.getLocalReplicationServerName()
|
|
768 | 768 |
+ "&action=getlock&updaterev=" + rev + "&docid=" + docid); |
769 | 769 |
//System.out.println("sending message: " + u.toString()); |
770 | 770 |
String serverResStr = MetacatReplication.getURLContent(u); |
... | ... | |
1195 | 1195 |
// if it is inline data first to get the inline data |
1196 | 1196 |
// internal id |
1197 | 1197 |
String fileName = currentNode.getNodeData(); |
1198 |
String accessfileName = MetaCatUtil
|
|
1198 |
String accessfileName = MetacatUtil
|
|
1199 | 1199 |
.getDocIdWithoutRevFromInlineDataID(fileName); |
1200 | 1200 |
// check if user has read permision for this inline data |
1201 | 1201 |
boolean readInlinedata = false; |
... | ... | |
1724 | 1724 |
currentName, docid, doctype, parentId)); |
1725 | 1725 |
} |
1726 | 1726 |
} |
1727 |
if( MetaCatUtil.pathsForIndexing.contains(currentName) &&
|
|
1727 |
if( MetacatUtil.pathsForIndexing.contains(currentName) &&
|
|
1728 | 1728 |
leafData.trim().length() != 0 ){ |
1729 | 1729 |
logMetacat.debug("paths found for indexing: " + currentName); |
1730 | 1730 |
pathsFoundForIndexing.put(currentName, new PathIndexEntry( |
... | ... | |
1748 | 1748 |
logMetacat.debug("B: " + path +"\n"); |
1749 | 1749 |
pathList.put(path, new PathIndexEntry(leafNodeId, path, docid, |
1750 | 1750 |
doctype, parentId)); |
1751 |
if( MetaCatUtil.pathsForIndexing.contains(path) &&
|
|
1751 |
if( MetacatUtil.pathsForIndexing.contains(path) &&
|
|
1752 | 1752 |
leafData.trim().length() != 0 ){ |
1753 | 1753 |
logMetacat.debug("paths found for indexing: " + currentName); |
1754 | 1754 |
pathsFoundForIndexing.put(path, new PathIndexEntry( |
... | ... | |
1765 | 1765 |
logMetacat.debug("C: " + fullPath +"\n"); |
1766 | 1766 |
pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath, |
1767 | 1767 |
docid, doctype, parentId)); |
1768 |
if( MetaCatUtil.pathsForIndexing.contains(fullPath) &&
|
|
1768 |
if( MetacatUtil.pathsForIndexing.contains(fullPath) &&
|
|
1769 | 1769 |
leafData.trim().length() != 0 ){ |
1770 | 1770 |
logMetacat.debug("paths found for indexing: " + currentName); |
1771 | 1771 |
pathsFoundForIndexing.put(fullPath, new PathIndexEntry( |
... | ... | |
1785 | 1785 |
*/ |
1786 | 1786 |
private void deleteNodeIndex(DBConnection conn) throws SQLException |
1787 | 1787 |
{ |
1788 |
//String familyId = MetaCatUtil.getDocIdFromString(docid);
|
|
1788 |
//String familyId = MetacatUtil.getDocIdFromString(docid);
|
|
1789 | 1789 |
double start = System.currentTimeMillis()/1000; |
1790 | 1790 |
String familyId = docid; |
1791 | 1791 |
String sql = "DELETE FROM xml_index WHERE docid = ?"; |
... | ... | |
2054 | 2054 |
if (!server.equals("localhost")) { |
2055 | 2055 |
this.docHomeServer = server; |
2056 | 2056 |
} else { |
2057 |
this.docHomeServer = MetaCatUtil
|
|
2057 |
this.docHomeServer = MetacatUtil
|
|
2058 | 2058 |
.getLocalReplicationServerName(); |
2059 | 2059 |
} |
2060 | 2060 |
logMetacat.info("server: " + docHomeServer); |
... | ... | |
2173 | 2173 |
try |
2174 | 2174 |
{ |
2175 | 2175 |
logMetacat.debug("Node data in read process before normalize=== "+nodedata); |
2176 |
nodedata = MetaCatUtil.normalize(nodedata);
|
|
2176 |
nodedata = MetacatUtil.normalize(nodedata);
|
|
2177 | 2177 |
logMetacat.debug("Node data in read process after normalize==== "+nodedata); |
2178 | 2178 |
} catch (java.lang.StringIndexOutOfBoundsException SIO){ |
2179 | 2179 |
logMetacat.warn("StringIndexOutOfBoundsException in normalize() while reading the document"); |
... | ... | |
2538 | 2538 |
} |
2539 | 2539 |
|
2540 | 2540 |
//DocumentIdentifier id = new DocumentIdentifier(accnum); |
2541 |
int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
|
|
2541 |
int revision = MetacatUtil.getRevisionFromAccessionNumber(accnum);
|
|
2542 | 2542 |
String updaterev = (new Integer(revision)).toString(); |
2543 | 2543 |
String server = MetacatReplication |
2544 | 2544 |
.getServerNameForServerCode(serverCode); |
2545 | 2545 |
MetacatReplication.replLog("attempting to lock " + accnum); |
2546 | 2546 |
URL u = new URL("https://" + server + "?server=" |
2547 |
+ MetaCatUtil.getLocalReplicationServerName()
|
|
2547 |
+ MetacatUtil.getLocalReplicationServerName()
|
|
2548 | 2548 |
+ "&action=getlock&updaterev=" + updaterev + "&docid=" |
2549 | 2549 |
+ docid); |
2550 | 2550 |
//System.out.println("sending message: " + u.toString()); |
... | ... | |
2769 | 2769 |
String catalogId = null; |
2770 | 2770 |
logMetacat.info("user in replication" + user); |
2771 | 2771 |
// Docid without revision |
2772 |
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
|
|
2772 |
String docid = MetacatUtil.getDocIdFromAccessionNumber(accnum);
|
|
2773 | 2773 |
logMetacat.warn("The docid without rev is " + docid); |
2774 | 2774 |
// Revision specified by user (int) |
2775 |
int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
|
|
2775 |
int userSpecifyRev = MetacatUtil.getRevisionFromAccessionNumber(accnum);
|
|
2776 | 2776 |
logMetacat.warn("The user specifyRev: " + userSpecifyRev); |
2777 | 2777 |
// Revision for this docid in current database |
2778 | 2778 |
int revInDataBase = DBUtil.getLatestRevisionInDocumentTable(docid); |
... | ... | |
2921 | 2921 |
try { |
2922 | 2922 |
String packagedoctype = PropertyService.getProperty("xml.packagedoctype"); |
2923 | 2923 |
Vector<String> packagedoctypes = new Vector<String>(); |
2924 |
packagedoctypes = MetaCatUtil.getOptionList(packagedoctype);
|
|
2925 |
String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnumber);
|
|
2926 |
int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnumber);
|
|
2924 |
packagedoctypes = MetacatUtil.getOptionList(packagedoctype);
|
|
2925 |
String docIdWithoutRev = MetacatUtil.getDocIdFromAccessionNumber(accnumber);
|
|
2926 |
int revision = MetacatUtil.getRevisionFromAccessionNumber(accnumber);
|
|
2927 | 2927 |
if (documenttype != null && |
2928 | 2928 |
packagedoctypes.contains(documenttype)) { |
2929 | 2929 |
dbconn = DBConnectionPool.getDBConnection( |
... | ... | |
2934 | 2934 |
String aclidWithRev = RelationHandler.getAccessFileIDWithRevision(docIdWithoutRev); |
2935 | 2935 |
if (aclidWithRev != null) |
2936 | 2936 |
{ |
2937 |
String aclid = MetaCatUtil.getDocIdFromAccessionNumber(aclidWithRev);
|
|
2938 |
revision = MetaCatUtil.getRevisionFromAccessionNumber(aclidWithRev);
|
|
2937 |
String aclid = MetacatUtil.getDocIdFromAccessionNumber(aclidWithRev);
|
|
2938 |
revision = MetacatUtil.getRevisionFromAccessionNumber(aclidWithRev);
|
|
2939 | 2939 |
|
2940 | 2940 |
// if there are access file, write ACL for that package |
2941 | 2941 |
if (aclid != null) { |
... | ... | |
2948 | 2948 |
} |
2949 | 2949 |
// if it is an access file |
2950 | 2950 |
else if (documenttype != null |
2951 |
&& MetaCatUtil.getOptionList(
|
|
2951 |
&& MetacatUtil.getOptionList(
|
|
2952 | 2952 |
PropertyService.getProperty("xml.accessdoctype")).contains( |
2953 | 2953 |
documenttype)) { |
2954 | 2954 |
dbconn = DBConnectionPool.getDBConnection( |
... | ... | |
3003 | 3003 |
int serialNumber = -1; |
3004 | 3004 |
try { |
3005 | 3005 |
//get rid of revision number |
3006 |
docid = MetaCatUtil.getDocIdFromString(accnumber);
|
|
3006 |
docid = MetacatUtil.getDocIdFromString(accnumber);
|
|
3007 | 3007 |
dbConnection = DBConnectionPool.getDBConnection( |
3008 | 3008 |
"DocumentImpl.getDocTypeFromDBForCurrentDoc"); |
3009 | 3009 |
serialNumber = dbConnection.getCheckOutSerialNumber(); |
... | ... | |
3057 | 3057 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV |
3058 | 3058 |
// IN IT |
3059 | 3059 |
//AccessionNumber ac = new AccessionNumber(accnum, "DELETE"); |
3060 |
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
|
|
3060 |
String docid = MetacatUtil.getDocIdFromAccessionNumber(accnum);
|
|
3061 | 3061 |
//String rev = ac.getRev(); |
3062 | 3062 |
|
3063 | 3063 |
// Check if the document exists. |
... | ... | |
3655 | 3655 |
throws SQLException |
3656 | 3656 |
{ |
3657 | 3657 |
//get rid of revNum part |
3658 |
String docId = MetaCatUtil.getDocIdFromString(accNum);
|
|
3658 |
String docId = MetacatUtil.getDocIdFromString(accNum);
|
|
3659 | 3659 |
PreparedStatement pStmt = null; |
3660 | 3660 |
int serverLocation = 1; |
3661 | 3661 |
DBConnection conn = null; |
... | ... | |
3717 | 3717 |
int serialNumber = -1; |
3718 | 3718 |
|
3719 | 3719 |
//we should consider about local host too |
3720 |
if (serverName.equals(MetaCatUtil.getLocalReplicationServerName())) {
|
|
3720 |
if (serverName.equals(MetacatUtil.getLocalReplicationServerName())) {
|
|
3721 | 3721 |
serverLocation = 1; |
3722 | 3722 |
return serverLocation; |
3723 | 3723 |
} |
... | ... | |
3801 | 3801 |
// If the server is not in the table, and server is not local host, |
3802 | 3802 |
// insert it |
3803 | 3803 |
if (!hasRow |
3804 |
&& !server.equals(MetaCatUtil
|
|
3804 |
&& !server.equals(MetacatUtil
|
|
3805 | 3805 |
.getLocalReplicationServerName())) { |
3806 | 3806 |
// Set auto commit false |
3807 | 3807 |
dbConn.setAutoCommit(false); |
... | ... | |
4139 | 4139 |
dbconn = DBConnectionPool.getDBConnection( |
4140 | 4140 |
"DeletedDocumentImpl.registerDeletedDataFile"); |
4141 | 4141 |
serialNumber = dbconn.getCheckOutSerialNumber(); |
4142 |
String docIdWithoutRev = MetaCatUtil
|
|
4142 |
String docIdWithoutRev = MetacatUtil
|
|
4143 | 4143 |
.getDocIdFromAccessionNumber(accnum); |
4144 |
String rev = MetaCatUtil.getRevisionStringFromString(accnum);
|
|
4144 |
String rev = MetacatUtil.getRevisionStringFromString(accnum);
|
|
4145 | 4145 |
writeDocumentToRevisionTable(dbconn, docIdWithoutRev, |
4146 | 4146 |
rev, doctype, docname, user, |
4147 | 4147 |
null, serverCode, -1, createDate, updateDate); |
src/edu/ucsb/nceas/metacat/ReplicationHandler.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import edu.ucsb.nceas.metacat.service.DatabaseService; |
30 | 30 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
31 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
|
|
31 |
import edu.ucsb.nceas.metacat.util.MetacatUtil;
|
|
32 | 32 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
33 | 33 |
|
34 | 34 |
import java.sql.*; |
... | ... | |
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; |
... | ... | |
154 | 154 |
try |
155 | 155 |
{ |
156 | 156 |
u = new URL("https://" + server + "?server=" |
157 |
+MetaCatUtil.getLocalReplicationServerName()+"&action=update");
|
|
157 |
+MetacatUtil.getLocalReplicationServerName()+"&action=update");
|
|
158 | 158 |
logMetacat.info("Sending infomation " +u.toString()); |
159 | 159 |
result = MetacatReplication.getURLContent(u); |
160 | 160 |
} |
... | ... | |
298 | 298 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
299 | 299 |
//if the document needs to be updated or inserted, this is executed |
300 | 300 |
String readDocURLString = "https://" + remoteserver + "?server="+ |
301 |
MetaCatUtil.getLocalReplicationServerName()+"&action=read&docid="+accNumber;
|
|
302 |
readDocURLString = MetaCatUtil.replaceWhiteSpaceForURL(readDocURLString);
|
|
301 |
MetacatUtil.getLocalReplicationServerName()+"&action=read&docid="+accNumber;
|
|
302 |
readDocURLString = MetacatUtil.replaceWhiteSpaceForURL(readDocURLString);
|
|
303 | 303 |
URL u = new URL(readDocURLString); |
304 | 304 |
|
305 | 305 |
// Get docid content |
... | ... | |
316 | 316 |
DocInfoHandler dih = new DocInfoHandler(); |
317 | 317 |
XMLReader docinfoParser = initParser(dih); |
318 | 318 |
String docInfoURLStr = "https://" + remoteserver + |
319 |
"?server="+MetaCatUtil.getLocalReplicationServerName()+
|
|
319 |
"?server="+MetacatUtil.getLocalReplicationServerName()+
|
|
320 | 320 |
"&action=getdocumentinfo&docid="+accNumber; |
321 |
docInfoURLStr = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLStr); |
|
321 |
docInfoURLStr = MetacatUtil.replaceWhiteSpaceForURL(docInfoURLStr); |
Also available in: Unified diff
Renamed MetaCatUtil to MetacatUtil