roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r575971 - in /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business: FileManager.java FileManagerImpl.java themes/SharedThemeFromDir.java themes/ThemeManagerImpl.java
Date Sat, 15 Sep 2007 20:47:07 GMT
Author: snoopdave
Date: Sat Sep 15 13:47:06 2007
New Revision: 575971

URL: http://svn.apache.org/viewvc?rev=575971&view=rev
Log:
Ensure that theme files are copied, regardless of the allowed upload file-types and upload
quotas.

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManager.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManager.java?rev=575971&r1=575970&r2=575971&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManager.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManager.java
Sat Sep 15 13:47:06 2007
@@ -89,7 +89,7 @@
     
     
     /**
-     * Save a file to weblog's uploads area.
+     * Save a file to weblog's uploads area, with can-save check.
      * 
      * @param weblog The weblog we are working on.
      * @param path The relative path to the desired location within 
@@ -106,7 +106,30 @@
                          String path, 
                          String contentType, 
                          long size,
-                         InputStream is) 
+                         InputStream is)
+        throws FileNotFoundException, FilePathException, FileIOException;
+    
+    
+    /**
+     * Save a file to weblog's uploads area, with optional can-save check.
+     * 
+     * @param weblog The weblog we are working on.
+     * @param path The relative path to the desired location within 
+     * the weblog's uploads area where the file should be saved.
+     * @param contentType Content type of the file.
+     * @param size Size of file to be saved.
+     * @param is InputStream to read the file from.
+     *
+     * @throws FileNotFoundException If path to save location does not exist.
+     * @throws FilePathException If path is invalid, is not a directory, or can't be read.
+     * @throws FileIOException If there is an unexpected error during the save.
+     */
+    public void saveFile(Weblog weblog, 
+                         String path, 
+                         String contentType, 
+                         long size,
+                         InputStream is,
+                         boolean checkCanSave)
         throws FileNotFoundException, FilePathException, FileIOException;
     
     

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManagerImpl.java?rev=575971&r1=575970&r2=575971&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/FileManagerImpl.java
Sat Sep 15 13:47:06 2007
@@ -142,7 +142,21 @@
                          String path, 
                          String contentType, 
                          long size, 
-                         InputStream is)
+                         InputStream is) 
+            throws FileNotFoundException, FilePathException, FileIOException {
+        
+        saveFile(weblog, path, contentType, size, is, true);
+    }
+    
+    /**
+     * @see org.apache.roller.weblogger.model.FileManager#saveFile(weblog, java.lang.String,
java.lang.String, long, java.io.InputStream)
+     */
+    public void saveFile(Weblog weblog, 
+                         String path, 
+                         String contentType, 
+                         long size, 
+                         InputStream is,
+                         boolean checkCanSave)
             throws FileNotFoundException, FilePathException, FileIOException {
         
         String savePath = path;
@@ -152,7 +166,7 @@
         
         // make sure we are allowed to save this file
         RollerMessages msgs = new RollerMessages();
-        if (!canSave(weblog, savePath, contentType, size, msgs)) {
+        if (checkCanSave && !canSave(weblog, savePath, contentType, size, msgs))
{
             throw new FileIOException(msgs.toString());
         }
         

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java?rev=575971&r1=575970&r2=575971&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
Sat Sep 15 13:47:06 2007
@@ -213,7 +213,7 @@
         // load resource representing preview image
         File previewFile = new File(this.themeDir + File.separator + themeMetadata.getPreviewImage());
         if(!previewFile.exists() || !previewFile.canRead()) {
-            log.warn("Couldn't read preview image file ["+themeMetadata.getPreviewImage()+"]");
+            log.warn("Couldn't read theme [" + this.getName() + "] preview image file ["+themeMetadata.getPreviewImage()+"]");
         } else {
             this.previewImage = new SharedThemeResourceFromDir(themeMetadata.getPreviewImage(),
previewFile);
         }
@@ -231,7 +231,7 @@
             String contents = loadTemplateFile(templateFile);
             if(contents == null) {
                 // if we don't have any contents then skip this one
-                log.error("Couldn't load stylesheet template file ["+templateFile+"]");
+                log.error("Couldn't load stylesheet theme [" + this.getName() + "] template
file ["+templateFile+"]");
             } else {
                 
                 // construct ThemeTemplate representing this file
@@ -267,7 +267,7 @@
             
             // Continue reading theme even if problem encountered with one file
             if(!resourceFile.exists() || !resourceFile.canRead()) {
-                log.warn("Couldn't read theme resource file ["+resourcePath+"]");
+                log.warn("Couldn't read  theme [" + this.getName() + "] resource file ["+resourcePath+"]");
                 continue;
             }
             
@@ -289,7 +289,7 @@
             String contents = loadTemplateFile(templateFile);
             if(contents == null) {
                 // if we don't have any contents then skip this one
-                throw new ThemeInitializationException("Couldn't load theme template file
["+templateFile+"]");
+                throw new ThemeInitializationException("Couldn't load theme [" + this.getName()
+ "] template file ["+templateFile+"]");
             }
             
             // construct ThemeTemplate representing this file
@@ -329,7 +329,7 @@
             InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
             length = reader.read(chars);
         } catch (Exception noprob) {
-            log.error("Exception reading template file ["+templateFile+"]");
+            log.error("Exception reading theme [" + this.getName() + "] template file ["+templateFile+"]");
             if (log.isDebugEnabled())
                 log.debug(noprob);
             return null;

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java?rev=575971&r1=575970&r2=575971&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
Sat Sep 15 13:47:06 2007
@@ -277,8 +277,9 @@
                     if(resource.isDirectory()) {
                         fileMgr.createDirectory(website, resource.getPath());
                     } else {
+                        // save file without file-type, quota checks, etc.
                         fileMgr.saveFile(website, resource.getPath(), "text/plain", 
-                                resource.getLength(), resource.getInputStream());
+                                resource.getLength(), resource.getInputStream(), false);
                     }
                 } catch (Exception ex) {
                     log.info(ex);



Mime
View raw message