This is an automated email from the ASF dual-hosted git repository.
snoopdave pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/roller.git
The following commit(s) were added to refs/heads/master by this push:
new 0308b4314 Let the theme page recover a weblog whose shared theme is
not installed (#232)
0308b4314 is described below
commit 0308b431416ffc5324709e1065149049eaf0bd0c
Author: David M. Johnson <[email protected]>
AuthorDate: Sat Oct 31 18:52:33 2026 -0400
Let the theme page recover a weblog whose shared theme is not installed
(#232)
A weblog set to a shared theme that is no longer installed made the
theme page fail with a NullPointerException, so an admin could not pick
another theme. The page now says the theme is not installed and offers
the installed themes. The weblog page logs one clear line and returns
404 instead of logging a NullPointerException.
---
.../weblogger/ui/rendering/servlets/PageServlet.java | 20 ++++++++++++++++----
.../weblogger/ui/struts2/editor/ThemeEdit.java | 20 +++++++++++++++++++-
.../main/resources/ApplicationResources.properties | 4 ++++
.../main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp | 7 ++++++-
4 files changed, 45 insertions(+), 6 deletions(-)
diff --git
a/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
b/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
index 39280f494..c8092d30b 100644
---
a/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
+++
b/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
@@ -266,6 +266,18 @@ public class PageServlet extends HttpServlet {
log.debug("Looking for template to use for rendering");
+ // a weblog whose shared theme is not installed has no templates
+ WeblogTheme theme = weblog.getTheme();
+ if (theme == null) {
+ log.error("Weblog " + weblog.getHandle() + " uses theme '"
+ + weblog.getEditorTheme() + "', which is not installed");
+ if (!response.isCommitted()) {
+ response.reset();
+ }
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+
// figure out what template to use
ThemeTemplate page = null;
@@ -274,7 +286,7 @@ public class PageServlet extends HttpServlet {
if (request.getParameter("popup") != null) {
try {
// Does user have a popupcomments page?
- page = weblog.getTheme().getTemplateByName("_popupcomments");
+ page = theme.getTemplateByName("_popupcomments");
} catch (Exception e) {
// ignored ... considered page not found
}
@@ -304,7 +316,7 @@ public class PageServlet extends HttpServlet {
} else if ("tags".equals(pageRequest.getContext())
&& pageRequest.getTags() != null) {
try {
- page = weblog.getTheme().getTemplateByAction(
+ page = theme.getTemplateByAction(
ComponentType.TAGSINDEX);
} catch (Exception e) {
log.error("Error getting weblog page for action 'tagsIndex'",
e);
@@ -323,7 +335,7 @@ public class PageServlet extends HttpServlet {
// If this is a permalink then look for a permalink template
} else if (pageRequest.getWeblogAnchor() != null) {
try {
- page = weblog.getTheme().getTemplateByAction(
+ page = theme.getTemplateByAction(
ComponentType.PERMALINK);
} catch (Exception e) {
log.error("Error getting weblog page for action 'permalink'",
e);
@@ -333,7 +345,7 @@ public class PageServlet extends HttpServlet {
// if we haven't found a page yet then try our default page
if (page == null) {
try {
- page = weblog.getTheme().getDefaultTemplate();
+ page = theme.getDefaultTemplate();
} catch (Exception e) {
log.error(
"Error getting default page for weblog = "
diff --git
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
index 9318ab9c1..24787abbf 100644
---
a/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
+++
b/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
@@ -80,6 +80,11 @@ public class ThemeEdit extends UIAction {
.getThemeManager();
themes = themeMgr.getEnabledThemesList();
+ // a shared theme that is not installed has no stylesheet to check
+ if (isMissingSharedTheme()) {
+ return;
+ }
+
// See if we're using a shared theme with a custom template
try {
if (!WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme())
@@ -110,6 +115,12 @@ public class ThemeEdit extends UIAction {
setThemeId(null);
setSelectedThemeId(null);
setImportTheme(false);
+ } else if (isMissingSharedTheme()) {
+ // let the user choose an installed theme
+ addError("themeEditor.themeNotInstalled",
+ getActionWeblog().getEditorTheme());
+ setThemeId(null);
+ setSelectedThemeId(null);
} else {
setThemeId(getActionWeblog().getTheme().getId());
setSelectedThemeId(getThemeId());
@@ -188,7 +199,9 @@ public class ThemeEdit extends UIAction {
WeblogManager mgr =
WebloggerFactory.getWeblogger().getWeblogManager();
// Remove old style sheet
- if (!originalTheme.equals(selectedThemeId) &&
getActionWeblog().getTheme().getStylesheet() != null) {
+ WeblogTheme currentTheme = getActionWeblog().getTheme();
+ if (!originalTheme.equals(selectedThemeId) && currentTheme
!= null
+ && currentTheme.getStylesheet() != null) {
WeblogTemplate stylesheet =
mgr.getTemplateByAction(getActionWeblog(),
ComponentType.STYLESHEET);
@@ -231,6 +244,11 @@ public class ThemeEdit extends UIAction {
return (WeblogTheme.CUSTOM.equals(getActionWeblog().getEditorTheme()));
}
+ // is the weblog set to a shared theme that is not installed?
+ private boolean isMissingSharedTheme() {
+ return !isCustomTheme() && getActionWeblog().getTheme() == null;
+ }
+
// has this weblog had a custom theme before?
public boolean isFirstCustomization() {
try {
diff --git a/app/src/main/resources/ApplicationResources.properties
b/app/src/main/resources/ApplicationResources.properties
index 38ca7a7d7..8aa834400 100644
--- a/app/src/main/resources/ApplicationResources.properties
+++ b/app/src/main/resources/ApplicationResources.properties
@@ -1307,9 +1307,13 @@ bloggers who want to be able to create a blog design of
their own. \
Beware though, managing a blog design of your own takes a bit of effort.
themeEditor.yourCurrentTheme=Your current theme is
+
themeEditor.yourCustomStylesheet=using <em style="color:red">custom</em>
override stylesheet.
themeEditor.yourThemeStyleSheet=using the <em>Shared Theme</em> default
stylesheet.
+themeEditor.themeNotInstalled=This weblog uses the theme {0}, which is not
installed. \
+ Choose another theme and select Update Theme.
+
themeEditor.youAreUsingACustomTheme=This weblog is using a custom theme.
themeEditor.thisTheme=This theme:
diff --git a/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
b/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
index 5314d8166..865d6ae16 100644
--- a/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
@@ -194,7 +194,12 @@
<s:else>
originalType = "shared"
updateView($('#sharedRadio'));
- previewImage('<s:property value="themeId"/>');
+ if (originalThemeId === "") {
+ // the weblog's theme is not installed, so propose the selected one
+ proposeSharedThemeChange($('#themeSelector').val());
+ } else {
+ previewImage(originalThemeId);
+ }
</s:else>
});