| 304 |
Converter converter = (Converter) obj; |
Converter converter = (Converter) obj; |
| 305 |
if (converter.getFormatType().equals(getFormattype())) |
if (converter.getFormatType().equals(getFormattype())) |
| 306 |
{ |
{ |
| 307 |
StringBuffer buffer = new StringBuffer(); |
String formattedMessage = converter.convert(getMessage()); |
| 308 |
try |
if (formattedMessage == null) |
| 309 |
{ |
{ |
|
StreamStorage storage; |
|
|
try |
|
|
{ |
|
|
storage = new ByteArrayStreamStorageImpl( |
|
|
new ByteArrayInputStream(getMessage() |
|
|
.getBytes(BlogConstants.UTF_8)), |
|
|
BlogConstants.UTF_8); |
|
|
} |
|
|
catch (UnsupportedEncodingException e1) |
|
|
{ |
|
|
log.warn("Unsupported encoding. ", e1); |
|
|
storage = new ByteArrayStreamStorageImpl( |
|
|
new ByteArrayInputStream(getMessage() |
|
|
.getBytes()), BlogConstants.UTF_8); |
|
|
} |
|
|
converter.getConverter().invoke(storage); |
|
|
|
|
|
BufferedReader r = null; |
|
|
try |
|
|
{ |
|
|
r = new BufferedReader(new InputStreamReader( |
|
|
storage.getResultInputStream(), storage |
|
|
.getEncoding())); |
|
|
String l = null; |
|
|
while ((l = r.readLine()) != null) |
|
|
{ |
|
|
buffer.append(l); |
|
|
buffer.append("\n"); |
|
|
} |
|
|
} |
|
|
catch (UnsupportedEncodingException e) |
|
|
{ |
|
|
log.warn("Unsupported Encoding. ", e); |
|
|
} |
|
|
catch (StreamStorageException e) |
|
|
{ |
|
|
log.warn("Stream Storage Exception. ", e); |
|
|
} |
|
|
catch (IOException e) |
|
|
{ |
|
|
log.error("I/O Exception. ", e); |
|
|
} |
|
|
finally |
|
|
{ |
|
|
if (r != null) |
|
|
{ |
|
|
try |
|
|
{ |
|
|
r.close(); |
|
|
} |
|
|
catch (IOException e) |
|
|
{ |
|
|
} |
|
|
} |
|
|
} |
|
|
storage.destroy(); |
|
|
return buffer.toString(); |
|
|
} |
|
|
catch (StreamStorageException e) |
|
|
{ |
|
|
log.error("StreamStorage Exception.", e); |
|
|
return getMessage(); |
|
|
} |
|
|
catch (PipelineException e) |
|
|
{ |
|
|
log.error("Pipeline Exception.", e); |
|
| 310 |
return getMessage(); |
return getMessage(); |
| 311 |
} |
} |
| 312 |
|
return formattedMessage; |
| 313 |
} |
} |
| 314 |
} |
} |
| 315 |
else |
else |