Revision 5958
Added by Chris Jones almost 14 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package edu.ucsb.nceas.metacat; |
26 | 26 |
|
27 |
import au.com.bytecode.opencsv.CSVWriter; |
|
28 |
|
|
29 |
import edu.ucsb.nceas.metacat.AccessionNumber; |
|
30 |
import edu.ucsb.nceas.metacat.AccessionNumberException; |
|
31 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
|
32 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException; |
|
33 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlForSingleFile; |
|
34 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface; |
|
35 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlList; |
|
36 |
import edu.ucsb.nceas.metacat.cart.CartManager; |
|
37 |
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException; |
|
38 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
|
39 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
|
40 |
import edu.ucsb.nceas.metacat.dataquery.DataQuery; |
|
41 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
42 |
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler; |
|
43 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
44 |
import edu.ucsb.nceas.metacat.service.XMLSchemaService; |
|
45 |
import edu.ucsb.nceas.metacat.shared.HandlerException; |
|
46 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
|
47 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
|
48 |
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester; |
|
49 |
import edu.ucsb.nceas.metacat.spatial.SpatialQuery; |
|
50 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
|
51 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
|
52 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
|
53 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
|
54 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
55 |
|
|
56 |
import edu.ucsb.nceas.utilities.FileUtil; |
|
57 |
import edu.ucsb.nceas.utilities.LSIDUtil; |
|
58 |
import edu.ucsb.nceas.utilities.ParseLSIDException; |
|
59 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
60 |
|
|
27 | 61 |
import java.io.BufferedInputStream; |
28 | 62 |
import java.io.ByteArrayInputStream; |
29 | 63 |
import java.io.File; |
30 | 64 |
import java.io.FileInputStream; |
65 |
import java.io.FileOutputStream; |
|
66 |
import java.io.FileNotFoundException; |
|
31 | 67 |
import java.io.IOException; |
68 |
import java.io.InputStream; |
|
32 | 69 |
import java.io.InputStreamReader; |
33 | 70 |
import java.io.OutputStream; |
34 | 71 |
import java.io.OutputStreamWriter; |
... | ... | |
40 | 77 |
import java.io.Writer; |
41 | 78 |
import java.net.MalformedURLException; |
42 | 79 |
import java.net.URL; |
80 |
import java.security.NoSuchAlgorithmException; |
|
43 | 81 |
import java.sql.PreparedStatement; |
44 | 82 |
import java.sql.ResultSet; |
45 | 83 |
import java.sql.SQLException; |
46 | 84 |
import java.sql.Timestamp; |
47 | 85 |
import java.text.ParseException; |
48 | 86 |
import java.text.SimpleDateFormat; |
87 |
import java.util.Date; |
|
49 | 88 |
import java.util.Enumeration; |
50 | 89 |
import java.util.HashMap; |
51 | 90 |
import java.util.Hashtable; |
52 | 91 |
import java.util.Iterator; |
53 | 92 |
import java.util.Map; |
54 | 93 |
import java.util.Timer; |
94 |
import java.util.TimerTask; |
|
95 |
import java.util.TimeZone; |
|
55 | 96 |
import java.util.Vector; |
56 | 97 |
import java.util.zip.ZipEntry; |
57 | 98 |
import java.util.zip.ZipOutputStream; |
... | ... | |
62 | 103 |
import javax.servlet.http.HttpSession; |
63 | 104 |
import javax.activation.MimetypesFileTypeMap; |
64 | 105 |
|
106 |
import javax.xml.parsers.ParserConfigurationException; |
|
107 |
import javax.xml.xpath.XPathExpressionException; |
|
108 |
|
|
65 | 109 |
import org.apache.commons.io.input.XmlStreamReader; |
66 | 110 |
import org.apache.log4j.Logger; |
67 | 111 |
import org.ecoinformatics.eml.EMLParser; |
68 | 112 |
|
69 |
import au.com.bytecode.opencsv.CSVWriter; |
|
113 |
import org.dataone.eml.DataoneEMLParser; |
|
114 |
import org.dataone.eml.EMLDocument; |
|
115 |
import org.dataone.eml.EMLDocument.DistributionMetadata; |
|
70 | 116 |
|
117 |
import org.dataone.service.exceptions.NotFound; |
|
118 |
import org.dataone.service.types.NodeReference; |
|
119 |
import org.dataone.service.types.util.ServiceTypeUtil; |
|
120 |
|
|
121 |
import org.jibx.runtime.BindingDirectory; |
|
122 |
import org.jibx.runtime.IBindingFactory; |
|
123 |
import org.jibx.runtime.IMarshallingContext; |
|
124 |
import org.jibx.runtime.IUnmarshallingContext; |
|
125 |
import org.jibx.runtime.JiBXException; |
|
126 |
|
|
127 |
import org.xml.sax.SAXException; |
|
128 |
|
|
71 | 129 |
import com.oreilly.servlet.multipart.FilePart; |
72 | 130 |
import com.oreilly.servlet.multipart.MultipartParser; |
73 | 131 |
import com.oreilly.servlet.multipart.ParamPart; |
74 | 132 |
import com.oreilly.servlet.multipart.Part; |
75 | 133 |
|
76 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException; |
|
77 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlForSingleFile; |
|
78 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface; |
|
79 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlList; |
|
80 |
import edu.ucsb.nceas.metacat.cart.CartManager; |
|
81 |
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException; |
|
82 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
|
83 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
|
84 |
import edu.ucsb.nceas.metacat.dataquery.DataQuery; |
|
85 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
86 |
import edu.ucsb.nceas.metacat.replication.ForceReplicationHandler; |
|
87 |
import edu.ucsb.nceas.metacat.service.SessionService; |
|
88 |
import edu.ucsb.nceas.metacat.service.XMLSchemaService; |
|
89 |
import edu.ucsb.nceas.metacat.shared.HandlerException; |
|
90 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
|
91 |
import edu.ucsb.nceas.metacat.shared.ServiceException; |
|
92 |
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester; |
|
93 |
import edu.ucsb.nceas.metacat.spatial.SpatialQuery; |
|
94 |
import edu.ucsb.nceas.metacat.util.AuthUtil; |
|
95 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
|
96 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
|
97 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
|
98 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
99 |
import edu.ucsb.nceas.utilities.FileUtil; |
|
100 |
import edu.ucsb.nceas.utilities.LSIDUtil; |
|
101 |
import edu.ucsb.nceas.utilities.ParseLSIDException; |
|
102 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
134 |
import org.dataone.service.types.AuthToken; |
|
135 |
import org.dataone.service.types.Checksum; |
|
136 |
import org.dataone.service.types.ChecksumAlgorithm; |
|
137 |
import org.dataone.service.types.Identifier; |
|
138 |
import org.dataone.service.types.ObjectFormat; |
|
139 |
import org.dataone.service.types.Principal; |
|
140 |
import org.dataone.service.types.SystemMetadata; |
|
103 | 141 |
|
142 |
import org.dataone.service.exceptions.BaseException; |
|
143 |
|
|
104 | 144 |
/** |
105 | 145 |
* General entry point for the Metacat server which is called from various |
106 | 146 |
* mechanisms such as the standard MetacatServlet class and the various web |
... | ... | |
966 | 1006 |
//System.out.println("response from MetacatHandler.setAccess: " + resp); |
967 | 1007 |
} |
968 | 1008 |
|
1009 |
/** |
|
1010 |
* Read a file from Metacat's configured file system data directory. |
|
1011 |
* |
|
1012 |
* @param filename The full path file name of the file to read |
|
1013 |
* |
|
1014 |
* @return fileInputStream The file to read as a FileInputStream |
|
1015 |
*/ |
|
1016 |
private FileInputStream readFromFilesystem(String filename) |
|
1017 |
throws FileNotFoundException { |
|
1018 |
|
|
1019 |
logMetacat.debug("MetacatHandler.readFromFilesystem() called."); |
|
1020 |
|
|
1021 |
FileInputStream fileInputStream = null; |
|
1022 |
|
|
1023 |
try { |
|
1024 |
fileInputStream = new FileInputStream(filename); |
|
1025 |
|
|
1026 |
} catch ( FileNotFoundException fnfe ) { |
|
1027 |
logMetacat.debug("There was an error reading the file " + |
|
1028 |
filename + ". The error was: " + |
|
1029 |
fnfe.getMessage()); |
|
1030 |
throw fnfe; |
|
1031 |
|
|
1032 |
} |
|
1033 |
|
|
1034 |
return fileInputStream; |
|
1035 |
} |
|
1036 |
|
|
969 | 1037 |
/** read metadata or data from Metacat |
970 | 1038 |
* @throws PropertyNotFoundException |
971 | 1039 |
* @throws ParseLSIDException |
Also available in: Unified diff
To support generation of SystemMetadata and GUIDs, added a number of methods to MetacatHandler that are also in CrudService(). CrudService should eventually be refactored to use the handler methods. Added:
readFromFilesystem() - Read a file from Metacat's configured file system data directory, and return a FileInputStream. This code has been factored out of handleInsertOrUpdateAction().
Also updated the imports list to support new methods.