roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r263878 - in /incubator/roller/branches/roller_2.0: src/org/roller/presentation/website/actions/ src/org/roller/presentation/website/tags/ web/website/
Date Sun, 28 Aug 2005 14:24:20 GMT
Author: snoopdave
Date: Sun Aug 28 07:24:14 2005
New Revision: 263878

URL: http://svn.apache.org/viewcvs?rev=263878&view=rev
Log:
Fixed current-website related  bugs in file upload and theme editor

Modified:
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UploadFileFormAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileManagerTag.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileUploadTag.java
    incubator/roller/branches/roller_2.0/web/website/theme-editor.jsp
    incubator/roller/branches/roller_2.0/web/website/upload-file.jsp

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UploadFileFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UploadFileFormAction.java?rev=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UploadFileFormAction.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UploadFileFormAction.java
Sun Aug 28 07:24:14 2005
@@ -22,6 +22,7 @@
 import org.roller.RollerException;
 import org.roller.config.RollerRuntimeConfig;
 import org.roller.model.FileManager;
+import org.roller.model.Roller;
 import org.roller.model.RollerFactory;
 import org.roller.pojos.WebsiteData;
 import org.roller.presentation.BasePageModel;
@@ -40,6 +41,7 @@
  */
 public final class UploadFileFormAction extends DispatchAction
 {
+    private static final String HANDLE = "fileupload.website.handle";
     private static Log mLogger = 
         LogFactory.getFactory().getInstance(UploadFileFormAction.class);
 
@@ -53,19 +55,19 @@
         HttpServletResponse response)
         throws IOException, ServletException
     {
-        RollerRequest rreq = null;
         ActionForward fwd = mapping.findForward("uploadFiles.page");
-        WebsiteData website = website = rreq.getWebsite();;
-        BasePageModel pageModel = 
-            new BasePageModel("uploadFiles.title", request, response, mapping);
+        WebsiteData website = getWebsite(request);
+        
+        BasePageModel pageModel = new BasePageModel(
+                "uploadFiles.title", request, response, mapping);
         request.setAttribute("model", pageModel);
+        pageModel.setWebsite(website);
+                
         RollerMessages msgs = new RollerMessages();
         try
-        {
-            rreq = RollerRequest.getRollerRequest(request);
-            RollerSession rollerSession = RollerSession.getRollerSession(request);
-            
-            if ( !rollerSession.isUserAuthorizedToAuthor(website) )
+        {            
+            RollerSession rses = RollerSession.getRollerSession(request);            
+            if ( !rses.isUserAuthorizedToAuthor(website) )
             {
                 return mapping.findForward("access-denied");
             }
@@ -165,14 +167,16 @@
         ActionErrors errors = new ActionErrors();
         UploadFileForm theForm = (UploadFileForm)actionForm;
         ActionForward fwd = mapping.findForward("uploadFiles.page");
-        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        
+        WebsiteData website = getWebsite(request);
         BasePageModel pageModel = 
             new BasePageModel("uploadFiles.title", request, response, mapping);
+        pageModel.setWebsite(website);
         request.setAttribute("model", pageModel);
+
         try
         {
             FileManager fmgr = RollerFactory.getRoller().getFileManager();
-            WebsiteData website = rreq.getWebsite();
             String[] deleteFiles = theForm.getDeleteFiles();
             for (int i=0; i<deleteFiles.length; i++)
             {
@@ -210,13 +214,15 @@
     {       
         try
         {
-            RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            RollerSession rollerSession = RollerSession.getRollerSession(request);
-            BasePageModel pageModel = 
-             new BasePageModel("uploadFiles.title", request, response, mapping);
+            WebsiteData website = getWebsite(request);
+            
+            BasePageModel pageModel = new BasePageModel(
+                "uploadFiles.title", request, response, mapping);
+            pageModel.setWebsite(website);
             request.setAttribute("model", pageModel);
-            WebsiteData website = rreq.getWebsite();
-            if ( !rollerSession.isUserAuthorizedToAuthor(website) )
+            
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if ( !rses.isUserAuthorizedToAuthor(website) )
             {
                 return mapping.findForward("access-denied");
             }
@@ -229,5 +235,34 @@
         return mapping.findForward("uploadFiles.page"); 
     }
 
+    /** 
+     * Other actions can get the website handle from request params, but 
+     * request params don't come accross in a file-upload post so we have to 
+     * stash the website handle in the session.
+     */
+    public static WebsiteData getWebsite(HttpServletRequest request) 
+        throws ServletException
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WebsiteData website = rreq.getWebsite();
+        if (website != null) 
+        {
+            request.getSession().setAttribute(HANDLE, website.getHandle());
+        }
+        else 
+        {
+            String handle = (String)request.getSession().getAttribute(HANDLE);
+            Roller roller = RollerFactory.getRoller();
+            try 
+            {
+                website = roller.getUserManager().getWebsiteByHandle(handle);
+            }
+            catch (RollerException e)
+            {
+                throw new ServletException(e);
+            }
+        }
+        return website;
+    }
 }
 

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileManagerTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileManagerTag.java?rev=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileManagerTag.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileManagerTag.java
Sun Aug 28 07:24:14 2005
@@ -18,7 +18,8 @@
 import org.roller.pojos.WebsiteData;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
-import org.roller.presentation.RollerSession;
+import org.roller.presentation.website.actions.UploadFileFormAction;
+
 
 /**
  * @jsp.tag name="FileManager"
@@ -51,7 +52,7 @@
             HttpServletRequest request =
                 (HttpServletRequest)pageContext.getRequest();
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            WebsiteData website = rreq.getWebsite();
+            WebsiteData website = UploadFileFormAction.getWebsite(request);
 
             // for formatting the file size
             DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
@@ -87,7 +88,7 @@
                     // to PRIMARY
                     java.text.Collator locCollator =
                         java.text.Collator.getInstance(
-                            rreq.getWebsite().getLocaleInstance());
+                            website.getLocaleInstance());
                     locCollator.setStrength(Collator.PRIMARY);
                     java.util.Arrays.sort(files, locCollator);
 

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileUploadTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileUploadTag.java?rev=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileUploadTag.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/tags/FileUploadTag.java
Sun Aug 28 07:24:14 2005
@@ -23,7 +23,7 @@
 import org.roller.model.RollerFactory;
 import org.roller.pojos.WebsiteData;
 import org.roller.presentation.RollerRequest;
-import org.roller.presentation.RollerSession;
+import org.roller.presentation.website.actions.UploadFileFormAction;
 
 /**
  * @jsp.tag name="FileUpload"
@@ -59,7 +59,7 @@
             HttpServletRequest request =
                 (HttpServletRequest)pageContext.getRequest();
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            WebsiteData website = rreq.getWebsite();
+            WebsiteData website = UploadFileFormAction.getWebsite(request);
             
             String maxDir = RollerRuntimeConfig.getProperty("uploads.dir.maxsize");
             String maxFile = RollerRuntimeConfig.getProperty("uploads.file.maxsize");
@@ -118,6 +118,8 @@
                 pw.println("<input type=\"submit\" value=\""
                     +bundle.getString("uploadFiles.upload")+"\" />");
                 pw.println("<input type=\"hidden\" name=\"method\" value=\"upload\" /><br
/><br />");
+                pw.println("<input type=\"hidden\" name=\"weblog\" value=\"" 
+                        + website.getHandle() + "\" /><br /><br />");
                 pw.println(MessageFormat.format(
                     bundle.getString("uploadFiles.quotaNote"),
                     new String[] {maxFileMB.toString(), maxDirMB.toString()}));

Modified: incubator/roller/branches/roller_2.0/web/website/theme-editor.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/website/theme-editor.jsp?rev=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/website/theme-editor.jsp (original)
+++ incubator/roller/branches/roller_2.0/web/website/theme-editor.jsp Sun Aug 28 07:24:14
2005
@@ -27,6 +27,7 @@
 
 <form action="themeEditor.do" method="post">
 
+    <input type=hidden name="weblog" value='<c:out value="${model.website.handle}"
/>' />
     <input type=hidden name="method" value="preview" />
 
     <table width="95%">

Modified: incubator/roller/branches/roller_2.0/web/website/upload-file.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/website/upload-file.jsp?rev=263878&r1=263877&r2=263878&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/website/upload-file.jsp (original)
+++ incubator/roller/branches/roller_2.0/web/website/upload-file.jsp Sun Aug 28 07:24:14 2005
@@ -26,6 +26,7 @@
           </td>
        </tr>
     </table>
+    <input type=hidden name="weblog" value='<c:out value="${model.website.handle}"
/>' />
     <input type="hidden" name="method" value="delete"></input>
 </html:form>
 



Mime
View raw message