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

Logging

parent 6dba75be
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,6 @@
import java.io.IOException;
import java.net.URI;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
......@@ -24,7 +23,6 @@
import javax.ws.rs.core.Response;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.XsltExecutable;
import org.apache.cxf.jaxrs.model.wadl.Description;
......@@ -44,10 +42,6 @@ private StylesheetManager getStylesheetManager() {
return stylesheetManager;
}
final Logger logger = Logger.getLogger("info.textgrid.services.aggregator.EPUB");
private XsltExecutable teiToEpub;
@Context
private ServletContext servlet;
......
......@@ -16,6 +16,7 @@
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Map.Entry;
......@@ -63,6 +64,8 @@ public EPUBSerializer(final ITextGridRep repository,
setMediaType("application/epub+zip");
setFileExtension("epub");
setFlatCorpus(true);
logger.info(MessageFormat.format("Started EPUB serialization for {0} after {1}",
uriList, stopwatch));
}
public void setStylesheet(final URI stylesheet) {
......@@ -79,7 +82,7 @@ public ResponseBuilder createResponse() throws MetadataParseFault,
return getResponseBuilder();
workingDir = Files.createTempDir();
logger.fine("Using " + workingDir + " to build the E-Book");
logger.fine(MessageFormat.format("Using {0} to build the E-Book", workingDir));
corpus = new File(workingDir, "corpus.xml");
setBufferFactory(new FileBufferFactory(corpus));
......@@ -97,6 +100,8 @@ public ResponseBuilder createResponse() throws MetadataParseFault,
.newSerializer(new File(workingDir, "output.xml")));
transformer.setSource(source);
transformer.transform();
logger.fine(MessageFormat.format("Finished EPUB transformation for {0} after {1}",
getRootURIs(), stopwatch));
return getResponseBuilder();
}
......@@ -107,6 +112,7 @@ private StylesheetManager getStylesheetManager() {
@Override
public void write(final OutputStream output) throws IOException,
WebApplicationException {
logger.info("Starting EPUB zipping for " + getRootURIs() + " after " + stopwatch);
final ZipOutputStream zip = new ZipOutputStream(output);
try {
......@@ -116,7 +122,6 @@ public void write(final OutputStream output) throws IOException,
final File mimeTypeFile = new File(workingDir, "mimetype");
final URI base = workingDir.toURI();
final File opsDir = new File(workingDir, "OPS");
final URI ops = opsDir.toURI();
final OPFManifest manifest = new OPFManifest(new File(opsDir,
"content.opf"));
final ConfigurableXMLRewriter xhtmlRewriter = new ConfigurableXMLRewriter(
......@@ -161,6 +166,10 @@ public void write(final OutputStream output) throws IOException,
}
}
logger.info(MessageFormat.format(
"Adding {0} external items to EPUB for {1} after {2}",
manifest.externalItems.size(), getRootURIs(), stopwatch));
// now we need to add those files that are referenced by
// absolute URI in the manifest
for (final Entry<URI, String> externalItem : manifest.externalItems
......@@ -172,6 +181,9 @@ public void write(final OutputStream output) throws IOException,
ByteStreams.copy(
repository.getContent(externalItem.getKey(), sid.orNull()), zip);
zip.closeEntry();
logger.info(MessageFormat.format(
"Successfully exported EPUB for {0} after {1}",
getRootURIs(), stopwatch));
}
} catch (final SAXException e) {
throw new WebApplicationException(e);
......@@ -192,6 +204,7 @@ public void write(final OutputStream output) throws IOException,
} finally {
zip.close();
FileUtils.removeDir(workingDir);
stopwatch.stop();
}
}
......
......@@ -12,7 +12,6 @@
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
......@@ -36,9 +35,6 @@ public class HTML {
ITextGridRep repository = TextGridRepProvider.getInstance();
final Logger logger = Logger
.getLogger("info.textgrid.services.aggregator.html.HTML");
@Context ServletContext servlet;
private StylesheetManager stylesheetManager;
......@@ -71,7 +67,6 @@ public Response get(
ProtocolNotImplementedFault, WebApplicationException, IOException,
SaxonApiException, ExecutionException {
logger.fine("HTML called for root objects: " + uriList);
final HTMLWriter writer = new HTMLWriter(repository, getStylesheetManager(), uriList, xsluri,
refreshStylesheet, pi, embedded, css, sid, mediaType, request);
......
......@@ -108,6 +108,8 @@ public HTMLWriter(final ITextGridRep repository, final StylesheetManager stylesh
setDisposition(Disposition.INLINE);
setFileExtension("html");
setMediaType(MediaType.TEXT_HTML);
logger.info(MessageFormat.format("Started HTML serialization for {0} after {1}",
this.rootURIs, stopwatch));
}
public HTMLWriter(final ITextGridRep repository, final StylesheetManager stylesheetManager, final String rootURIs,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment