src/org/sonews/storage/DrupalMessage.java
changeset 106 dc04a3c2c557
parent 105 d566d08c20d6
child 109 03cc47e9daee
     1.1 --- a/src/org/sonews/storage/DrupalMessage.java	Fri Oct 21 18:21:30 2011 +0200
     1.2 +++ b/src/org/sonews/storage/DrupalMessage.java	Sun Oct 23 23:37:39 2011 +0200
     1.3 @@ -135,7 +135,7 @@
     1.4  
     1.5  			/** Plain text part */
     1.6  			MimeBodyPart textPart = new MimeBodyPart();
     1.7 -			String plainText = readPlainText(rs, xhtmlText);
     1.8 +			String plainText = formatedToPlainText(xhtmlText);
     1.9  			textPart.setText(plainText);
    1.10  			//addHeader("Lines", String.valueOf(plainText.split("\n").length));
    1.11  
    1.12 @@ -185,7 +185,11 @@
    1.13  		return new ByteArrayInputStream(message);
    1.14  	}
    1.15  
    1.16 -	private String readPlainText(ResultSet rs, String xhtmlText) {
    1.17 +	/**
    1.18 +	 * @param xhtmlText well-formed XHTML
    1.19 +	 * @return plain text representation of this formated text
    1.20 +	 */
    1.21 +	private String formatedToPlainText(String xhtmlText) {
    1.22  		try {
    1.23  			Transformer textTransformer = transformerFactory.newTransformer(new StreamSource(Resource.getAsStream("helpers/mimeTextPart.xsl")));
    1.24  
    1.25 @@ -199,7 +203,7 @@
    1.26  			 * TODO: lepší ošetření chyby
    1.27  			 */
    1.28  			log.log(Level.WARNING, "Error while transforming article to plain text", e);
    1.29 -			return makeSimpleXHTML("Při transformaci příspěvku bohužel došlo k chybě.");
    1.30 +			return "Při transformaci příspěvku bohužel došlo k chybě.";
    1.31  		}
    1.32  	}
    1.33  
    1.34 @@ -499,4 +503,11 @@
    1.35  			throw new StorageBackendException(e);
    1.36  		}
    1.37  	}
    1.38 +	
    1.39 +	public String getBodyPlainText() throws StorageBackendException {
    1.40 +		/**
    1.41 +		 * TODO: netransformovat XHTML 2x
    1.42 +		 */
    1.43 +		return formatedToPlainText(makeSimpleXHTML(getBodyXhtmlFragment()));
    1.44 +	}
    1.45  }