Revision 5027
Added by daigle over 14 years ago
ResponseUtil.java | ||
---|---|---|
32 | 32 |
import java.io.InputStream; |
33 | 33 |
import java.io.OutputStream; |
34 | 34 |
import java.io.PrintWriter; |
35 |
import java.sql.SQLException; |
|
36 | 35 |
import java.util.Hashtable; |
37 | 36 |
|
38 | 37 |
import javax.servlet.http.HttpServletRequest; |
... | ... | |
40 | 39 |
|
41 | 40 |
import org.apache.log4j.Logger; |
42 | 41 |
|
43 |
import edu.ucsb.nceas.metacat.DBTransform; |
|
44 | 42 |
import edu.ucsb.nceas.metacat.shared.BaseException; |
45 | 43 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException; |
46 | 44 |
import edu.ucsb.nceas.utilities.FileUtil; |
47 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
48 | 45 |
|
49 | 46 |
public class ResponseUtil { |
50 | 47 |
|
... | ... | |
242 | 239 |
return message.indexOf("<success>") != -1; |
243 | 240 |
} |
244 | 241 |
|
245 |
public static void transformAndSendXML(HttpServletResponse response, String xmlDoc, |
|
246 |
String sourceType, String targetType, String qformat, |
|
247 |
Hashtable<String, String[]> params) throws ErrorSendingErrorException { |
|
248 |
|
|
249 |
PrintWriter out = null; |
|
250 |
try { |
|
251 |
out = response.getWriter(); |
|
252 |
DBTransform dbTransform = new DBTransform(); |
|
253 |
|
|
254 |
dbTransform.transformXMLDocument(xmlDoc, sourceType, targetType, qformat, out, params); |
|
255 |
} catch (PropertyNotFoundException pnfe) { |
|
256 |
throw new ErrorSendingErrorException("Property error when transforming XML: " |
|
257 |
+ xmlDoc + " : " + pnfe.getMessage()); |
|
258 |
} catch (ClassNotFoundException cnfe) { |
|
259 |
throw new ErrorSendingErrorException("Class error when transforming XML: " |
|
260 |
+ xmlDoc + " : " + cnfe.getMessage()); |
|
261 |
} catch (SQLException sqle) { |
|
262 |
throw new ErrorSendingErrorException("SQL error when transforming XML: " |
|
263 |
+ xmlDoc + " : " + sqle.getMessage()); |
|
264 |
} catch (IOException ioe) { |
|
265 |
throw new ErrorSendingErrorException("I/O error when transforming XML: " |
|
266 |
+ xmlDoc + " : " + ioe.getMessage()); |
|
267 |
} finally { |
|
268 |
if (out != null) { |
|
269 |
out.close(); |
|
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 | 242 |
} |
Also available in: Unified diff
Change MetaCatVersion to MetacatVersion