r4502 - trunk/src/edu/ucsb/nceas/metacat
daigle at ecoinformatics.org
daigle at ecoinformatics.org
Mon Nov 3 11:05:38 PST 2008
Author: daigle
Date: 2008-11-03 11:05:38 -0800 (Mon, 03 Nov 2008)
New Revision: 4502
Modified:
trunk/src/edu/ucsb/nceas/metacat/MetaCatServlet.java
Log:
Remove the code to read and write metadata to disk. It is getting put into DocumentImpl
Modified: trunk/src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- trunk/src/edu/ucsb/nceas/metacat/MetaCatServlet.java 2008-11-03 19:01:52 UTC (rev 4501)
+++ trunk/src/edu/ucsb/nceas/metacat/MetaCatServlet.java 2008-11-03 19:05:38 UTC (rev 4502)
@@ -30,7 +30,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
@@ -65,7 +64,7 @@
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
-//import org.ecoinformatics.eml.EMLParser;
+import org.ecoinformatics.eml.EMLParser;
import au.com.bytecode.opencsv.CSVWriter;
@@ -1717,7 +1716,6 @@
ZipOutputStream zout, boolean withInlineData, Hashtable<String, String[]> params)
throws ClassNotFoundException, IOException, SQLException,
McdbException, Exception {
- String documentDir = PropertyService.getProperty("application.documentfilepath");
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
try {
@@ -1802,22 +1800,16 @@
// Try to get the metadata file from disk. If it isn't
// found, create it from the db and write it to disk then.
- String documentPath = documentDir + FileUtil.getFS() + docid;
try {
- if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST) {
- FileWriter fileWriter = new FileWriter(documentPath);
- doc.toXml(fileWriter, user, groups, withInlineData);
- }
-
PrintWriter out = new PrintWriter(streamOut);
- doc.readFromFileSystem(out, user, groups, documentPath);
+ doc.toXml(out, user, groups, withInlineData);
} catch (Exception e) {
// any exceptions in reading the xml from disc, and we go back to the
// old way of creating the xml directly.
- logMetacat.error("could not read from document file " + documentPath
+ logMetacat.error("could not read from document file " + docid
+ ": " + e.getMessage());
PrintWriter out = new PrintWriter(streamOut);
- doc.toXml(out, user, groups, withInlineData);
+ doc.toXmlFromDb(out, user, groups, withInlineData);
}
} else {
// TODO MCD, this should read from disk as well?
@@ -2135,14 +2127,14 @@
// set eml2 base validation parser
String rule = DocumentImpl.EML200;
// using emlparser to check id validation
-// EMLParser parser = new EMLParser(doctext[0]);
+ EMLParser parser = new EMLParser(doctext[0]);
documentWrapper = new DocumentImplWrapper(rule, true);
} else if (namespace.compareTo(
DocumentImpl.EML2_1_0NAMESPACE) == 0) {
// set eml2 base validation parser
String rule = DocumentImpl.EML210;
// using emlparser to check id validation
-// EMLParser parser = new EMLParser(doctext[0]);
+ EMLParser parser = new EMLParser(doctext[0]);
documentWrapper = new DocumentImplWrapper(rule, true);
} else {
// set schema base validation parser
@@ -2182,27 +2174,6 @@
newdocid = documentWrapper.write(dbConn, xml, pub, dtd,
doAction, accNumber, user, groups);
-
- // write the document to disk
- FileWriter fileWriter = null;
- try {
- String documentDir =
- PropertyService.getProperty("application.documentfilepath");
- String documentPath = documentDir + FileUtil.getFS() + accNumber;
-
- if (accNumber != null
- && FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST) {
- fileWriter = new FileWriter(documentPath);
- fileWriter.write(doctext[0]);
- }
- } catch (IOException ioe) {
- logMetacat.error("Did not write " + accNumber
- + " to file system: " + ioe.getMessage());
- } finally {
- if (fileWriter != null) {
- fileWriter.close();
- }
- }
EventLog.getInstance().log(request.getRemoteAddr(),
user, accNumber, action[0]);
More information about the Metacat-cvs
mailing list