use of org.collectionspace.chain.csp.config.ConfigException in project application by collectionspace.
the class AssemblingContentHandler method apply_xslt.
private void apply_xslt(InputSource xslt, String root) throws SAXException {
String errMsg = String.format("Config Generation: '%s' - Could not create inner parser.", getSrcFileName());
try {
ContentHandler inner = new AssemblingContentHandler(parser, up, false, false, this);
TransformerHandler transformer = transfactory.newTransformerHandler(new StreamSource(xslt.getByteStream()));
transformer.setResult(new SAXResult(inner));
delegated = transformer;
delegated.startDocument();
if (root != null) {
delegated.startElement("", root, root, new AttributesImpl());
}
delegated_root = root;
delegated_depth = 1;
} catch (TransformerConfigurationException e) {
throw new SAXException(errMsg, e);
} catch (ConfigException e) {
throw new SAXException(errMsg, e);
} catch (IOException e) {
throw new SAXException(errMsg, e);
}
}
use of org.collectionspace.chain.csp.config.ConfigException in project application by collectionspace.
the class AssemblingParser method parse.
public void parse(Result out) throws ConfigException {
String errMsg = String.format("Config Generation: '%s' - Exception raised during parsing.", this.getMain().getPublicId());
try {
String rootpath = AssemblingParser.class.getPackage().getName().replaceAll("\\.", "/") + "/" + root_file;
// load the file at org/collectionspace/chain/csp/config/impl/parser/root.xml
InputStream root = Thread.currentThread().getContextClassLoader().getResourceAsStream(rootpath);
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
TransformerHandler xform = transfactory.newTransformerHandler();
xform.setResult(out);
AssemblingContentHandler assemblingContentHandler = new AssemblingContentHandler(this, xform);
logger.info(String.format("Temporary XMLMerge files will be written out to '%s'.", AssemblingContentHandler.getTempDirectory()));
reader.setContentHandler(assemblingContentHandler);
reader.parse(new InputSource(root));
} catch (IOException e) {
throw new ConfigException(errMsg, e);
} catch (ParserConfigurationException e) {
throw new ConfigException(errMsg, e);
} catch (SAXException e) {
throw new ConfigException(errMsg, e);
} catch (TransformerConfigurationException e) {
throw new ConfigException(errMsg, e);
}
}
use of org.collectionspace.chain.csp.config.ConfigException in project application by collectionspace.
the class ConfigErrorHandler method fail_if_necessary.
public void fail_if_necessary() throws ConfigException {
if (errors.size() == 0)
return;
StringBuffer out = new StringBuffer();
out.append("Error loading config. See messages for details: summary ");
for (Throwable t : errors) {
out.append(t.getMessage());
if (t instanceof SAXParseException) {
SAXParseException s = (SAXParseException) t;
out.append("[" + s.getSystemId() + "/" + s.getLineNumber() + "]");
}
out.append(' ');
}
throw new ConfigException(out.toString());
}
Aggregations