roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1088110 - in /roller/trunk: weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
Date Sat, 02 Apr 2011 20:31:09 GMT
Author: snoopdave
Date: Sat Apr  2 20:31:09 2011
New Revision: 1088110

URL: http://svn.apache.org/viewvc?rev=1088110&view=rev
Log:
Fix for ROL-1918: switching to shared Front Page theme on Glassfish causes HTTP 500 error

https://issues.apache.org/jira/browse/ROL-1918

- Change to exception handling so errors get logged
- Better handling for files in root directory

It is possible that you'll get a 500 error if a weblog does not have a root media directory.
As far as I know, the only way that can happen is if you upgrade from 4.0 to 5.0 but do not
do the media file migration properly. 

Modified:
    roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
    roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java

Modified: roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java?rev=1088110&r1=1088109&r2=1088110&view=diff
==============================================================================
--- roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
(original)
+++ roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
Sat Apr  2 20:31:09 2011
@@ -190,6 +190,10 @@ public class ThemeManagerImpl implements
         log.debug("Importing theme [" + theme.getName() + "] to weblog [" + website.getName()
+ "]");
 
         WeblogManager wmgr = roller.getWeblogManager();
+        MediaFileManager fileMgr = roller.getMediaFileManager();
+        
+        MediaFileDirectory root = fileMgr.getMediaFileRootDirectory(website);
+        log.warn("Weblog " + website.getHandle() + " does not have a root MediaFile directory");
 
         Set importedActionTemplates = new HashSet();
         ThemeTemplate themeTemplate = null;
@@ -266,14 +270,10 @@ public class ThemeManagerImpl implements
         }
         wmgr.saveWeblog(website);
 
-
         // now lets import all the theme resources
-        MediaFileManager fileMgr = roller.getMediaFileManager();
-
         List resources = theme.getResources();
         Iterator iterat = resources.iterator();
         ThemeResource resource = null;
-        MediaFileDirectory root = fileMgr.getMediaFileRootDirectory(website);
         while (iterat.hasNext()) {
             resource = (ThemeResource) iterat.next();
 
@@ -284,7 +284,8 @@ public class ThemeManagerImpl implements
                     fileMgr.getMediaFileDirectoryByPath(website, resource.getPath());
                 if (mdir == null) {
                     log.debug("    Creating directory: " + resource.getPath());
-                    mdir = fileMgr.createMediaFileDirectory(root, resource.getPath());
+                    mdir = fileMgr.createMediaFileDirectory(
+                    	fileMgr.getMediaFileRootDirectory(website), resource.getPath());
                     roller.flush();
                 } else {
                     log.debug("    No action: directory already exists");
@@ -298,8 +299,10 @@ public class ThemeManagerImpl implements
                 String justPath = null;
 
                 if (resourcePath.indexOf("/") == -1) {
-                    mdir = root;
-
+                    mdir = fileMgr.getMediaFileRootDirectory(website);
+                    justPath = "";
+                    justName = resourcePath;
+                    
                 } else {
                     justPath = resourcePath.substring(0, resourcePath.lastIndexOf("/"));
                     if (!justPath.startsWith("/")) justPath = "/" + justPath;
@@ -329,6 +332,7 @@ public class ThemeManagerImpl implements
                 mf.setLength(resource.getLength());
 
                 log.debug("    Saving file: " + justName);
+                log.debug("    Saviving in directory = " + mf.getDirectory());
                 RollerMessages errors = new RollerMessages();
                 fileMgr.createMediaFile(website, mf, errors);
                 try {

Modified: roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java?rev=1088110&r1=1088109&r2=1088110&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
(original)
+++ roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
Sat Apr  2 20:31:09 2011
@@ -115,7 +115,7 @@ public class ThemeEdit extends UIAction 
                     ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
                     t = themeMgr.getTheme(getImportThemeId());
                     themeMgr.importTheme(getActionWeblog(), t);
-                } catch(WebloggerException re) {
+                } catch(Exception re) {
                     log.error("Error customizing theme for weblog - "+getActionWeblog().getHandle(),
re);
                     // TODO: i18n
                     addError("Error importing theme");



Mime
View raw message