Skip to content
Snippets Groups Projects
Commit 370ce076 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Merge branch 'release/1.4.10'

parents 83dca441 b16690c4
Branches
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.services</groupId>
<artifactId>aggregator</artifactId>
<version>1.4.9</version>
<version>1.4.10</version>
<packaging>war</packaging>
<name>TextGrid Aggregator Service</name>
......
......@@ -189,18 +189,22 @@ void detectEmbeddedStylesheet(final Source source) {
private XsltExecutable getStylesheet() throws SaxonApiException,
IOException {
if (explicitStylesheetURI.isPresent()) {
actualStylesheetLabel = explicitStylesheetURI.get().toString() + " (explicit)";
return stylesheetManager.getStylesheet(explicitStylesheetURI.get(), getSid(),
refreshStylesheet, false);
} else if (associatedStylesheetURI.isPresent()) {
actualStylesheetLabel = associatedStylesheetURI.get().toString() + " (associated)";
return stylesheetManager.getStylesheet(associatedStylesheetURI.get(), getSid(),
refreshStylesheet, false);
} else {
actualStylesheetLabel = "(internal)";
return stylesheetManager.getStylesheet(TO_HTML_XSL, getSid(), false, true);
try {
if (explicitStylesheetURI.isPresent()) {
actualStylesheetLabel = explicitStylesheetURI.get().toString() + " (explicit)";
return stylesheetManager.getStylesheet(explicitStylesheetURI.get(), getSid(),
refreshStylesheet, false);
} else if (associatedStylesheetURI.isPresent()) {
actualStylesheetLabel = associatedStylesheetURI.get().toString() + " (associated)";
return stylesheetManager.getStylesheet(associatedStylesheetURI.get(), getSid(),
refreshStylesheet, false);
};
} catch (final SaxonApiException e) {
logger.log(Level.WARNING, MessageFormat.format("Failed to load stylesheet {0}, falling back to internal",
actualStylesheetLabel), e);
}
actualStylesheetLabel = "(internal)";
return stylesheetManager.getStylesheet(TO_HTML_XSL, getSid(), false, true);
}
private Source getSource() throws ObjectNotFoundFault, MetadataParseFault, IoFault, ProtocolNotImplementedFault, AuthFault, IOException {
......
......@@ -7,9 +7,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.*;
import java.text.MessageFormat;
import java.util.Set;
import java.util.concurrent.Callable;
......@@ -199,8 +197,15 @@ public XsltExecutable call() throws Exception {
throw new PrivateResourceException(executable);
}
} else {
URLConnection connection = uri.toURL().openConnection();
if (connection instanceof HttpURLConnection) {
HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.setInstanceFollowRedirects(true);
httpConnection.setRequestProperty("Accept", "text/xsl, text/xslt, application/xslt+xml, */*;q=0.8");
}
// (2) it's non-TextGrid -- load & cache it.
executable = compiler.compile(new StreamSource(uri.toString()));
InputStream inputStream = connection.getInputStream();
executable = compiler.compile(new StreamSource(inputStream));
logger.log(Level.INFO, "Cached external stylesheet {0}", uri);
return executable;
}
......
......@@ -9,15 +9,13 @@
import info.textgrid.services.aggregator.util.StylesheetManager;
import info.textgrid.services.aggregator.util.TextGridRepProvider;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import javax.ws.rs.WebApplicationException;
import net.sf.saxon.s9api.SaxonApiException;
import org.apache.commons.io.output.NullOutputStream;
import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLTestCase;
......@@ -58,7 +56,7 @@ protected void writeHtmlTo(final String uris, final OutputStream target, boolean
MetadataParseFault, IoFault, ProtocolNotImplementedFault,
AuthFault, SaxonApiException {
final HTMLWriter htmlWriter = new HTMLWriter(rep, stylesheets, uris, null,
false, false, embedded, null, null, null, null, null);
false, true, embedded, null, null, null, null, null);
htmlWriter.createResponse();
htmlWriter.write(target);
}
......@@ -151,4 +149,9 @@ public void testLetter() throws WebApplicationException, IOException, SAXExcepti
compareHtml("textgrid:11sqw.0", "11sqw.0.html", false);
}
@Test
public void testEPoetics() throws IOException, IoFault, AuthFault, SaxonApiException, ObjectNotFoundFault, MetadataParseFault, ProtocolNotImplementedFault, SAXException {
compareHtml("textgrid:2shhm.0", "2shhm.0.html", false);
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment