Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions build-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@
<include name="junit-4.7.jar"/>
<include name="reload4j-1.2.25.jar"/>
<include name="jing.jar"/>
<include name="xml-apis.jar"/>
<include name="sac.jar"/>
<include name="saxon.jar"/>
<include name="saxon8.jar"/>
<include name="saxon8-dom.jar"/>
<include name="serializer.jar"/>
<include name="slf4j-api-1.5.6.jar"/>
<include name="slf4j-log4j12-1.5.6.jar"/>
<include name="stax-api-1.0.1.jar"/>
<include name="tagsoup-1.2.jar"/>
<include name="tritonus_remaining-0.3.6.jar"/>
<include name="tritonus_share-0.3.6.jar"/>
Expand Down Expand Up @@ -193,13 +191,13 @@
<javac srcdir="${dmfc.src.dir}"
destdir="${build.dir}"
includes="**/*.java"
debug="true" encoding="UTF-8" source="11" target="11">
debug="true" encoding="UTF-8" source="1.8" target="1.8">
<classpath refid="path.utilJars"/>
</javac>
<javac srcdir="${transformers.dir}"
destdir="${transformers.dir}"
includes="**/*.java"
debug="true" encoding="UTF-8" source="11" target="11">
debug="true" encoding="UTF-8" source="1.8" target="1.8">
<classpath refid="path.build.transformers"/>
</javac>
<copy todir="${build.dir}" failonerror="true" overwrite="false">
Expand Down
Binary file removed lib/stax-api-1.0.1.jar
Binary file not shown.
Binary file removed lib/xml-apis.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/org/daisy/pipeline/core/DirClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DirClassLoader extends URLClassLoader {
* directory for resource files
*/
public DirClassLoader(File clsDir, File resDir) {
super(new URL[] { fileToURL(clsDir) });
super(new URL[] { fileToURL(clsDir) }, DirClassLoader.class.getClassLoader());
classDir = clsDir;
resourceDir = resDir;
}
Expand Down
9 changes: 4 additions & 5 deletions src/org/daisy/pipeline/core/PipelineCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
public class PipelineCore {

private Creator mCreator;
protected Creator mCreator;
private Runner mRunner;
private File mHomeDir;

Expand Down Expand Up @@ -166,10 +166,9 @@ private void initialize(Properties userProps, Properties pipelineProps)
setUserProperties(userProps);

// Load messages
ResourceBundle bundle = XMLPropertyResourceBundle.getBundle((this
.getClass().getPackage().getName()).replace('.', '/')
+ "/messages.properties", Locale.getDefault(), this.getClass()
.getClassLoader());
ResourceBundle bundle = XMLPropertyResourceBundle.getBundle(
"org/daisy/pipeline/core/messages.properties", Locale.getDefault(),
this.getClass().getClassLoader());
// ResourceBundle bundle =
// XMLPropertyResourceBundle.getBundle(this.getClass().getPackage().getName()
// + ".pipeline.messages", Locale.getDefault(),
Expand Down
8 changes: 6 additions & 2 deletions src/org/daisy/pipeline/core/script/Creator.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ private void setTransformerHandlers(Script script)
throws ScriptValidationException {
for (Task task : script.getTasks()) {
try {
TransformerHandler handler = TransformerHandlerLoader.INSTANCE
.getTransformerHandler(task.getName());
TransformerHandler handler = getTransformerHandler(task.getName());
if (handler != null) {
task.setTransformerHandler(handler);
} else {
Expand All @@ -118,4 +117,9 @@ private void setTransformerHandlers(Script script)
}
}
}

protected TransformerHandler getTransformerHandler(String name)
throws TransformerDisabledException {
return TransformerHandlerLoader.INSTANCE.getTransformerHandler(name);
}
}
2 changes: 1 addition & 1 deletion src/org/daisy/pipeline/core/script/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void execute(Job job) throws JobFailedException {
// Add hard-coded transformer parameters
this.addTransformerParameters(parameters, handler);

boolean success = handler.run(parameters, task.isInteractive(), task, null);
boolean success = handler.run(parameters, task.isInteractive(), task, job);
if (!success) {
throw new JobFailedException(i18n("TASK_FAILED", handler.getName()));
}
Expand Down
6 changes: 4 additions & 2 deletions src/org/daisy/pipeline/core/script/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.daisy.pipeline.core.script;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URL;
Expand Down Expand Up @@ -173,8 +174,9 @@ void setDescription(String description) {
* @param uri
*/
void setDocumentation(URI uri) {
File test = new File(uri);
if(!test.exists()||!test.canRead()) {
try {
uri.toURL().openStream();
} catch (IllegalArgumentException|IOException e) {
System.out.println("Warning [in Script#setDocumentation]: Script documentation URI " + uri.toString() + " seems not to resolve");
}
this.mDocumentation = uri;
Expand Down
3 changes: 2 additions & 1 deletion src/org/daisy/pipeline/core/script/ScriptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public static File upgrade(URL url) throws ScriptValidationException {
throw new ScriptValidationException(e.getMessage(), e);
} finally {
try {
PeekerPool.getInstance().release(peeker);
if (peeker != null)
PeekerPool.getInstance().release(peeker);
} catch (PoolException e) {}
}

Expand Down
3 changes: 2 additions & 1 deletion src/org/daisy/pipeline/util/PropertiesValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public PropertiesValidator(String path) throws IOException, CatalogExceptionNotR

for (File inputFile : files) {
try {
XMLInputFactory2 ifact = (XMLInputFactory2)XMLInputFactory.newInstance();
XMLInputFactory2 ifact = (XMLInputFactory2)XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
ifact.setXMLResolver(new StaxEntityResolver(CatalogEntityResolver.getInstance()));
XMLStreamReader2 sr = ifact.createXMLStreamReader(inputFile);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ private void executeSchemas() throws ValidatorNotSupportedException, ValidatorEx
if(SchemaLanguageConstants.hasEntry(uri)) {
++nsURIsFound;
try{
SchemaFactory factory = SchemaFactory.newInstance(uri);
// SchemaFactoryFinder is not public in Java 8
SchemaFactory factory = /*new SchemaFactoryFinder(getClass().getClassLoader()).newFactory(uri);
if (factory == null)
throw new IllegalStateException("No SchemaFactory could be loaded for " + uri);*/SchemaFactory.newInstance(uri);
factory.setErrorHandler(this);
factory.setResourceResolver(CatalogEntityResolver.getInstance());
//go via StreamSource and explicitly set the system id to be safe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public void execute(Fileset fileset) throws ValidatorNotSupportedException, Vali
* @throws CatalogExceptionNotRecoverable
*/
private void checkXMLDeclaration(URL url) throws URISyntaxException, XMLStreamException, IOException, CatalogExceptionNotRecoverable {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLInputFactory inputFactory = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ private void checkEncoding(URL url) throws IOException, URISyntaxException, Cata
String charset = detector.detect(url);
String[] probableCharsets = detector.getProbableCharsets();

XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLInputFactory inputFactory = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public void execute(Fileset fileset) throws ValidatorNotSupportedException, Vali
private void checkForDocTypeDeclaration(URL url) throws XMLStreamException, IOException,
URISyntaxException {
boolean foundDocTypeDecl = false;
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLInputFactory inputFactory = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());

InputStream is = null;
XMLEventReader eventReader = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public void execute(Fileset fileset) throws ValidatorNotSupportedException, Vali
* @throws URISyntaxException
*/
public void checkForProcessingInstruction(URL url) throws CatalogExceptionNotRecoverable, XMLStreamException, IOException, URISyntaxException {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLInputFactory inputFactory = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
Expand Down
11 changes: 10 additions & 1 deletion src/org/daisy/util/text/URIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,16 @@ public static URI resolve(URI reference, URI uri) {
throw new IllegalStateException("shouldn't happen: "
+ e.getMessage(), e);
}

} else if (reference.toString().startsWith("jar:") && !uri.isAbsolute()) {
try {
reference = new URI(reference.toASCIIString().substring(4));
uri = reference.resolve(uri);
uri = new URI("jar:" + uri.toASCIIString());
return uri;
} catch (URISyntaxException e) {
throw new IllegalStateException("shouldn't happen: "
+ e.getMessage(), e);
}
} else {
return reference.resolve(uri);
}
Expand Down
3 changes: 2 additions & 1 deletion src/org/daisy/util/xml/NamespaceReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public NamespaceReporter(URL document) throws IOException, XMLStreamException {
}
}
} finally {
reader.close();
if (reader != null)
reader.close();
pool.release(xif, mProperties, null);
}

Expand Down
3 changes: 2 additions & 1 deletion src/org/daisy/util/xml/PeekerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ private void readStream()
throws XMLStreamException {
try {
if (xif == null) {
xif = XMLInputFactory.newInstance();
xif = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
xif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
Expand Down
3 changes: 2 additions & 1 deletion src/org/daisy/util/xml/pool/StAXInputFactoryPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public void release(XMLInputFactory xif, Map<String,Object> properties) throws P
* @throws PoolException
*/
private XMLInputFactory create(Map<String,Object> properties) throws PoolException {
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLInputFactory xif = XMLInputFactory.newFactory(
"javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
return setProperties(xif,properties);
}

Expand Down
5 changes: 4 additions & 1 deletion src/org/daisy/util/xml/validation/SimpleValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ private boolean doJAXPSchemaValidation(URL url) throws SAXException {
try{
String schemaNsURI = mSchemaSources.get(source);
if(!factoryMap.containsKey(schemaNsURI)) {
factoryMap.put(schemaNsURI,SchemaFactory.newInstance(schemaNsURI));
SchemaFactory f = /*new SchemaFactoryFinder(getClass().getClassLoader()).newFactory(schemaNsURI);
if (f == null)
throw new IllegalStateException("No SchemaFactory could be loaded for " + schemaNsURI);*/SchemaFactory.newInstance(schemaNsURI);
factoryMap.put(schemaNsURI, f);
}
anySchemaFactory = factoryMap.get(schemaNsURI);
anySchemaFactory.setErrorHandler(mErrorHandler);
Expand Down