Revision 4854
Added by daigle over 15 years ago
src/edu/ucsb/nceas/metacat/util/UtilException.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: An Exception thrown when an error occurs because an |
|
4 |
* AccessionNumber was invalid or used incorrectly |
|
5 |
* Copyright: 2008 Regents of the University of California and the |
|
6 |
* National Center for Ecological Analysis and Synthesis |
|
7 |
* Authors: Michael Daigle |
|
8 |
* |
|
9 |
* '$Author$' |
|
10 |
* '$Date$' |
|
11 |
* '$Revision$' |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or modify |
|
14 |
* it under the terms of the GNU General Public License as published by |
|
15 |
* the Free Software Foundation; either version 2 of the License, or |
|
16 |
* (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
*/ |
|
27 |
|
|
28 |
package edu.ucsb.nceas.metacat.util; |
|
29 |
/** |
|
30 |
* Exception thrown when an error occurs in a utility method |
|
31 |
*/ |
|
32 |
public class UtilException extends Exception { |
|
33 |
|
|
34 |
private static final long serialVersionUID = -253071242028406390L; |
|
35 |
|
|
36 |
/** |
|
37 |
* Create a new AdminException. |
|
38 |
* |
|
39 |
* @param message The error or warning message. |
|
40 |
*/ |
|
41 |
public UtilException(String message) { |
|
42 |
super(message); |
|
43 |
} |
|
44 |
} |
|
45 | 0 |
src/edu/ucsb/nceas/metacat/QuerySpecification.java | ||
---|---|---|
37 | 37 |
import java.util.Vector; |
38 | 38 |
|
39 | 39 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
40 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException; |
|
40 | 41 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
41 |
import edu.ucsb.nceas.metacat.util.UtilException;
|
|
42 |
//import edu.ucsb.nceas.utilities.UtilException;
|
|
42 | 43 |
|
43 | 44 |
import org.apache.log4j.Logger; |
44 | 45 |
import org.xml.sax.Attributes; |
... | ... | |
957 | 958 |
* @param unaccessableNodePair the node pairs (start id and end id) |
958 | 959 |
* which this user should not access |
959 | 960 |
*/ |
960 |
private String printExtendedSQL(String doclist) |
|
961 |
{ |
|
961 |
private String printExtendedSQL(String doclist) { |
|
962 | 962 |
logMetacat.info("querySpecification.printExtendedSQL called\n"); |
963 | 963 |
StringBuffer self = new StringBuffer(); |
964 | 964 |
Vector elementVector = new Vector(); |
... | ... | |
975 | 975 |
String path = (String)returnFieldList.elementAt(i); |
976 | 976 |
// Since return fileds having preicates will be handle in another path, |
977 | 977 |
// we should skip it. |
978 |
if (returnFieldListWithPredicates.contains(path)) |
|
979 |
{ |
|
978 |
if (returnFieldListWithPredicates.contains(path)) { |
|
980 | 979 |
continue; |
981 | 980 |
} |
982 |
if (path != null && path.indexOf(ATTRIBUTESYMBOL) != -1) |
|
983 |
{ |
|
981 |
|
|
982 |
if (path != null && path.indexOf(ATTRIBUTESYMBOL) != -1) {
|
|
984 | 983 |
attributeVector.add(path); |
985 |
} |
|
986 |
else |
|
987 |
{ |
|
984 |
} else { |
|
988 | 985 |
elementVector.add(path); |
989 | 986 |
} |
987 |
|
|
988 |
|
|
990 | 989 |
try { |
991 |
if(!SystemUtil.getPathsForIndexing().contains(path)){
|
|
992 |
usePathIndex = false;
|
|
993 |
}
|
|
994 |
} catch (UtilException ue) {
|
|
995 |
logMetacat.warn("Could not get index paths: " + ue.getMessage());
|
|
996 |
}
|
|
990 |
if (!SystemUtil.getPathsForIndexing().contains(path)) {
|
|
991 |
usePathIndex = false;
|
|
992 |
}
|
|
993 |
} catch (MetacatUtilException mue) {
|
|
994 |
logMetacat.warn("Could not get index paths: " + mue.getMessage());
|
|
995 |
}
|
|
997 | 996 |
|
998 | 997 |
} |
999 | 998 |
// check if has return field |
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
1147 | 1147 |
} |
1148 | 1148 |
|
1149 | 1149 |
|
1150 |
/** |
|
1151 |
* Sends a document to a remote host |
|
1152 |
*/ |
|
1153 |
private void handleGetDocumentRequest(PrintWriter out, Hashtable<String, String[]> params, |
|
1154 |
HttpServletResponse response) |
|
1155 |
{ |
|
1150 |
/** |
|
1151 |
* Sends a document to a remote host |
|
1152 |
*/ |
|
1153 |
private void handleGetDocumentRequest(PrintWriter out, |
|
1154 |
Hashtable<String, String[]> params, HttpServletResponse response) { |
|
1156 | 1155 |
|
1157 |
try |
|
1158 |
{ |
|
1159 |
//try to open a https stream to test if the request server's public key |
|
1160 |
//in the key store, this is security issue |
|
1161 |
String server = params.get("server")[0]; |
|
1162 |
URL u = new URL("https://" + server + "?server=" |
|
1163 |
+MetacatUtil.getLocalReplicationServerName() |
|
1164 |
+"&action=test"); |
|
1165 |
String test = MetacatReplication.getURLContent(u); |
|
1166 |
//couldn't pass the test |
|
1167 |
if (test.indexOf("successfully")==-1) |
|
1168 |
{ |
|
1169 |
response.setContentType("text/xml"); |
|
1170 |
out.println("<error>Couldn't pass the trust test "+test+" </error>"); |
|
1171 |
out.close(); |
|
1172 |
return; |
|
1173 |
} |
|
1156 |
String urlString = null; |
|
1157 |
String documentPath = null; |
|
1158 |
try { |
|
1159 |
// try to open a https stream to test if the request server's public |
|
1160 |
// key |
|
1161 |
// in the key store, this is security issue |
|
1162 |
String server = params.get("server")[0]; |
|
1163 |
urlString = "https://" + server + "?server=" |
|
1164 |
+ MetacatUtil.getLocalReplicationServerName() + "&action=test"; |
|
1165 |
URL u = new URL(urlString); |
|
1166 |
String test = MetacatReplication.getURLContent(u); |
|
1167 |
// couldn't pass the test |
|
1168 |
if (test.indexOf("successfully") == -1) { |
|
1169 |
response.setContentType("text/xml"); |
|
1170 |
out.println("<error>Couldn't pass the trust test " + test + " </error>"); |
|
1171 |
out.close(); |
|
1172 |
return; |
|
1173 |
} |
|
1174 | 1174 |
|
1175 |
String docid = params.get("docid")[0]; |
|
1176 |
DocumentImpl di = new DocumentImpl(docid); |
|
1177 |
|
|
1178 |
String documentDir = PropertyService.getProperty("application.documentfilepath"); |
|
1179 |
String documentPath = documentDir + FileUtil.getFS() + docid; |
|
1180 |
|
|
1181 |
// if the document does not exist on disk, read it from db and write |
|
1182 |
// it to disk. |
|
1183 |
if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST) { |
|
1184 |
FileWriter fileWriter = new FileWriter(documentPath); |
|
1185 |
di.toXml(fileWriter, null, null, true); |
|
1186 |
} |
|
1187 |
|
|
1188 |
// read the file from disk and sent it to PrintWriter |
|
1189 |
// PrintWriter out = new PrintWriter(streamOut); |
|
1190 |
di.readFromFileSystem(out, null, null, documentPath); |
|
1175 |
String docid = params.get("docid")[0]; |
|
1176 |
DocumentImpl di = new DocumentImpl(docid); |
|
1191 | 1177 |
|
1192 |
// response.setContentType("text/xml");
|
|
1193 |
// out.print(di.toString(null, null, true));
|
|
1178 |
String documentDir = PropertyService.getProperty("application.documentfilepath");
|
|
1179 |
documentPath = documentDir + FileUtil.getFS() + docid;
|
|
1194 | 1180 |
|
1195 |
MetacatReplication.replLog("document " + docid + " sent"); |
|
1181 |
// if the document does not exist on disk, read it from db and write |
|
1182 |
// it to disk. |
|
1183 |
if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST |
|
1184 |
|| FileUtil.getFileSize(documentPath) == 0) { |
|
1185 |
FileWriter fileWriter = new FileWriter(documentPath); |
|
1186 |
di.toXml(fileWriter, null, null, true); |
|
1187 |
} |
|
1196 | 1188 |
|
1197 |
} |
|
1198 |
catch(Exception e) |
|
1199 |
{ |
|
1200 |
logMetacat.error("error getting document from MetacatReplication." |
|
1201 |
+"handlGetDocumentRequest " + e.getMessage()); |
|
1202 |
//e.printStackTrace(System.out); |
|
1203 |
response.setContentType("text/xml"); |
|
1204 |
out.println("<error>"+e.getMessage()+"</error>"); |
|
1205 |
} |
|
1189 |
// read the file from disk and sent it to PrintWriter |
|
1190 |
// PrintWriter out = new PrintWriter(streamOut); |
|
1191 |
di.readFromFileSystem(out, null, null, documentPath); |
|
1206 | 1192 |
|
1207 |
} |
|
1193 |
// response.setContentType("text/xml"); |
|
1194 |
// out.print(di.toString(null, null, true)); |
|
1208 | 1195 |
|
1196 |
MetacatReplication.replLog("document " + docid + " sent"); |
|
1197 |
|
|
1198 |
} catch (MalformedURLException mue) { |
|
1199 |
logMetacat.error("Url error when getting document from MetacatReplication." |
|
1200 |
+ "handlGetDocumentRequest for url: " + urlString + " : " |
|
1201 |
+ mue.getMessage()); |
|
1202 |
// e.printStackTrace(System.out); |
|
1203 |
response.setContentType("text/xml"); |
|
1204 |
out.println("<error>" + mue.getMessage() + "</error>"); |
|
1205 |
} catch (IOException ioe) { |
|
1206 |
logMetacat.error("I/O error when getting document from MetacatReplication." |
|
1207 |
+ "handlGetDocumentRequest for file: " + documentPath + " : " + ioe.getMessage()); |
|
1208 |
// e.printStackTrace(System.out); |
|
1209 |
response.setContentType("text/xml"); |
|
1210 |
out.println("<error>" + ioe.getMessage() + "</error>"); |
|
1211 |
} catch (PropertyNotFoundException pnfe) { |
|
1212 |
logMetacat.error("Error getting property when getting document from MetacatReplication." |
|
1213 |
+ "handlGetDocumentRequest for file: " + documentPath + " : " + pnfe.getMessage()); |
|
1214 |
// e.printStackTrace(System.out); |
|
1215 |
response.setContentType("text/xml"); |
|
1216 |
out.println("<error>" + pnfe.getMessage() + "</error>"); |
|
1217 |
} catch (McdbException me) { |
|
1218 |
logMetacat.error("Document implementation error getting property when getting document from MetacatReplication." |
|
1219 |
+ "handlGetDocumentRequest for file: " + documentPath + " : " + me.getMessage()); |
|
1220 |
// e.printStackTrace(System.out); |
|
1221 |
response.setContentType("text/xml"); |
|
1222 |
out.println("<error>" + me.getMessage() + "</error>"); |
|
1223 |
} |
|
1224 |
|
|
1225 |
} |
|
1226 |
|
|
1209 | 1227 |
/** |
1210 |
* Sends a list of all of the documents on this sever along with their |
|
1211 |
* revision numbers. |
|
1212 |
* The format is: |
|
1213 |
* <!ELEMENT replication (server, updates)> |
|
1214 |
* <!ELEMENT server (#PCDATA)> |
|
1215 |
* <!ELEMENT updates ((updatedDocument | deleteDocument | revisionDocument)*)> |
|
1216 |
* <!ELEMENT updatedDocument (docid, rev, datafile*)> |
|
1217 |
* <!ELEMENT deletedDocument (docid, rev)> |
|
1218 |
* <!ELEMENT revisionDocument (docid, rev, datafile*)> |
|
1219 |
* <!ELEMENT docid (#PCDATA)> |
|
1220 |
* <!ELEMENT rev (#PCDATA)> |
|
1221 |
* <!ELEMENT datafile (#PCDATA)> |
|
1222 |
* note that the rev in deletedDocument is always empty. I just left |
|
1223 |
* it in there to make the parser implementation easier. |
|
1224 |
*/ |
|
1228 |
* Sends a list of all of the documents on this sever along with their |
|
1229 |
* revision numbers. The format is: <!ELEMENT replication (server, updates)> |
|
1230 |
* <!ELEMENT server (#PCDATA)> <!ELEMENT updates ((updatedDocument | |
|
1231 |
* deleteDocument | revisionDocument)*)> <!ELEMENT updatedDocument (docid, |
|
1232 |
* rev, datafile*)> <!ELEMENT deletedDocument (docid, rev)> <!ELEMENT |
|
1233 |
* revisionDocument (docid, rev, datafile*)> <!ELEMENT docid (#PCDATA)> |
|
1234 |
* <!ELEMENT rev (#PCDATA)> <!ELEMENT datafile (#PCDATA)> note that the rev |
|
1235 |
* in deletedDocument is always empty. I just left it in there to make the |
|
1236 |
* parser implementation easier. |
|
1237 |
*/ |
|
1225 | 1238 |
private void handleUpdateRequest(PrintWriter out, Hashtable<String, String[]> params, |
1226 | 1239 |
HttpServletResponse response) |
1227 | 1240 |
{ |
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
89 | 89 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
90 | 90 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
91 | 91 |
import edu.ucsb.nceas.metacat.util.SessionData; |
92 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
92 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
93 | 93 |
import edu.ucsb.nceas.utilities.FileUtil; |
94 | 94 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
95 | 95 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
205 | 205 |
"Service problem while intializing MetaCat Servlet: " + se.getMessage(); |
206 | 206 |
logMetacat.error(errorMessage); |
207 | 207 |
throw new ServletException(errorMessage); |
208 |
} catch (UtilException ue) { |
|
208 |
} catch (MetacatUtilException ue) {
|
|
209 | 209 |
String errorMessage = |
210 | 210 |
"Utility problem while intializing MetaCat Servlet: " + ue.getMessage(); |
211 | 211 |
logMetacat.error(errorMessage); |
... | ... | |
368 | 368 |
try { |
369 | 369 |
pathsForIndexing = SystemUtil.getPathsForIndexing(); |
370 | 370 |
} |
371 |
catch (UtilException ue) { |
|
371 |
catch (MetacatUtilException ue) {
|
|
372 | 372 |
pathsForIndexing = null; |
373 | 373 |
logMetacat.error("Could not find index paths. Setting " |
374 | 374 |
+ "pathsForIndexing to null: " + ue.getMessage()); |
... | ... | |
878 | 878 |
String errorString = "Critical property not found: " + pnfe.getMessage(); |
879 | 879 |
logMetacat.error(errorString); |
880 | 880 |
throw new ServletException(errorString); |
881 |
} catch (UtilException ue) { |
|
881 |
} catch (MetacatUtilException ue) {
|
|
882 | 882 |
String errorString = "Utility error: " + ue.getMessage(); |
883 | 883 |
logMetacat.error(errorString); |
884 | 884 |
throw new ServletException(errorString); |
... | ... | |
2052 | 2052 |
logMetacat.error("User '" + user + "' not allowed to insert and update"); |
2053 | 2053 |
return; |
2054 | 2054 |
} |
2055 |
} catch (UtilException ue) { |
|
2055 |
} catch (MetacatUtilException ue) {
|
|
2056 | 2056 |
logMetacat.error("Could not determine if user could insert or update: " |
2057 | 2057 |
+ ue.getMessage()); |
2058 | 2058 |
} |
... | ... | |
2697 | 2697 |
} catch (IOException e) { |
2698 | 2698 |
logMetacat.error("Could not open http response for writing: " |
2699 | 2699 |
+ e.getMessage()); |
2700 |
} catch (UtilException ue) { |
|
2700 |
} catch (MetacatUtilException ue) {
|
|
2701 | 2701 |
logMetacat.error("Could not determine if user is administrator: " |
2702 | 2702 |
+ ue.getMessage()); |
2703 | 2703 |
} |
... | ... | |
2767 | 2767 |
logMetacat.error( |
2768 | 2768 |
"Could not open http response for writing: " |
2769 | 2769 |
+ e.getMessage()); |
2770 |
} catch (UtilException ue) { |
|
2770 |
} catch (MetacatUtilException ue) {
|
|
2771 | 2771 |
logMetacat.error("Could not determine if user is administrator: " |
2772 | 2772 |
+ ue.getMessage()); |
2773 | 2773 |
} |
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
61 | 61 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
62 | 62 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
63 | 63 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
64 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
64 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
65 | 65 |
import edu.ucsb.nceas.utilities.FileUtil; |
66 | 66 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
67 | 67 |
import edu.ucsb.nceas.utilities.StringUtil; |
... | ... | |
991 | 991 |
documentDir = PropertyService.getProperty("application.documentfilepath"); |
992 | 992 |
documentPath = documentDir + FileUtil.getFS() + docid + separator + rev; |
993 | 993 |
|
994 |
if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST) { |
|
994 |
if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST |
|
995 |
|| FileUtil.getFileSize(documentPath) == 0) { |
|
995 | 996 |
FileWriter fileWriter = new FileWriter(documentPath); |
996 | 997 |
toXmlFromDb(fileWriter, user, groups, true); |
997 | 998 |
} |
... | ... | |
1740 | 1741 |
leafNodeId, currentName, docid, leafParentId, leafData, |
1741 | 1742 |
leafDataNumerical)); |
1742 | 1743 |
} |
1743 |
} catch (UtilException ue) { |
|
1744 |
} catch (MetacatUtilException ue) {
|
|
1744 | 1745 |
logMetacat.warn("Could not get index paths: " + ue.getMessage()); |
1745 | 1746 |
} |
1746 | 1747 |
|
... | ... | |
1768 | 1769 |
pathsFoundForIndexing.put(path, new PathIndexEntry(leafNodeId, |
1769 | 1770 |
path, docid, leafParentId, leafData, leafDataNumerical)); |
1770 | 1771 |
} |
1771 |
} catch (UtilException ue) { |
|
1772 |
} catch (MetacatUtilException ue) {
|
|
1772 | 1773 |
logMetacat.warn("Could not get index paths: " + ue.getMessage()); |
1773 | 1774 |
} |
1774 | 1775 |
} |
... | ... | |
1789 | 1790 |
leafNodeId, fullPath, docid, leafParentId, leafData, |
1790 | 1791 |
leafDataNumerical)); |
1791 | 1792 |
} |
1792 |
} catch (UtilException ue) { |
|
1793 |
} catch (MetacatUtilException ue) {
|
|
1793 | 1794 |
logMetacat.warn("Could not get index paths: " + ue.getMessage()); |
1794 | 1795 |
} |
1795 | 1796 |
} |
src/edu/ucsb/nceas/metacat/service/PropertyService.java | ||
---|---|---|
38 | 38 |
import org.apache.log4j.Logger; |
39 | 39 |
|
40 | 40 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
41 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
41 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
42 | 42 |
import edu.ucsb.nceas.utilities.FileUtil; |
43 | 43 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
44 | 44 |
import edu.ucsb.nceas.utilities.MetaDataProperty; |
45 | 45 |
import edu.ucsb.nceas.utilities.PropertiesMetaData; |
46 | 46 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
47 | 47 |
import edu.ucsb.nceas.utilities.SortedProperties; |
48 |
import edu.ucsb.nceas.utilities.UtilException; |
|
48 | 49 |
|
49 | 50 |
/** |
50 | 51 |
* A suite of utility classes for the metadata configuration utility |
... | ... | |
442 | 443 |
* @return a boolean that is true if properties are not unconfigured and |
443 | 444 |
* false otherwise |
444 | 445 |
*/ |
445 |
public static boolean arePropertiesConfigured() throws UtilException { |
|
446 |
public static boolean arePropertiesConfigured() throws MetacatUtilException {
|
|
446 | 447 |
try { |
447 | 448 |
String propertiesConfigured = PropertyService.getProperty("configutil.propertiesConfigured"); |
448 | 449 |
if (propertiesConfigured != null && !propertiesConfigured.equals(UNCONFIGURED)) { |
... | ... | |
450 | 451 |
} |
451 | 452 |
return false; |
452 | 453 |
} catch (PropertyNotFoundException pnfe) { |
453 |
throw new UtilException("Could not determine if properties are configured: " |
|
454 |
throw new MetacatUtilException("Could not determine if properties are configured: "
|
|
454 | 455 |
+ pnfe.getMessage()); |
455 | 456 |
} |
456 | 457 |
} |
src/edu/ucsb/nceas/metacat/service/SkinPropertyService.java | ||
---|---|---|
40 | 40 |
import org.apache.log4j.Logger; |
41 | 41 |
|
42 | 42 |
import edu.ucsb.nceas.metacat.util.SkinUtil; |
43 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
43 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
44 | 44 |
import edu.ucsb.nceas.utilities.FileUtil; |
45 | 45 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
46 | 46 |
import edu.ucsb.nceas.utilities.MetaDataProperty; |
... | ... | |
424 | 424 |
* @return a boolean that is true if properties are not unconfigured and |
425 | 425 |
* false otherwise |
426 | 426 |
*/ |
427 |
public static boolean areSkinsConfigured() throws UtilException { |
|
427 |
public static boolean areSkinsConfigured() throws MetacatUtilException {
|
|
428 | 428 |
try { |
429 | 429 |
return !PropertyService.getProperty("configutil.skinsConfigured").equals( |
430 | 430 |
PropertyService.UNCONFIGURED); |
431 | 431 |
} catch (PropertyNotFoundException pnfe) { |
432 |
throw new UtilException("Could not determine if skins are configured: " |
|
432 |
throw new MetacatUtilException("Could not determine if skins are configured: "
|
|
433 | 433 |
+ pnfe.getMessage()); |
434 | 434 |
} |
435 | 435 |
} |
src/edu/ucsb/nceas/metacat/util/AuthUtil.java | ||
---|---|---|
57 | 57 |
* |
58 | 58 |
* @return a Vector of Strings holding the administrators |
59 | 59 |
*/ |
60 |
public static Vector<String> getAdministrators() throws UtilException { |
|
60 |
public static Vector<String> getAdministrators() throws MetacatUtilException {
|
|
61 | 61 |
if (administrators == null) { |
62 | 62 |
populateAdministrators(); |
63 | 63 |
} |
... | ... | |
69 | 69 |
* |
70 | 70 |
* @return a Vector of Strings holding the submitters |
71 | 71 |
*/ |
72 |
public static Vector<String> getAllowedSubmitters() throws UtilException { |
|
72 |
public static Vector<String> getAllowedSubmitters() throws MetacatUtilException {
|
|
73 | 73 |
if (allowedSubmitters == null) { |
74 | 74 |
populateAllowedSubmitters(); |
75 | 75 |
} |
... | ... | |
81 | 81 |
* |
82 | 82 |
* @return a Vector of Strings holding the denied submitters |
83 | 83 |
*/ |
84 |
public static Vector<String> getDeniedSubmitters() throws UtilException { |
|
84 |
public static Vector<String> getDeniedSubmitters() throws MetacatUtilException {
|
|
85 | 85 |
if (deniedSubmitters == null) { |
86 | 86 |
populateDeniedSubmitters(); |
87 | 87 |
} |
... | ... | |
93 | 93 |
* |
94 | 94 |
* @return a Vector of Strings holding the moderators |
95 | 95 |
*/ |
96 |
public static Vector<String> getModerators() throws UtilException { |
|
96 |
public static Vector<String> getModerators() throws MetacatUtilException {
|
|
97 | 97 |
if (moderators == null) { |
98 | 98 |
populateModerators(); |
99 | 99 |
} |
... | ... | |
104 | 104 |
* Get the vector of administrator credentials from metacat.properties |
105 | 105 |
* and put into global administrators list |
106 | 106 |
*/ |
107 |
private static void populateAdministrators() throws UtilException { |
|
107 |
private static void populateAdministrators() throws MetacatUtilException {
|
|
108 | 108 |
String administratorString = null; |
109 | 109 |
try { |
110 | 110 |
administratorString = |
111 | 111 |
PropertyService.getProperty("auth.administrators"); |
112 | 112 |
} catch (PropertyNotFoundException pnfe) { |
113 |
throw new UtilException("Could not get metacat property: auth.administrators. " |
|
113 |
throw new MetacatUtilException("Could not get metacat property: auth.administrators. "
|
|
114 | 114 |
+ "There will be no registered metacat adminstrators: " |
115 | 115 |
+ pnfe.getMessage()); |
116 | 116 |
} |
... | ... | |
121 | 121 |
* Get the vector of allowed submitter credentials from metacat.properties |
122 | 122 |
* and put into global allowedSubmitters list |
123 | 123 |
*/ |
124 |
private static void populateAllowedSubmitters() throws UtilException { |
|
124 |
private static void populateAllowedSubmitters() throws MetacatUtilException {
|
|
125 | 125 |
String allowedSubmitterString = null; |
126 | 126 |
try { |
127 | 127 |
allowedSubmitterString = PropertyService.getProperty("auth.allowedSubmitters"); |
128 | 128 |
} catch (PropertyNotFoundException pnfe) { |
129 |
throw new UtilException("Could not get metacat property: auth.allowedSubmitters. " |
|
129 |
throw new MetacatUtilException("Could not get metacat property: auth.allowedSubmitters. "
|
|
130 | 130 |
+ "Anyone will be allowed to submit: " |
131 | 131 |
+ pnfe.getMessage()); |
132 | 132 |
} |
... | ... | |
137 | 137 |
* Get the vector of denied submitter credentials from metacat.properties |
138 | 138 |
* and put into global deniedSubmitters list |
139 | 139 |
*/ |
140 |
private static void populateDeniedSubmitters() throws UtilException { |
|
140 |
private static void populateDeniedSubmitters() throws MetacatUtilException {
|
|
141 | 141 |
String deniedSubmitterString = null; |
142 | 142 |
try { |
143 | 143 |
deniedSubmitterString = PropertyService.getProperty("auth.deniedSubmitters"); |
144 | 144 |
} catch (PropertyNotFoundException pnfe) { |
145 |
throw new UtilException("Could not get metacat property: auth.deniedSubmitters: " |
|
145 |
throw new MetacatUtilException("Could not get metacat property: auth.deniedSubmitters: "
|
|
146 | 146 |
+ pnfe.getMessage()); |
147 | 147 |
} |
148 | 148 |
deniedSubmitters = StringUtil.toVector(deniedSubmitterString, ':'); |
... | ... | |
152 | 152 |
* Get the vector of moderator credentials from metacat.properties |
153 | 153 |
* and put into global administrators list |
154 | 154 |
*/ |
155 |
private static void populateModerators() throws UtilException { |
|
155 |
private static void populateModerators() throws MetacatUtilException {
|
|
156 | 156 |
String moderatorString = null; |
157 | 157 |
try { |
158 | 158 |
moderatorString = |
159 | 159 |
PropertyService.getProperty("auth.moderators"); |
160 | 160 |
} catch (PropertyNotFoundException pnfe) { |
161 |
throw new UtilException("Could not get metacat property: auth.moderators. " |
|
161 |
throw new MetacatUtilException("Could not get metacat property: auth.moderators. "
|
|
162 | 162 |
+ "There will be no registered metacat moderators: " |
163 | 163 |
+ pnfe.getMessage()); |
164 | 164 |
} |
... | ... | |
171 | 171 |
* |
172 | 172 |
* @param request the http request. |
173 | 173 |
*/ |
174 |
public static boolean logUserIn(HttpServletRequest request, String userName, String password) throws UtilException { |
|
174 |
public static boolean logUserIn(HttpServletRequest request, String userName, String password) throws MetacatUtilException {
|
|
175 | 175 |
AuthSession authSession = null; |
176 | 176 |
|
177 | 177 |
// make sure we have username and password. |
178 | 178 |
if (userName == null || password == null) { |
179 |
throw new UtilException("null username or password when logging user in"); |
|
179 |
throw new MetacatUtilException("null username or password when logging user in");
|
|
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
// Create auth session |
183 | 183 |
try { |
184 | 184 |
authSession = new AuthSession(); |
185 | 185 |
} catch (Exception e) { |
186 |
throw new UtilException("Could not instantiate AuthSession: " |
|
186 |
throw new MetacatUtilException("Could not instantiate AuthSession: "
|
|
187 | 187 |
+ e.getMessage()); |
188 | 188 |
} |
189 | 189 |
// authenticate user against ldap |
190 | 190 |
if(!authSession.authenticate(request, userName,password)) { |
191 |
throw new UtilException(authSession.getMessage()); |
|
191 |
throw new MetacatUtilException(authSession.getMessage());
|
|
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
// if login was successful, add the session information to the |
... | ... | |
202 | 202 |
(String[]) session.getAttribute("groupnames"), |
203 | 203 |
(String) session.getAttribute("password")); |
204 | 204 |
} catch (ServiceException se) { |
205 |
throw new UtilException("Problem registering session: " + se.getMessage()); |
|
205 |
throw new MetacatUtilException("Problem registering session: " + se.getMessage());
|
|
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
return true; |
... | ... | |
215 | 215 |
* @param request the http request that holds the login session |
216 | 216 |
* @return boolean that is true if the user is logged in, false otherwise |
217 | 217 |
*/ |
218 |
public static boolean isUserLoggedIn(HttpServletRequest request) throws UtilException{ |
|
218 |
public static boolean isUserLoggedIn(HttpServletRequest request) throws MetacatUtilException{
|
|
219 | 219 |
SessionData sessionData = null; |
220 | 220 |
String sessionId = request.getSession().getId(); |
221 | 221 |
|
... | ... | |
246 | 246 |
} |
247 | 247 |
|
248 | 248 |
} catch (PropertyNotFoundException pnfe) { |
249 |
throw new UtilException("Could not determine if user is logged in because " |
|
249 |
throw new MetacatUtilException("Could not determine if user is logged in because "
|
|
250 | 250 |
+ "of property error: " + pnfe.getMessage()); |
251 | 251 |
} catch (NumberFormatException nfe) { |
252 |
throw new UtilException("Could not determine if user is logged in because " |
|
252 |
throw new MetacatUtilException("Could not determine if user is logged in because "
|
|
253 | 253 |
+ "of number conversion error: " + nfe.getMessage()); |
254 | 254 |
} |
255 | 255 |
|
... | ... | |
266 | 266 |
* @return boolean that is true if the user is logged in as admin, false |
267 | 267 |
* otherwise |
268 | 268 |
*/ |
269 |
public static boolean isUserLoggedInAsAdmin(HttpServletRequest request) throws UtilException { |
|
269 |
public static boolean isUserLoggedInAsAdmin(HttpServletRequest request) throws MetacatUtilException {
|
|
270 | 270 |
if (!isUserLoggedIn(request)) { |
271 | 271 |
return false; |
272 | 272 |
} |
... | ... | |
319 | 319 |
* @return String holding the ldap login string |
320 | 320 |
*/ |
321 | 321 |
public static String createLDAPString(String username, String organization, |
322 |
Vector<String> dnList) throws UtilException { |
|
322 |
Vector<String> dnList) throws MetacatUtilException {
|
|
323 | 323 |
|
324 | 324 |
if (username == null || organization == null || dnList == null || dnList.size() == 0) { |
325 |
throw new UtilException("Could not generate LDAP user string. One of the following is null: username, organization or dnlist"); |
|
325 |
throw new MetacatUtilException("Could not generate LDAP user string. One of the following is null: username, organization or dnlist");
|
|
326 | 326 |
} |
327 | 327 |
|
328 | 328 |
String ldapString = "uid=" + username + ",o=" + organization; |
... | ... | |
340 | 340 |
* @return a boolean that is true if all sections are configured and false |
341 | 341 |
* otherwise |
342 | 342 |
*/ |
343 |
public static boolean isAuthConfigured() throws UtilException { |
|
343 |
public static boolean isAuthConfigured() throws MetacatUtilException {
|
|
344 | 344 |
String authConfiguredString = PropertyService.UNCONFIGURED; |
345 | 345 |
try { |
346 | 346 |
authConfiguredString = PropertyService.getProperty("configutil.authConfigured"); |
347 | 347 |
} catch (PropertyNotFoundException pnfe) { |
348 |
throw new UtilException("Could not determine if LDAP is configured: " |
|
348 |
throw new MetacatUtilException("Could not determine if LDAP is configured: "
|
|
349 | 349 |
+ pnfe.getMessage()); |
350 | 350 |
} |
351 | 351 |
return !authConfiguredString.equals(PropertyService.UNCONFIGURED); |
... | ... | |
360 | 360 |
* a list of the user's groups |
361 | 361 |
*/ |
362 | 362 |
public static boolean isAdministrator(String username, String[] groups) |
363 |
throws UtilException { |
|
363 |
throws MetacatUtilException {
|
|
364 | 364 |
return onAccessList(getAdministrators(), username, groups); |
365 | 365 |
} |
366 | 366 |
|
... | ... | |
372 | 372 |
* @param groups |
373 | 373 |
* a list of the user's groups |
374 | 374 |
*/ |
375 |
public static boolean isModerator(String username, String[] groups) throws UtilException{ |
|
375 |
public static boolean isModerator(String username, String[] groups) throws MetacatUtilException{
|
|
376 | 376 |
return onAccessList(getModerators(), username, groups); |
377 | 377 |
} |
378 | 378 |
|
... | ... | |
385 | 385 |
* a list of the user's groups |
386 | 386 |
*/ |
387 | 387 |
public static boolean isAllowedSubmitter(String username, String[] groups) |
388 |
throws UtilException { |
|
388 |
throws MetacatUtilException {
|
|
389 | 389 |
if (getAllowedSubmitters().size() == 0) { |
390 | 390 |
// no allowedSubmitters list specified - |
391 | 391 |
// hence everyone should be allowed |
... | ... | |
403 | 403 |
* a list of the user's groups |
404 | 404 |
*/ |
405 | 405 |
public static boolean isDeniedSubmitter(String username, String[] groups) |
406 |
throws UtilException { |
|
406 |
throws MetacatUtilException {
|
|
407 | 407 |
return (onAccessList(getDeniedSubmitters(), username, groups)); |
408 | 408 |
} |
409 | 409 |
|
... | ... | |
416 | 416 |
* a list of the user's groups |
417 | 417 |
*/ |
418 | 418 |
public static boolean canInsertOrUpdate(String username, String[] groups) |
419 |
throws UtilException { |
|
419 |
throws MetacatUtilException {
|
|
420 | 420 |
return (isAllowedSubmitter(username, groups) && !isDeniedSubmitter(username, |
421 | 421 |
groups)); |
422 | 422 |
} |
src/edu/ucsb/nceas/metacat/util/GeoserverUtil.java | ||
---|---|---|
56 | 56 |
* the HttpClient we will use to post. This is passed in since it |
57 | 57 |
* may need to be used after login by other methods. |
58 | 58 |
*/ |
59 |
public static void loginAdmin(HttpClient httpClient) throws UtilException { |
|
59 |
public static void loginAdmin(HttpClient httpClient) throws MetacatUtilException {
|
|
60 | 60 |
try { |
61 | 61 |
String username = |
62 | 62 |
PropertyService.getProperty("geoserver.username"); |
... | ... | |
96 | 96 |
// check to see if the success string is part of the result |
97 | 97 |
if(postResult.indexOf(loginSuccessString) == -1) { |
98 | 98 |
logMetacat.debug(postResult); |
99 |
throw new UtilException("Could not log in to geoserver."); |
|
99 |
throw new MetacatUtilException("Could not log in to geoserver.");
|
|
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
} catch (PropertyNotFoundException pnfe) { |
103 |
throw new UtilException("Property error while logging in with " |
|
103 |
throw new MetacatUtilException("Property error while logging in with "
|
|
104 | 104 |
+ "default account: " + pnfe.getMessage()); |
105 | 105 |
} catch (IOException ioe) { |
106 |
throw new UtilException("I/O error while logging in with " |
|
106 |
throw new MetacatUtilException("I/O error while logging in with "
|
|
107 | 107 |
+ "default account: " + ioe.getMessage()); |
108 | 108 |
} |
109 | 109 |
} |
... | ... | |
122 | 122 |
* the new password |
123 | 123 |
*/ |
124 | 124 |
public static void changePassword(HttpClient httpClient, String username, String password) |
125 |
throws UtilException { |
|
125 |
throws MetacatUtilException {
|
|
126 | 126 |
try { |
127 | 127 |
|
128 | 128 |
HashMap<String, String> paramMap = new HashMap<String, String>(); |
... | ... | |
146 | 146 |
// check to see if the success string is part of the result |
147 | 147 |
if(postResult.indexOf(passwordSuccessString) == -1) { |
148 | 148 |
logMetacat.debug(postResult); |
149 |
throw new UtilException("Could not change geoserver password."); |
|
149 |
throw new MetacatUtilException("Could not change geoserver password.");
|
|
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
// send a post to apply the password changes. Unfortunately, there really |
... | ... | |
159 | 159 |
RequestUtil.post(httpClient, applyPostURL, null); |
160 | 160 |
|
161 | 161 |
} catch (PropertyNotFoundException pnfe) { |
162 |
throw new UtilException("Property error while logging in with " |
|
162 |
throw new MetacatUtilException("Property error while logging in with "
|
|
163 | 163 |
+ "default account: " + pnfe.getMessage()); |
164 | 164 |
} catch (IOException ioe) { |
165 |
throw new UtilException("I/O error while logging in with " |
|
165 |
throw new MetacatUtilException("I/O error while logging in with "
|
|
166 | 166 |
+ "default account: " + ioe.getMessage()); |
167 | 167 |
} |
168 | 168 |
} |
... | ... | |
172 | 172 |
* |
173 | 173 |
* @return a boolean that is true if geoserver is configured or bypassed |
174 | 174 |
*/ |
175 |
public static boolean isGeoserverConfigured() throws UtilException { |
|
175 |
public static boolean isGeoserverConfigured() throws MetacatUtilException {
|
|
176 | 176 |
String geoserverConfiguredString = PropertyService.UNCONFIGURED; |
177 | 177 |
try { |
178 | 178 |
geoserverConfiguredString = PropertyService.getProperty("configutil.geoserverConfigured"); |
179 | 179 |
} catch (PropertyNotFoundException pnfe) { |
180 |
throw new UtilException("Could not determine if geoservice are configured: " |
|
180 |
throw new MetacatUtilException("Could not determine if geoservice are configured: "
|
|
181 | 181 |
+ pnfe.getMessage()); |
182 | 182 |
} |
183 | 183 |
// geoserver is configured if not unconfigured |
src/edu/ucsb/nceas/metacat/util/DatabaseUtil.java | ||
---|---|---|
52 | 52 |
* @return a boolean that is true if database is not unconfigured and false |
53 | 53 |
* otherwise |
54 | 54 |
*/ |
55 |
public static boolean isDatabaseConfigured() throws UtilException { |
|
55 |
public static boolean isDatabaseConfigured() throws MetacatUtilException {
|
|
56 | 56 |
String databaseConfiguredString = PropertyService.UNCONFIGURED; |
57 | 57 |
try { |
58 | 58 |
databaseConfiguredString = |
59 | 59 |
PropertyService.getProperty("configutil.databaseConfigured"); |
60 | 60 |
} catch (PropertyNotFoundException pnfe) { |
61 |
throw new UtilException("Could not determine if database is configured: " |
|
61 |
throw new MetacatUtilException("Could not determine if database is configured: "
|
|
62 | 62 |
+ pnfe.getMessage()); |
63 | 63 |
} |
64 | 64 |
return !databaseConfiguredString.equals(PropertyService.UNCONFIGURED); |
src/edu/ucsb/nceas/metacat/util/OrganizationUtil.java | ||
---|---|---|
48 | 48 |
* |
49 | 49 |
* TODO MCD this should be retrieved from ldap instead of metacat.properties |
50 | 50 |
*/ |
51 |
public static Vector<String> getOrganizations() throws UtilException { |
|
51 |
public static Vector<String> getOrganizations() throws MetacatUtilException {
|
|
52 | 52 |
|
53 | 53 |
Vector<String> shortOrgNames = new Vector<String>(); |
54 | 54 |
Vector<String> longOrgNames = null; |
... | ... | |
67 | 67 |
* |
68 | 68 |
* @return a Vector of Strings that hold all available organizations |
69 | 69 |
*/ |
70 |
public static Vector<String> getOrgDNs(String orgName) throws UtilException { |
|
70 |
public static Vector<String> getOrgDNs(String orgName) throws MetacatUtilException {
|
|
71 | 71 |
|
72 | 72 |
String orgBaseList = null; |
73 | 73 |
try { |
74 | 74 |
orgBaseList = PropertyService.getProperty("organization.base." + orgName); |
75 | 75 |
} catch (PropertyNotFoundException pnfe) { |
76 |
throw new UtilException("Could not get metacat property: organization.base." |
|
76 |
throw new MetacatUtilException("Could not get metacat property: organization.base."
|
|
77 | 77 |
+ orgName + " : " + pnfe.getMessage()); |
78 | 78 |
} |
79 | 79 |
// this will always return a vector (maybe an empty one) |
... | ... | |
87 | 87 |
* @return a boolean that is true if all sections are configured and false |
88 | 88 |
* otherwise |
89 | 89 |
*/ |
90 |
public static boolean areOrganizationsConfigured() throws UtilException { |
|
90 |
public static boolean areOrganizationsConfigured() throws MetacatUtilException {
|
|
91 | 91 |
String orgConfiguredString = PropertyService.UNCONFIGURED; |
92 | 92 |
try { |
93 | 93 |
orgConfiguredString = PropertyService.getProperty("configutil.organizationsConfigured"); |
94 | 94 |
} catch (PropertyNotFoundException pnfe) { |
95 |
throw new UtilException("Could not determine if organizations are configured: " |
|
95 |
throw new MetacatUtilException("Could not determine if organizations are configured: "
|
|
96 | 96 |
+ pnfe.getMessage()); |
97 | 97 |
} |
98 | 98 |
return !orgConfiguredString.equals(PropertyService.UNCONFIGURED); |
src/edu/ucsb/nceas/metacat/util/SkinUtil.java | ||
---|---|---|
51 | 51 |
* @return a boolean that is true if skins are not unconfigured and false |
52 | 52 |
* otherwise |
53 | 53 |
*/ |
54 |
public static boolean areSkinsConfigured() throws UtilException { |
|
54 |
public static boolean areSkinsConfigured() throws MetacatUtilException {
|
|
55 | 55 |
try { |
56 | 56 |
return !PropertyService.getProperty("configutil.skinsConfigured").equals( |
57 | 57 |
PropertyService.UNCONFIGURED); |
58 | 58 |
} catch (PropertyNotFoundException pnfe) { |
59 |
throw new UtilException("Could not determine if database is configured: " |
|
59 |
throw new MetacatUtilException("Could not determine if database is configured: "
|
|
60 | 60 |
+ pnfe.getMessage()); |
61 | 61 |
} |
62 | 62 |
} |
src/edu/ucsb/nceas/metacat/util/SystemUtil.java | ||
---|---|---|
42 | 42 |
import edu.ucsb.nceas.utilities.FileUtil; |
43 | 43 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
44 | 44 |
import edu.ucsb.nceas.utilities.StringUtil; |
45 |
import edu.ucsb.nceas.utilities.UtilException; |
|
45 | 46 |
|
46 | 47 |
public class SystemUtil { |
47 | 48 |
|
... | ... | |
333 | 334 |
return storedBackupDirLoc; |
334 | 335 |
} |
335 | 336 |
} |
336 |
} catch (IOException ioe) {
|
|
337 |
logMetacat.warn("I/O problem finding backup location: " + ioe.getMessage());
|
|
337 |
} catch (UtilException ue) {
|
|
338 |
logMetacat.warn("Utility problem finding backup location: " + ue.getMessage());
|
|
338 | 339 |
} catch (ServiceException se) { |
339 | 340 |
logMetacat.warn("Could not get real application context: " + se.getMessage()); |
340 | 341 |
} |
... | ... | |
361 | 362 |
|
362 | 363 |
FileUtil.writeFile(storedBackupFileLoc, backupPath); |
363 | 364 |
|
365 |
} catch (UtilException ue) { |
|
366 |
logMetacat.warn("Utility error writing backup file: " + ue.getMessage()); |
|
364 | 367 |
} catch (IOException ioe) { |
365 |
logMetacat.warn("I/O proplem finding backup location: " + ioe.getMessage());
|
|
368 |
logMetacat.warn("I/O error finding backup location: " + ioe.getMessage());
|
|
366 | 369 |
} catch (ServiceException se) { |
367 |
logMetacat.warn("Could not get real application context: " + se.getMessage());
|
|
368 |
} |
|
370 |
logMetacat.warn("Service error getting real application context: " + se.getMessage());
|
|
371 |
}
|
|
369 | 372 |
} |
370 | 373 |
|
371 | 374 |
/** |
... | ... | |
500 | 503 |
} catch (ServiceException se) { |
501 | 504 |
logMetacat.error("Could not get real application directory while trying to write " |
502 | 505 |
+ "stored backup directory: "+ storedBackupLocFile + " : " + se.getMessage()); |
506 |
} catch (UtilException ue) { |
|
507 |
logMetacat.error("Could not write backup location file into " |
|
508 |
+ "stored backup directory: "+ storedBackupLocFile + " : " + ue.getMessage()); |
|
503 | 509 |
} |
504 | 510 |
} else { |
505 | 511 |
logMetacat.warn("Could not write out stored backup directory." |
... | ... | |
579 | 585 |
/** |
580 | 586 |
* Get a list of xml paths that need to be indexed |
581 | 587 |
*/ |
582 |
public static Vector<String> getPathsForIndexing() throws UtilException { |
|
588 |
public static Vector<String> getPathsForIndexing() throws MetacatUtilException {
|
|
583 | 589 |
Vector <String> indexPaths = null; |
584 | 590 |
try { |
585 | 591 |
indexPaths = |
586 | 592 |
StringUtil.toVector(PropertyService.getProperty("xml.indexPaths"), ','); |
587 | 593 |
} catch (PropertyNotFoundException pnfe) { |
588 |
throw new UtilException("could not get index paths: " + pnfe.getMessage()); |
|
594 |
throw new MetacatUtilException("could not get index paths: " + pnfe.getMessage());
|
|
589 | 595 |
} |
590 | 596 |
|
591 | 597 |
return indexPaths; |
src/edu/ucsb/nceas/metacat/util/MetacatUtilException.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Purpose: An Exception thrown when an error occurs because an |
|
4 |
* AccessionNumber was invalid or used incorrectly |
|
5 |
* Copyright: 2008 Regents of the University of California and the |
|
6 |
* National Center for Ecological Analysis and Synthesis |
|
7 |
* Authors: Michael Daigle |
|
8 |
* |
|
9 |
* '$Author$' |
|
10 |
* '$Date$' |
|
11 |
* '$Revision$' |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or modify |
|
14 |
* it under the terms of the GNU General Public License as published by |
|
15 |
* the Free Software Foundation; either version 2 of the License, or |
|
16 |
* (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
*/ |
|
27 |
|
|
28 |
package edu.ucsb.nceas.metacat.util; |
|
29 |
/** |
|
30 |
* Exception thrown when an error occurs in a utility method |
|
31 |
*/ |
|
32 |
public class MetacatUtilException extends Exception { |
|
33 |
|
|
34 |
private static final long serialVersionUID = -253071242028406390L; |
|
35 |
|
|
36 |
/** |
|
37 |
* Create a new AdminException. |
|
38 |
* |
|
39 |
* @param message The error or warning message. |
|
40 |
*/ |
|
41 |
public MetacatUtilException(String message) { |
|
42 |
super(message); |
|
43 |
} |
|
44 |
} |
|
0 | 45 |
src/edu/ucsb/nceas/metacat/util/MetacatUtil.java | ||
---|---|---|
50 | 50 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
51 | 51 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
52 | 52 |
import edu.ucsb.nceas.utilities.FileUtil; |
53 |
import edu.ucsb.nceas.utilities.UtilException; |
|
53 | 54 |
|
54 | 55 |
/** |
55 | 56 |
* A suite of utility classes for the metadata catalog server |
... | ... | |
923 | 924 |
&& DatabaseUtil.isDatabaseConfigured() |
924 | 925 |
&& GeoserverUtil.isGeoserverConfigured() |
925 | 926 |
&& isBackupDirConfigured(); |
926 |
} catch (UtilException ue) { |
|
927 |
} catch (MetacatUtilException ue) {
|
|
927 | 928 |
logMetacat.error("Could not determine if metacat is configured due to utility exception: " |
928 | 929 |
+ ue.getMessage()); |
929 | 930 |
} catch (PropertyNotFoundException pnfe) { |
... | ... | |
941 | 942 |
* @return false if the application.backupDir property does not point to a |
942 | 943 |
* writable directory. |
943 | 944 |
*/ |
944 |
public static boolean isBackupDirConfigured() throws UtilException, PropertyNotFoundException { |
|
945 |
public static boolean isBackupDirConfigured() throws MetacatUtilException, PropertyNotFoundException {
|
|
945 | 946 |
String backupDir = PropertyService.getProperty("application.backupDir"); |
946 | 947 |
if (backupDir == null || backupDir.equals("")) { |
947 | 948 |
return false; |
... | ... | |
963 | 964 |
* @return a boolean that is false if dev.runConfiguration is false and the |
964 | 965 |
* backup properties file exists. |
965 | 966 |
*/ |
966 |
public static boolean bypassConfiguration() throws UtilException, ServiceException { |
|
967 |
public static boolean bypassConfiguration() throws MetacatUtilException, ServiceException {
|
|
967 | 968 |
try { |
968 | 969 |
// If the system is not configured to do bypass, return false. |
969 | 970 |
if (!PropertyService.doBypass()) { |
... | ... | |
995 | 996 |
|
996 | 997 |
return true; |
997 | 998 |
} catch (GeneralPropertyException gpe) { |
998 |
throw new UtilException("Property error while discovering backup directory: " |
|
999 |
throw new MetacatUtilException("Property error while discovering backup directory: "
|
|
999 | 1000 |
+ gpe.getMessage()); |
1001 |
} catch (UtilException ue) { |
|
1002 |
throw new MetacatUtilException("Utility error while discovering backup directory: " |
|
1003 |
+ ue.getMessage()); |
|
1000 | 1004 |
} |
1001 | 1005 |
|
1002 | 1006 |
} |
src/edu/ucsb/nceas/metacat/AuthSession.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
39 | 39 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
40 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
40 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
41 | 41 |
|
42 | 42 |
/** |
43 | 43 |
* A Class that implements session tracking for MetaCatServlet users. |
... | ... | |
228 | 228 |
if (AuthUtil.isAdministrator(username, groups)) { |
229 | 229 |
out.append("\n <isAdministrator></isAdministrator>\n"); |
230 | 230 |
} |
231 |
} catch (UtilException ue) { |
|
231 |
} catch (MetacatUtilException ue) {
|
|
232 | 232 |
logMetacat.error("Could not determine if user is administrator. " |
233 | 233 |
+ "Omitting from xml output: " + ue.getMessage()); |
234 | 234 |
} |
... | ... | |
238 | 238 |
if (AuthUtil.isModerator(username, groups)) { |
239 | 239 |
out.append("\n <isModerator></isModerator>\n"); |
240 | 240 |
} |
241 |
} catch (UtilException ue) { |
|
241 |
} catch (MetacatUtilException ue) {
|
|
242 | 242 |
logMetacat.error("Could not determine if user is moderator. " |
243 | 243 |
+ "Omitting from xml output: " + ue.getMessage()); |
244 | 244 |
} |
src/edu/ucsb/nceas/metacat/QueryGroup.java | ||
---|---|---|
32 | 32 |
import edu.ucsb.nceas.dbadapter.*; |
33 | 33 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
34 | 34 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
35 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
35 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
36 | 36 |
|
37 | 37 |
import java.io.*; |
38 | 38 |
import java.util.Hashtable; |
... | ... | |
373 | 373 |
queryTermsInPathIndex.add(newTerm); |
374 | 374 |
return; |
375 | 375 |
} |
376 |
} catch (UtilException ue) { |
|
376 |
} catch (MetacatUtilException ue) {
|
|
377 | 377 |
logMetacat.warn("Could not get index paths: " + ue.getMessage()); |
378 | 378 |
} |
379 | 379 |
|
src/edu/ucsb/nceas/metacat/QueryTerm.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
36 | 36 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
37 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
37 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
38 | 38 |
|
39 | 39 |
/** a utility class that represents a single term in a query */ |
40 | 40 |
public class QueryTerm |
... | ... | |
230 | 230 |
if (SystemUtil.getPathsForIndexing().contains(pathexpr)) { |
231 | 231 |
usePathIndex = true; |
232 | 232 |
} |
233 |
} catch (UtilException ue) { |
|
233 |
} catch (MetacatUtilException ue) {
|
|
234 | 234 |
log.warn("Could not get index paths: " + ue.getMessage()); |
235 | 235 |
} |
236 | 236 |
} |
src/edu/ucsb/nceas/metacat/admin/LoginAdmin.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
39 | 39 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
40 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
40 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
41 | 41 |
|
42 | 42 |
/** |
43 | 43 |
* Control the display of the login page |
... | ... | |
116 | 116 |
if (validationErrors.size() == 0) { |
117 | 117 |
try { |
118 | 118 |
isLoggedIn = AuthUtil.logUserIn(request, userName, password); |
119 |
} catch (UtilException ue) { |
|
119 |
} catch (MetacatUtilException ue) {
|
|
120 | 120 |
String errorMessage = "Could not log in as: " + userName |
121 | 121 |
+ " : " + ue.getMessage() + ". Please try again"; |
122 | 122 |
processingErrors.add(errorMessage); |
src/edu/ucsb/nceas/metacat/admin/GeoserverAdmin.java | ||
---|---|---|
39 | 39 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
40 | 40 |
import edu.ucsb.nceas.metacat.util.GeoserverUtil; |
41 | 41 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
42 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
42 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
43 | 43 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
44 | 44 |
|
45 | 45 |
/** |
... | ... | |
191 | 191 |
PropertyService.persistMainBackupProperties(request.getSession() |
192 | 192 |
.getServletContext()); |
193 | 193 |
} |
194 |
} catch (UtilException ue) { |
|
194 |
} catch (MetacatUtilException ue) {
|
|
195 | 195 |
String errorMessage = "Error updating geoserver password: " + ue.getMessage(); |
196 | 196 |
logMetacat.error(errorMessage); |
197 | 197 |
processingErrors.add(errorMessage); |
src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java | ||
---|---|---|
46 | 46 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
47 | 47 |
import edu.ucsb.nceas.metacat.util.SkinUtil; |
48 | 48 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
49 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
49 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
50 | 50 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
51 | 51 |
|
52 | 52 |
/** |
... | ... | |
193 | 193 |
"Admin problem while handling request: " + ae.getMessage(); |
194 | 194 |
logMetacat.error(errorMessage); |
195 | 195 |
processingErrors.add(errorMessage); |
196 |
} catch (UtilException ue) { |
|
196 |
} catch (MetacatUtilException ue) {
|
|
197 | 197 |
String errorMessage = |
198 | 198 |
"Utility problem while handling request: " + ue.getMessage(); |
199 | 199 |
logMetacat.error(errorMessage); |
src/edu/ucsb/nceas/metacat/admin/BackupAdmin.java | ||
---|---|---|
40 | 40 |
import edu.ucsb.nceas.metacat.service.ServiceService; |
41 | 41 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
42 | 42 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
43 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
44 | 43 |
import edu.ucsb.nceas.utilities.FileUtil; |
45 | 44 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
45 |
import edu.ucsb.nceas.utilities.UtilException; |
|
46 | 46 |
|
47 | 47 |
/** |
48 | 48 |
* Control the display of the login page |
src/edu/ucsb/nceas/metacat/admin/DBAdmin.java | ||
---|---|---|
58 | 58 |
import edu.ucsb.nceas.metacat.util.DatabaseUtil; |
59 | 59 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
60 | 60 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
61 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
61 |
import edu.ucsb.nceas.metacat.util.MetacatUtilException;
|
|
62 | 62 |
|
63 | 63 |
import edu.ucsb.nceas.utilities.DBUtil; |
64 | 64 |
import edu.ucsb.nceas.utilities.FileUtil; |
... | ... | |
276 | 276 |
throw new AdminException("An attempt was made to get the database version " |
277 | 277 |
+ "before system properties were configured"); |
278 | 278 |
} |
279 |
} catch (UtilException ue) { |
|
279 |
} catch (MetacatUtilException ue) {
|
|
280 | 280 |
throw new AdminException("Could not determine the database version: " |
281 | 281 |
+ ue.getMessage()); |
282 | 282 |
} |
Also available in: Unified diff
Beef up exception handling from file utilities. Move UtilException to MetacatUtilException to eliminate conflict with similar exception in utility package.