svn commit: r635288 - /lenya/trunk/src/modules/resource/java/src/org/apache/lenya/cms/publication/ResourceWrapper.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Sun Mar  9 10:08:14 2008
New Revision: 635288

URL: http://svn.apache.org/viewvc?rev=635288&view=rev
Log:
Update extension when uploading new resource.

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=635288&r1=635287&r2=635288&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 Mar  9 10:08:14 2008
@@ -146,8 +146,8 @@
 
             destOutputStream = document.getOutputStream();
             IOUtils.write(sourceBos.toByteArray(), destOutputStream);
-
             document.setMimeType(mimeType);
+            document.setSourceExtension(getSourceExtension(fileName));
 
         } finally {
             if (destOutputStream != null) {
@@ -198,4 +198,16 @@
         }
         return mimeType;
     }
+
+    protected String getSourceExtension(String fileName) {
+        String extension = "";
+        int lastDotIndex = fileName.lastIndexOf(".");
+        if (lastDotIndex > -1) {
+            extension = fileName.substring(lastDotIndex + 1);
+        } else {
+            getLogger().warn("Can't determine extension from file name [" + fileName + "].");
+        }
+        return extension.toLowerCase();
+    }
+
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.