src/org/sonews/storage/DrupalMessage.java
changeset 105 d566d08c20d6
parent 104 b4c8a2760d6f
child 106 dc04a3c2c557
     1.1 --- a/src/org/sonews/storage/DrupalMessage.java	Fri Oct 21 17:35:29 2011 +0200
     1.2 +++ b/src/org/sonews/storage/DrupalMessage.java	Fri Oct 21 18:21:30 2011 +0200
     1.3 @@ -209,26 +209,25 @@
     1.4  		return new DOMSource(d);
     1.5  	}
     1.6  
     1.7 -	private String readXhtmlText(String text, String subject, long parentId, String urlBase, String wwwRead, String wwwPost) throws TransformerException, IOException, ParserConfigurationException, SAXException {
     1.8 +	private String readXhtmlText(String sourceText, String subject, long parentId, String urlBase, String wwwRead, String wwwPost) throws TransformerException, IOException, ParserConfigurationException, SAXException {
     1.9  		/**
    1.10  		 * TODO: 
    1.11  		 *		- znovupoužívat XSL transformér (nejen v instanci)
    1.12  		 *		- používat cache, ukládat si vygenerované články
    1.13  		 */
    1.14 -		String inputText = makeSimpleXHTML(text);
    1.15 +		String wrappedText = makeSimpleXHTML(sourceText);
    1.16  
    1.17  		Transformer paragraphTransformer = transformerFactory.newTransformer(new StreamSource(Resource.getAsStream("helpers/mimeXhtmlPart-make-paragraphs.xsl")));
    1.18 -
    1.19  		String paragraphedText;
    1.20  		boolean tidyWasUsed = false;
    1.21  		try {
    1.22 -			StringWriter output = new StringWriter(2 * inputText.length());
    1.23 -			paragraphTransformer.transform(readDOM(inputText), new StreamResult(output));
    1.24 +			StringWriter output = new StringWriter(2 * wrappedText.length());
    1.25 +			paragraphTransformer.transform(readDOM(wrappedText), new StreamResult(output));
    1.26  			paragraphedText = output.toString();
    1.27  		} catch (Exception e) {
    1.28  			log.log(Level.FINER, "HTML input was shitty – Tidy had to be called.", e);
    1.29 -			StringWriter output = new StringWriter(2 * inputText.length());
    1.30 -			paragraphTransformer.transform(readDOM(tidyXhtml(inputText)), new StreamResult(output));
    1.31 +			StringWriter output = new StringWriter(2 * wrappedText.length());
    1.32 +			paragraphTransformer.transform(readDOM(tidyXhtml(wrappedText)), new StreamResult(output));
    1.33  			paragraphedText = output.toString();
    1.34  			tidyWasUsed = true;
    1.35  		}
    1.36 @@ -240,11 +239,11 @@
    1.37  		xhtmlTransformer.setParameter("wwwRead", wwwRead);
    1.38  		xhtmlTransformer.setParameter("wwwPost", wwwPost);
    1.39  		xhtmlTransformer.setParameter("headComment", String.format("Drupal-NNTP bridge. Transformed: %1$tc. Tidy had to be used: %2$b", new Date(), tidyWasUsed));
    1.40 -		StringReader input = new StringReader(paragraphedText);
    1.41 -		StringWriter output = new StringWriter(2 * paragraphedText.length());
    1.42 -		xhtmlTransformer.transform(new StreamSource(input), new StreamResult(output));
    1.43 +		StringReader paragraphedReader = new StringReader(paragraphedText);
    1.44 +		StringWriter xhtmlWriter = new StringWriter(2 * paragraphedText.length());
    1.45 +		xhtmlTransformer.transform(new StreamSource(paragraphedReader), new StreamResult(xhtmlWriter));
    1.46  
    1.47 -		return output.toString();
    1.48 +		return xhtmlWriter.toString();
    1.49  	}
    1.50  
    1.51  	/**