Revision 3675
Added by barteau almost 17 years ago
src/edu/ucsb/nceas/metacat/DBTransform.java | ||
---|---|---|
33 | 33 |
import java.sql.*; |
34 | 34 |
import java.util.Enumeration; |
35 | 35 |
import java.util.Hashtable; |
36 |
import java.util.Iterator; |
|
37 |
import java.util.Map; |
|
38 |
import java.util.Map.Entry; |
|
36 | 39 |
import java.util.Stack; |
37 | 40 |
|
38 | 41 |
import javax.xml.transform.TransformerFactory; |
... | ... | |
252 | 255 |
} |
253 | 256 |
} |
254 | 257 |
|
255 |
/* |
|
256 |
* Method to do transfer |
|
258 |
/** |
|
259 |
* Reads skin's config file if it exists, and populates Transformer paramaters |
|
260 |
* with its contents. |
|
261 |
* It then adds the parameters passed to it via Hashtable param to the Transformer. |
|
262 |
* It then calls the Transformer.transform method. |
|
257 | 263 |
*/ |
258 |
private void doTransform(StringReader docContent, StreamResult resultOutput, |
|
259 |
String xslSystemId, Hashtable param, |
|
260 |
String qformat, String sessionid) |
|
261 |
throws Exception |
|
262 |
{ |
|
263 |
if (xslSystemId != null) |
|
264 |
{ |
|
265 |
TransformerFactory tFactory = TransformerFactory.newInstance(); |
|
266 |
Transformer transformer = tFactory.newTransformer( |
|
267 |
new StreamSource(xslSystemId)); |
|
264 |
private void doTransform(StringReader docContent, |
|
265 |
StreamResult resultOutput, |
|
266 |
String xslSystemId, |
|
267 |
Hashtable param, |
|
268 |
String qformat, |
|
269 |
String sessionid) |
|
270 |
throws Exception { |
|
271 |
|
|
272 |
Properties skinOptions; |
|
273 |
TransformerFactory tFactory; |
|
274 |
Transformer transformer; |
|
275 |
String key, value; |
|
276 |
StreamSource xml; |
|
277 |
Enumeration en; |
|
278 |
Iterator iterIt; |
|
279 |
Map.Entry entry; |
|
280 |
|
|
281 |
if (xslSystemId != null) { |
|
282 |
tFactory = TransformerFactory.newInstance(); |
|
283 |
transformer = tFactory.newTransformer(new StreamSource(xslSystemId)); |
|
284 |
|
|
268 | 285 |
transformer.setParameter("qformat", qformat); |
269 | 286 |
logMetacat.warn("qformat: "+qformat); |
270 | 287 |
|
271 |
if (MetaCatUtil.skinconfigs.containsKey(qformat)){
|
|
272 |
Properties skinOptions = (Properties)MetaCatUtil.skinconfigs.get(qformat);
|
|
288 |
if (MetaCatUtil.hasSkinConfig(qformat)) {
|
|
289 |
skinOptions = MetaCatUtil.getSkinConfig(qformat);
|
|
273 | 290 |
|
274 |
if(skinOptions.getProperty("lsidauthority") != null){ |
|
275 |
transformer.setParameter("lsidauthority", skinOptions.getProperty("lsidauthority")); |
|
276 |
} |
|
277 |
|
|
278 |
if(skinOptions.getProperty("registryurl") != null){ |
|
279 |
transformer.setParameter("registryurl", skinOptions.getProperty("registryurl")); |
|
280 |
} |
|
281 |
|
|
282 |
if(skinOptions.getProperty("registryname") != null){ |
|
283 |
transformer.setParameter("registryname", skinOptions.getProperty("registryname")); |
|
284 |
} |
|
285 |
} |
|
291 |
iterIt = skinOptions.entrySet().iterator(); |
|
292 |
while (iterIt.hasNext()) { |
|
293 |
entry = (Entry) iterIt.next(); |
|
294 |
key = (String) entry.getKey(); |
|
295 |
value = (String) entry.getValue(); |
|
296 |
transformer.setParameter(key, value); |
|
297 |
} |
|
298 |
} |
|
286 | 299 |
|
287 |
if(sessionid != null) |
|
288 |
{ |
|
300 |
if (sessionid != null && !sessionid.equals("null")) { |
|
289 | 301 |
transformer.setParameter("sessid", sessionid); |
290 | 302 |
} |
303 |
|
|
291 | 304 |
// Set up parameter for transformation |
292 |
if ( param != null) |
|
293 |
{ |
|
294 |
Enumeration en = param.keys(); |
|
295 |
while (en.hasMoreElements()) |
|
296 |
{ |
|
297 |
String key =(String)en.nextElement(); |
|
298 |
String value = ((String[])(param.get(key)))[0]; |
|
305 |
if ( param != null) { |
|
306 |
en = param.keys(); |
|
307 |
while (en.hasMoreElements()) { |
|
308 |
key = (String) en.nextElement(); |
|
309 |
value = ((String[]) (param.get(key)))[0]; |
|
299 | 310 |
logMetacat.info(key+" : "+value); |
300 | 311 |
transformer.setParameter(key, value); |
301 | 312 |
} |
302 | 313 |
} |
303 |
StreamSource xml = new StreamSource(docContent);
|
|
314 |
xml = new StreamSource(docContent); |
|
304 | 315 |
transformer.transform(xml,resultOutput); |
305 | 316 |
} |
306 | 317 |
}//doTransform |
Also available in: Unified diff
Modification for changes to the field "MetacatUtil.skinconfigs" (bug 3057 fix).
Also changes reading skin.configs properties/files (bug 3058 fix).