svn commit: r647552 - /lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java
[email protected] Sun, 13 Apr 2008 09:53:07 -0000
Newsgroups
gmane.comp.cms.lenya.cvs
Message-ID
<[email protected] >
Author: andreas
Date: Sun Apr 13 02:53:06 2008
New Revision: 647552
URL: http://svn.apache.org/viewvc?rev=647552&view=rev
Log:
Handling case that ImageIO.read returns null.
Modified:
lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java
Modified: lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java?rev=647552&r1=647551&r2=647552&view=diff
==============================================================================
--- lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java (original)
+++ lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java Sun Apr 13 02:53:06 2008
@@ -167,7 +167,8 @@
public void updateImageDimensions() {
Document doc = getDocument();
try {
- updateImageDimensions(doc.getMimeType(), doc.getInputStream(), doc.getMetaData(MEDIA_METADATA_NAMESPACE));
+ updateImageDimensions(doc.getMimeType(), doc.getInputStream(), doc.getMetaData(MEDIA_METADATA_NAMESPACE),
+ doc.toString() + " (" + doc.getPath() + ")");
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -179,17 +180,22 @@
if (customMeta != null) {
customMeta.setValue("filename", fileName);
}
- updateImageDimensions(mimeType, stream, customMeta);
+ updateImageDimensions(mimeType, stream, customMeta, fileName);
}
- protected void updateImageDimensions(String mimeType, InputStream stream, MetaData customMeta)
+ protected void updateImageDimensions(String mimeType, InputStream stream, MetaData customMeta, String logInfo)
throws IOException, MetaDataException {
if (canReadMimeType(mimeType)) {
BufferedImage input = ImageIO.read(stream);
- String width = Integer.toString(input.getWidth());
- String height = Integer.toString(input.getHeight());
- customMeta.setValue("height", height);
- customMeta.setValue("width", width);
+ if (input == null) {
+ getLogger().warn("Couln't read image information from [" + logInfo + "].");
+ }
+ else {
+ String width = Integer.toString(input.getWidth());
+ String height = Integer.toString(input.getHeight());
+ customMeta.setValue("height", height);
+ customMeta.setValue("width", width);
+ }
}
}