r673 - branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst
Author: jpages Date: 2012-05-24 16:00:52 +0200 (Thu, 24 May 2012) New Revision: 673 Url: http://nuiton.org/repositories/revision/jrst/673 Log: Ajout de commentaires. Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-24 12:52:39 UTC (rev 672) +++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-24 14:00:52 UTC (rev 673) @@ -288,8 +288,11 @@ if (outputType.equals("pdf")) { try { + // Creation of the document builder DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); builder.setEntityResolver(result.getEntityResolver()); + + // We must redifine our own DocumentInputSource because of the visibility MyDocumentInputSource source = new MyDocumentInputSource(result); org.w3c.dom.Document doc = builder.parse(source); @@ -313,6 +316,7 @@ } } else { + // If the output file type si not "pdf", we can write in the final file OutputStreamWriter writer = null; try { writer = new OutputStreamWriter(outputStream, outputEncoding); @@ -447,7 +451,7 @@ /* Transformation of the __run__ URL into a path that python will use For example the URL is : jar:file:/home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar!/__run__.py - and it will become : + and it becomes : /home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar/ */ URL resource = JRST.class.getResource("/" + DOCUTILS_LAUNCHER); Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 12:52:39 UTC (rev 672) +++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 14:00:52 UTC (rev 673) @@ -64,6 +64,7 @@ // Sets the scale of the image scaleToOutputResolution(image); + // Creation of the image for IText ITextFSImage iTextFSImage = new ITextFSImage(image); imageResource = new ImageResource(iTextFSImage); } catch (Exception eee) { @@ -101,24 +102,27 @@ public String resolveURI(String uri) { if (uri == null) return null; String ret = null; + // If path is null, we try to set the baseURL with the uri, or if it doesn't work, with the current path if (path == null) { try { URL result = new URL(uri); setBaseURL(result.toExternalForm()); } catch (MalformedURLException e) { try { + // Sets the current file for the base url setBaseURL(new File(".").toURI().toURL().toExternalForm()); } catch (Exception e1) { - XRLog.exception("The default NaiveUserAgent doesn't know how to resolve the base URL for " + uri); + log.info("The default NaiveUserAgent doesn't know how to resolve the base URL for " + uri); return null; } } } try { + // If the URI is absolute, we return the string of the url return new URL(uri).toString(); } catch (MalformedURLException e) { - XRLog.load("Could not read " + uri + " as a URL; may be relative. Testing using parent URL " + path); + // If we are here, the uri is relative so we must build the absolute link with the path try { File filePath = new File(path); URI resourcePath = filePath.toURI(); @@ -128,7 +132,7 @@ URL result = resourcePath.toURL(); ret = result.toURI().toString(); } catch (Exception e1) { - XRLog.exception("The default NaiveUserAgent cannot resolve the URL " + uri + " with base URL " + path); + log.error("The default NaiveUserAgent cannot resolve the URL " + uri + " with base URL " + path, e1); } } return ret;
participants (1)
-
jpages@users.nuiton.org