diff -r d566d08c20d6 -r dc04a3c2c557 src/org/sonews/storage/DrupalMessage.java --- a/src/org/sonews/storage/DrupalMessage.java Fri Oct 21 18:21:30 2011 +0200 +++ b/src/org/sonews/storage/DrupalMessage.java Sun Oct 23 23:37:39 2011 +0200 @@ -135,7 +135,7 @@ /** Plain text part */ MimeBodyPart textPart = new MimeBodyPart(); - String plainText = readPlainText(rs, xhtmlText); + String plainText = formatedToPlainText(xhtmlText); textPart.setText(plainText); //addHeader("Lines", String.valueOf(plainText.split("\n").length)); @@ -185,7 +185,11 @@ return new ByteArrayInputStream(message); } - private String readPlainText(ResultSet rs, String xhtmlText) { + /** + * @param xhtmlText well-formed XHTML + * @return plain text representation of this formated text + */ + private String formatedToPlainText(String xhtmlText) { try { Transformer textTransformer = transformerFactory.newTransformer(new StreamSource(Resource.getAsStream("helpers/mimeTextPart.xsl"))); @@ -199,7 +203,7 @@ * TODO: lepší ošetření chyby */ log.log(Level.WARNING, "Error while transforming article to plain text", e); - return makeSimpleXHTML("Při transformaci příspěvku bohužel došlo k chybě."); + return "Při transformaci příspěvku bohužel došlo k chybě."; } } @@ -499,4 +503,11 @@ throw new StorageBackendException(e); } } + + public String getBodyPlainText() throws StorageBackendException { + /** + * TODO: netransformovat XHTML 2x + */ + return formatedToPlainText(makeSimpleXHTML(getBodyXhtmlFragment())); + } }