You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2005/08/30 22:41:11 UTC
svn commit: r264853 - in /incubator/roller/branches/roller_2.0:
metadata/xdoclet/ src/org/roller/presentation/weblog/actions/
src/org/roller/presentation/website/actions/ web/ web/WEB-INF/classes/
Author: snoopdave
Date: Tue Aug 30 13:40:56 2005
New Revision: 264853
URL: http://svn.apache.org/viewcvs?rev=264853&view=rev
Log:
Better error message for entry not found
Modified:
incubator/roller/branches/roller_2.0/metadata/xdoclet/global-forwards.xml
incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties
incubator/roller/branches/roller_2.0/web/errorBody.jsp
Modified: incubator/roller/branches/roller_2.0/metadata/xdoclet/global-forwards.xml
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/metadata/xdoclet/global-forwards.xml?rev=264853&r1=264852&r2=264853&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/metadata/xdoclet/global-forwards.xml (original)
+++ incubator/roller/branches/roller_2.0/metadata/xdoclet/global-forwards.xml Tue Aug 30 13:40:56 2005
@@ -1,6 +1,6 @@
<global-forwards>
<forward name="access-denied" path=".denied"/>
-<forward name="error" path=".error"/>
+<forward name="error" path="/error.jsp"/>
<forward name="login-redirect" path="/login-redirect.jsp"/>
<forward name="logout-redirect" path="/logout-redirect.jsp"/>
Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java?rev=264853&r1=264852&r2=264853&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java Tue Aug 30 13:40:56 2005
@@ -149,8 +149,15 @@
{
entry = wmgr.retrieveWeblogEntry(form.getId());
}
-
- if (rses.isUserAuthorizedToAuthor(entry.getWebsite())
+ if (entry == null)
+ {
+ ResourceBundle resources = ResourceBundle.getBundle(
+ "ApplicationResources", request.getLocale());
+ request.setAttribute("javax.servlet.error.message",
+ resources.getString("weblogEntry.notFound"));
+ forward = mapping.findForward("error");
+ }
+ else if (rses.isUserAuthorizedToAuthor(entry.getWebsite())
|| (rses.isUserAuthorized(entry.getWebsite()) && entry.isDraft()))
{
form.copyFrom(entry, request.getLocale());
@@ -421,8 +428,7 @@
+ "/editor/weblog.do?method=edit&entryid=" + entry.getId();
ResourceBundle resources = ResourceBundle.getBundle(
- "ApplicationResources",
- entry.getWebsite().getLocaleInstance());
+ "ApplicationResources", request.getLocale());
StringBuffer sb = new StringBuffer();
sb.append(
MessageFormat.format(
@@ -555,9 +561,11 @@
wf.copyFrom(wd, request.getLocale());
if (wd == null || wd.getId() == null)
{
- throw new NullPointerException(
- "Unable to find WeblogEntry for " +
- request.getParameter(RollerRequest.WEBLOGENTRYID_KEY));
+ ResourceBundle resources = ResourceBundle.getBundle(
+ "ApplicationResources", request.getLocale());
+ request.setAttribute("javax.servlet.error.message",
+ resources.getString("weblogEntry.notFound"));
+ forward = mapping.findForward("error");
}
}
else
@@ -763,52 +771,57 @@
{
if (wd == null || wd.getId() == null)
{
- throw new NullPointerException(
- "Unable to find WeblogEntry for "+
- request.getParameter(RollerRequest.WEBLOGENTRYID_KEY));
+ ResourceBundle resources = ResourceBundle.getBundle(
+ "ApplicationResources", request.getLocale());
+ request.setAttribute("javax.servlet.error.message",
+ resources.getString("weblogEntry.notFound"));
+ forward = mapping.findForward("error");
}
- WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
-
- // If form indicates that comments should be deleted, delete
- WeblogManager mgr= RollerFactory.getRoller().getWeblogManager();
- String[] deleteIds = form.getDeleteComments();
- if (deleteIds != null && deleteIds.length > 0)
+ else
{
- mgr.removeComments( deleteIds );
- }
+ WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
- List comments = mgr.getComments(wd.getId(), false); // spam too
- if (form.getSpamComments() != null)
- {
- // comments marked as spam
- List spamIds = Arrays.asList(form.getSpamComments());
+ // If form indicates that comments should be deleted, delete
+ WeblogManager mgr= RollerFactory.getRoller().getWeblogManager();
+ String[] deleteIds = form.getDeleteComments();
+ if (deleteIds != null && deleteIds.length > 0)
+ {
+ mgr.removeComments( deleteIds );
+ }
- // iterate over all comments, check each to see if
- // is in the spamIds list. If so, mark it as spam.
- Iterator it = comments.iterator();
- while (it.hasNext())
+ List comments = mgr.getComments(wd.getId(), false); // spam too
+ if (form.getSpamComments() != null)
{
- CommentData comment = (CommentData)it.next();
- if (spamIds.contains(comment.getId()))
- {
- comment.setSpam(Boolean.TRUE);
- }
- else
+ // comments marked as spam
+ List spamIds = Arrays.asList(form.getSpamComments());
+
+ // iterate over all comments, check each to see if
+ // is in the spamIds list. If so, mark it as spam.
+ Iterator it = comments.iterator();
+ while (it.hasNext())
{
- comment.setSpam(Boolean.FALSE);
+ CommentData comment = (CommentData)it.next();
+ if (spamIds.contains(comment.getId()))
+ {
+ comment.setSpam(Boolean.TRUE);
+ }
+ else
+ {
+ comment.setSpam(Boolean.FALSE);
+ }
+ comment.save();
}
- comment.save();
}
- }
- RollerFactory.getRoller().commit();
-
- reindexEntry(RollerFactory.getRoller(), wd);
-
- request.setAttribute("model",
- new WeblogEntryPageModel(request, response, mapping,
- (WeblogEntryFormEx)actionForm,
- WeblogEntryPageModel.EDIT_MODE));
+ RollerFactory.getRoller().commit();
+
+ reindexEntry(RollerFactory.getRoller(), wd);
+
+ request.setAttribute("model",
+ new WeblogEntryPageModel(request, response, mapping,
+ (WeblogEntryFormEx)actionForm,
+ WeblogEntryPageModel.EDIT_MODE));
+ }
}
else
{
Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java?rev=264853&r1=264852&r2=264853&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/CommonPingTargetsAction.java Tue Aug 30 13:40:56 2005
@@ -16,6 +16,7 @@
import org.roller.model.PingTargetManager;
import org.roller.model.RollerFactory;
import org.roller.pojos.PingTargetData;
+import org.roller.pojos.WebsiteData;
import org.roller.presentation.RollerRequest;
import org.roller.presentation.RollerSession;
import org.roller.presentation.forms.PingTargetForm;
@@ -76,10 +77,11 @@
/*
* Check if request carries admin rights.
*/
- protected boolean hasRequiredRights(RollerRequest rreq) throws RollerException
+ protected boolean hasRequiredRights(
+ RollerRequest rreq, WebsiteData website) throws RollerException
{
- // This mimics the check in other admin actions, but not sure why the latter is not sufficient.
- RollerSession rollerSession = RollerSession.getRollerSession(rreq.getRequest());
+ RollerSession rollerSession =
+ RollerSession.getRollerSession(rreq.getRequest());
return rollerSession.isGlobalAdminUser();
}
}
Modified: incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties?rev=264853&r1=264852&r2=264853&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/branches/roller_2.0/web/WEB-INF/classes/ApplicationResources.properties Tue Aug 30 13:40:56 2005
@@ -1125,6 +1125,8 @@
Link to edit the pending post:\
<{2}>
+weblogEntry.notFound=Cannot find requested weblog entry
+
weblogEdit.actionCol=Actions
weblogEdit.autoformat=Autoformat
weblogEdit.calendarTitle=Weblog Entry Archive
Modified: incubator/roller/branches/roller_2.0/web/errorBody.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/errorBody.jsp?rev=264853&r1=264852&r2=264853&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/errorBody.jsp (original)
+++ incubator/roller/branches/roller_2.0/web/errorBody.jsp Tue Aug 30 13:40:56 2005
@@ -1,6 +1,3 @@
- <%@ page import="org.roller.model.Roller" %>
-<%@ page import="org.roller.pojos.UserData" %>
-<%@ page import="org.roller.presentation.RollerRequest" %>
<%@ include file="/taglibs.jsp" %>
<%@ page import="java.io.*,org.roller.util.Utilities" isErrorPage="true" %>
@@ -10,23 +7,29 @@
java.util.ResourceBundle.getBundle("ApplicationResources",locale);
final Object codeObj, messageObj, typeObj, exceptionObj;
-codeObj = request.getAttribute("javax.servlet.error.status_code");
+codeObj = request.getAttribute("javax.servlet.error.status_code");
messageObj = request.getAttribute("javax.servlet.error.message");
-typeObj = request.getAttribute("javax.servlet.error.type");
+typeObj = request.getAttribute("javax.servlet.error.type");
String code=null, message=null, type=null;
if ( null != codeObj ) code = codeObj.toString();
if ( null != messageObj ) message = messageObj.toString();
if ( null != typeObj ) type = typeObj.toString();
+
String reason = null != code ? code : type;
exception = (Throwable)request.getAttribute("javax.servlet.error.exception");
%>
<h2 class="error"><fmt:message key="errorPage.title" /></h2>
-<p><fmt:message key="errorPage.message" /></p>
+
<p><%= message %></p>
+
+<% if ( null != reason )
+{ %>
<p><b><fmt:message key="errorPage.reason" /></b>: <%= reason %></p>
+<% } %>
+
<% if ( null != exception )
{ %>
<form><textarea rows="30" style="font-size:8pt;width:95%">