roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r398712 [29/32] - in /incubator/roller/trunk/src/org/apache: ./ roller/ roller/business/ roller/business/hibernate/ roller/business/referrers/ roller/business/runnable/ roller/business/search/ roller/business/search/operations/ roller/busin...
Date Mon, 01 May 2006 22:23:34 GMT
Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/UserNewAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/UserNewAction.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/UserNewAction.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/UserNewAction.java Mon May  1 15:23:02 2006
@@ -0,0 +1,228 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.presentation.website.actions;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerRuntimeConfig;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerContext;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.website.formbeans.UserFormEx;
+import org.apache.roller.util.StringUtils;
+
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * Actions for creating a new user.
+ * 
+ * @struts.action name="userFormEx" path="/user" 
+ * 		scope="session" parameter="method"
+ * 
+ * @struts.action-forward name="registerUser.page" path=".UserNew"
+ * @struts.action-forward name="welcome.page" path=".welcome"
+ */
+public class UserNewAction extends UserBaseAction
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(UserNewAction.class);
+
+    //------------------------------------------------------------------------
+    /** Process GET of new user page (allows admin to create a user) */
+    public ActionForward createUser(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        UserFormEx userForm = (UserFormEx)actionForm;
+        userForm.setAdminCreated(true);
+        return registerUser(mapping, actionForm, request, response);
+    }
+    
+    public ActionForward cancel(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        return mapping.findForward("main");
+    }
+    
+    //------------------------------------------------------------------------
+    /** Process GET of user registration page (allows users to register themselves). */
+    public ActionForward registerUser(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("registerUser.page");
+        ActionErrors errors = new ActionErrors();
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        try
+        {
+            UserFormEx userForm = (UserFormEx)actionForm;
+            
+            userForm.setLocale(Locale.getDefault().toString());
+            userForm.setTimeZone(TimeZone.getDefault().getID());
+            
+            userForm.setPasswordText(null);
+            userForm.setPasswordConfirm(null);            
+            request.setAttribute("model", new BasePageModel(
+                    "newUser.addNewUser", request, response, mapping));
+        }
+        catch (Exception e)
+        {
+            errors.add(ActionErrors.GLOBAL_ERROR,
+                new ActionError("error.editing.user", e.toString()));
+            mLogger.error("ERROR in newUser", e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    /** Process POST of new user information. */
+    public ActionForward add(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        UserFormEx form = (UserFormEx)actionForm;
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        ServletContext ctx = rreq.getServletContext();
+        RollerContext rollerContext = RollerContext.getRollerContext();
+
+        boolean reg_allowed = 
+                RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
+
+        if ( !reg_allowed && !request.isUserInRole("admin"))
+        {
+            throw new ServletException("New users disabled!");
+        }
+
+        ActionMessages msgs = new ActionMessages();
+        ActionMessages errors = validate(form, new ActionErrors());
+        if (!errors.isEmpty())
+        {
+            saveErrors(request, errors);
+        }
+        else try
+        {
+            // Add new user
+            UserManager mgr = RollerFactory.getRoller().getUserManager(); 
+
+            UserData ud = new UserData();
+            form.copyTo(ud, request.getLocale()); // doesn't copy password
+            ud.setId(null);
+            ud.setDateCreated(new java.util.Date());
+            ud.setEnabled(Boolean.TRUE);
+
+            // If user set both password and passwordConfirm then reset password
+            if (    !StringUtils.isEmpty(form.getPasswordText()) 
+                 && !StringUtils.isEmpty(form.getPasswordConfirm()))
+            {
+               ud.resetPassword(RollerFactory.getRoller(), 
+                  form.getPasswordText(), form.getPasswordConfirm());
+            }
+            
+            // save new user
+            mgr.addUser(ud);
+            RollerFactory.getRoller().flush();
+            
+            if (form.getAdminCreated()) 
+            {
+                // User created for admin, so return to new user page with empty form
+                msgs.add(ActionMessages.GLOBAL_MESSAGE, 
+                    new ActionMessage("newUser.created"));
+                saveMessages(request, msgs);
+                form.reset(mapping, request);
+                return createUser(mapping, actionForm, request, response);
+            }
+            else 
+            {
+                // User registered, so go to welcome page
+                String weblogURL = rollerContext.getAbsoluteContextUrl(request)
+                                 + "/page/"+ud.getUserName();
+                request.setAttribute("weblogURL",weblogURL);   
+                String rssURL = rollerContext.getAbsoluteContextUrl(request)
+                              + "/rss/"+ud.getUserName();
+                request.setAttribute("rssURL",rssURL);  
+                request.setAttribute("contextURL", 
+                                 rollerContext.getAbsoluteContextUrl(request));
+                return mapping.findForward("welcome.page");
+            }
+        }
+        catch (RollerException e)
+        {
+            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(e.getMessage()));
+            saveErrors(request,errors);          
+            mLogger.error("ERROR in addUser", e);
+            form.setUserName("");
+        }
+
+        if (form.getAdminCreated()) 
+        {
+            return mapping.findForward("createUser");
+        }
+        else 
+        {
+            // Error occured, send user back to new user form
+            return mapping.findForward("registerUser");
+        }
+    }
+
+    //------------------------------------------------------------------------
+    /** Validate user form. TODO: replace with Struts validation. */
+    protected ActionMessages validate( UserFormEx form, ActionMessages errors ) {
+        super.validate(form, errors);
+        if (    StringUtils.isEmpty(form.getPasswordText())
+             && StringUtils.isEmpty(form.getPasswordConfirm()))
+        {
+            errors.add( ActionErrors.GLOBAL_ERROR,
+               new ActionError("error.add.user.missingPassword"));
+        }
+        return errors;
+    }
+}
\ No newline at end of file

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WeblogTemplateFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WeblogTemplateFormAction.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WeblogTemplateFormAction.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WeblogTemplateFormAction.java Mon May  1 15:23:02 2006
@@ -0,0 +1,441 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.presentation.website.actions;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.actions.DispatchAction;
+import org.apache.roller.RollerException;
+import org.apache.roller.RollerPermissionsException;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.WeblogTemplate;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.RollerSession;
+import org.apache.roller.presentation.cache.CacheManager;
+import org.apache.roller.presentation.forms.WeblogTemplateForm;
+import org.apache.roller.util.StringUtils;
+import org.apache.roller.util.Utilities;
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * Page form action.
+ * @struts.action name="weblogTemplateForm" path="/editor/page"
+ *  	scope="session" parameter="method"
+ * 
+ * @struts.action-forward name="removePage.page" path=".remove-page"
+ * @struts.action-forward name="editPage.page" path=".edit-page"
+ * @struts.action-forward name="editPages.page" path=".edit-pages"
+ */
+public final class WeblogTemplateFormAction extends DispatchAction
+{
+    private static Log mLogger = 
+        LogFactory.getFactory().getInstance(WeblogTemplateFormAction.class);
+        
+    public ActionForward add(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("editPages.page");
+        try
+        {
+            request.setAttribute("model", new BasePageModel(
+                "pagesForm.title", request, response, mapping));   
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            RollerSession rses = RollerSession.getRollerSession(request);
+            WebsiteData website = rreq.getWebsite();
+            if ( rses.isUserAuthorizedToAdmin(website) )
+            {
+                WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
+                WeblogTemplate data = new WeblogTemplate();
+                form.copyTo(data, request.getLocale());
+                data.setWebsite(website);
+                data.setLastModified( new java.util.Date() );
+                data.setDescription("");
+                data.setContents("");
+                validateLink( data );
+
+                UserManager mgr = RollerFactory.getRoller().getUserManager();
+                mgr.savePage( data );
+                RollerFactory.getRoller().flush();
+                
+                ActionMessages uiMessages = new ActionMessages();
+                uiMessages.add(ActionMessages.GLOBAL_MESSAGE, 
+                        new ActionMessage("pagesForm.addNewPage.success", 
+                                data.getName()));
+                saveMessages(request, uiMessages);
+                    
+                actionForm.reset(mapping,request);                
+                
+                addModelObjects(request, response, mapping, website);
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    public ActionForward edit(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("editPage.page");
+        try
+        {            
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WeblogTemplate pd = (WeblogTemplate)rreq.getPage();
+            
+            RollerSession rses = RollerSession.getRollerSession(request);            
+            if ( rses.isUserAuthorizedToAdmin(pd.getWebsite()) )
+            {
+                BasePageModel pageModel = new BasePageModel(
+                    "pageForm.title", request, response, mapping);
+                pageModel.setWebsite(pd.getWebsite());
+                request.setAttribute("model", pageModel); 
+                
+                WeblogTemplateForm pf = (WeblogTemplateForm)actionForm;
+                pf.copyFrom(pd, request.getLocale());
+                
+                addModelObjects(request, response, mapping, pd.getWebsite());
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    public ActionForward editPages(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("editPages.page");
+        try
+        {
+            WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            RollerSession rses = RollerSession.getRollerSession(request);
+            request.setAttribute("model", new BasePageModel(
+                "pagesForm.title", request, response, mapping)); 
+            
+            WebsiteData website = rreq.getWebsite();
+            if (website == null && form.getId()!=null) 
+            {
+                UserManager mgr = RollerFactory.getRoller().getUserManager();                
+                WeblogTemplate template = mgr.getPage(form.getId());
+                website = template.getWebsite();
+            }
+            
+            if ( rses.isUserAuthorizedToAdmin(website))
+            {
+                addModelObjects(request, response, mapping, website);
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    public ActionForward remove(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("editPages");
+        request.setAttribute("model", new BasePageModel(
+            "pagesForm.title", request, response, mapping));
+        try
+        {
+            UserManager mgr = RollerFactory.getRoller().getUserManager();
+            WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
+            WeblogTemplate template = mgr.getPage(form.getId());
+            WebsiteData website = template.getWebsite();
+            
+            RollerSession rses = RollerSession.getRollerSession(request);          
+            if ( rses.isUserAuthorizedToAdmin(website) )
+            {
+                if(!template.isRequired()) {
+                    
+                    mgr.removePage(template);
+                    RollerFactory.getRoller().flush();
+                    
+                    // notify cache
+                    CacheManager.invalidate(template);
+                } else {
+                    
+                    // someone trying to remove a required template
+                    throw new RollerException("Cannot remove required page");
+                }
+                
+                addModelObjects(
+                        request, response, mapping, template.getWebsite());
+                actionForm.reset(mapping, request);
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (RollerException e)
+        {
+            ActionErrors errors = new ActionErrors();
+            errors.add(null, new ActionError(
+                    "error.internationalized",e.getRootCauseMessage()));
+            saveErrors(request, errors);       
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    /** Send user to remove confirmation page */
+    public ActionForward removeOk(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("removePage.page");
+        try
+        {
+            RollerSession rses = RollerSession.getRollerSession(request);
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WeblogTemplate page = (WeblogTemplate) rreq.getPage();
+            WebsiteData website = page.getWebsite();
+            if ( rses.isUserAuthorizedToAdmin(website) )
+            {
+                WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
+                form.copyFrom(page, request.getLocale());
+
+                addModelObjects(request, response, mapping, page.getWebsite());
+                
+                BasePageModel pageModel = new BasePageModel(
+                    "editPages.title.removeOK", request, response, mapping);
+                pageModel.setWebsite(website);
+                request.setAttribute("model", pageModel);
+
+                UserData ud = rses.getAuthenticatedUser();
+                request.setAttribute("user",ud);
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    public ActionForward update(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("editPage.page");
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
+            UserManager mgr = RollerFactory.getRoller().getUserManager();
+            WeblogTemplate data = mgr.getPage(form.getId());
+            WebsiteData website = data.getWebsite();
+            
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if (rses.isUserAuthorizedToAdmin(website))
+            {
+                form.copyTo(data, request.getLocale());
+                data.setLastModified( new java.util.Date() );
+
+                validateLink( data );
+
+                mgr.savePage( data );
+                RollerFactory.getRoller().flush();
+                
+                // set the (possibly) new link back into the Form bean
+                ((WeblogTemplateForm)actionForm).setLink( data.getLink() );
+
+                ActionMessages uiMessages = new ActionMessages();
+                uiMessages.add(ActionMessages.GLOBAL_MESSAGE, 
+                        new ActionMessage("pageForm.save.success", 
+                                data.getName()));
+                saveMessages(request, uiMessages);
+
+                CacheManager.invalidate(data);
+                
+                BasePageModel pageModel = new BasePageModel(
+                    "pageForm.title", request, response, mapping);
+                pageModel.setWebsite(website);
+                request.setAttribute("model", pageModel);
+            }
+            else
+            {
+                forward = mapping.findForward("access-denied");
+            }
+              
+            // Don't reset this form. Allow user to keep on tweaking.        
+            //actionForm.reset(mapping,request);
+        }
+        catch (RollerPermissionsException e)
+        {
+            ActionErrors errors = new ActionErrors();
+            errors.add(null, new ActionError("error.permissions.deniedSave"));
+            saveErrors(request, errors);
+            forward = mapping.findForward("access-denied");
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    //-----------------------------------------------------------------------
+    /**
+     * Ensures that the page has a safe value for the link
+     * field.  "Safe" is defined as containing no html
+     * or any other non-alphanumeric characters.
+     * While this is overly strict (there are non-alphanum
+     * characters that are web-safe), this is a much easier
+     * test-and-correct.  Otherwise we would need a RegEx package.
+     */
+    private void validateLink( WeblogTemplate data )
+    {
+        // if data.getLink() is null or empty
+        // use the title ( data.getName() )
+        if ( StringUtils.isEmpty( data.getLink() ) )
+        {
+            data.setLink( data.getName() );
+        }
+
+        // if link contains any nonAlphanumeric, strip them
+        // first we must remove any html, as this is
+        // non-instructional markup.  Then do a straight
+        // removeNonAlphanumeric.
+        if ( !StringUtils.isAlphanumeric( data.getLink() ) )
+        {
+            String link = Utilities.removeHTML( data.getLink() );
+            link = Utilities.removeNonAlphanumeric( link );
+            data.setLink( link );
+        }
+    }
+    
+    //-----------------------------------------------------------------------
+    public ActionForward cancel(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        request.setAttribute("model", new BasePageModel(
+            "pagesForm.title", request, response, mapping));
+        return (mapping.findForward("editPages"));
+    }
+    
+    //-----------------------------------------------------------------------
+    private void addModelObjects( 
+        HttpServletRequest  request,
+        HttpServletResponse response,
+        ActionMapping mapping, 
+        WebsiteData website)
+    throws RollerException 
+    {             
+        UserManager mgr = RollerFactory.getRoller().getUserManager();        
+        RollerSession rses = RollerSession.getRollerSession(request);
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+                
+        UserData user = rses.getAuthenticatedUser();
+        request.setAttribute("user", user);
+
+        WebsiteData wd = rreq.getWebsite();
+        request.setAttribute("website", website);
+
+        List pages = mgr.getPages(website);
+        request.setAttribute("pages", pages);
+        
+        request.setAttribute("page", rreq.getPage());
+    }
+}
+

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WebsiteFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WebsiteFormAction.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WebsiteFormAction.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/WebsiteFormAction.java Mon May  1 15:23:02 2006
@@ -0,0 +1,383 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.presentation.website.actions;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.BooleanUtils;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.actions.DispatchAction;
+import org.apache.velocity.VelocityContext;
+import org.apache.roller.RollerException;
+import org.apache.roller.RollerPermissionsException;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.config.RollerRuntimeConfig;
+import org.apache.roller.model.PagePluginManager;
+import org.apache.roller.model.Roller;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.model.WeblogManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerContext;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.RollerSession;
+import org.apache.roller.presentation.cache.CacheManager;
+import org.apache.roller.presentation.website.formbeans.WebsiteFormEx;
+import org.apache.roller.util.Blacklist;
+
+
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * Website Settings action.
+ *
+ * @struts.action name="websiteFormEx" path="/editor/website"
+ * 		scope="session" parameter="method"
+ *
+ * @struts.action-forward name="editWebsite.page" path=".edit-website"
+ * @struts.action-forward name="removeWebsite.page" path=".WebsiteRemove"
+ */
+public final class WebsiteFormAction extends DispatchAction {
+    private static Log mLogger =
+            LogFactory.getFactory().getInstance(WebsiteFormAction.class);
+    
+    public ActionForward add(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception {
+        return update( mapping, actionForm, request, response );
+    }
+    
+    //-----------------------------------------------------------------------
+    public ActionForward edit(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
+        ActionForward forward = mapping.findForward("editWebsite.page");
+        try {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WebsiteData website = rreq.getWebsite();
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if (rses.isUserAuthorizedToAdmin(website)) {
+                Roller roller = RollerFactory.getRoller();
+                UserManager umgr = roller.getUserManager();
+                WeblogManager wmgr = roller.getWeblogManager();
+                UserData ud = rses.getAuthenticatedUser();
+                request.setAttribute("user",ud);
+                
+                WebsiteFormEx wf = (WebsiteFormEx)actionForm;
+                wf.copyFrom(website, request.getLocale());
+                
+                List cd = wmgr.getWeblogCategories(website, true);
+                request.setAttribute("categories",cd);
+                
+                List bcd = wmgr.getWeblogCategories(website, false);
+                request.setAttribute("bloggerCategories",bcd);
+                
+                List pages = umgr.getPages(website);
+                request.setAttribute("pages",pages);
+                
+                ServletContext ctx = request.getSession().getServletContext();
+                String editorPages =
+                        RollerRuntimeConfig.getProperty("users.editor.pages");
+                
+                List epages = Arrays.asList(StringUtils.split(
+                        StringUtils.deleteWhitespace(editorPages), ","));
+                request.setAttribute("editorPagesList", epages);
+                
+                
+                WebsitePageModel pageModel = new WebsitePageModel(
+                        "websiteSettings.title", request, response, mapping, website);
+                request.setAttribute("model",pageModel);
+            } else {
+                forward = mapping.findForward("access-denied");
+            }
+        } catch (Exception e) {
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+    
+    
+    //-----------------------------------------------------------------------
+    public ActionForward update(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception {
+        ActionErrors errors = new ActionErrors();
+        ActionMessages messages = new ActionMessages();
+        ActionForward forward = mapping.findForward("editWebsite");
+        try {
+            WebsiteFormEx form = (WebsiteFormEx)actionForm;
+            WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+            UserManager umgr = RollerFactory.getRoller().getUserManager();
+            
+            WebsiteData wd = umgr.getWebsite(form.getId());
+            
+            // Set website in request, so subsequent action gets it
+            RollerRequest.getRollerRequest(request).setWebsite(wd);
+            
+            RollerSession rollerSession = RollerSession.getRollerSession(request);
+            if ( rollerSession.isUserAuthorizedToAdmin(wd)) {
+                checkBlacklist(errors, messages, form.getBlacklist());
+                if (errors.isEmpty()) {
+                    // ensure getEnabled can't be changed
+                    form.setEnabled(wd.getEnabled());
+                    form.copyTo(wd, request.getLocale());
+                    
+                    // ROL-485: comments not be allowed on inactive weblogs
+                    if (wd.getActive() != null && !wd.getActive().booleanValue()) {
+                        wd.setAllowComments(Boolean.FALSE);
+                        messages.add(null, new ActionMessage(
+                            "websiteSettings.commentsOffForInactiveWeblog"));
+                    }
+                                        
+                    umgr.saveWebsite(wd);  
+                    
+                    // ROL-1050: apply comment defaults to existing entries
+                    if (form.isApplyCommentDefaults()) {
+                        wmgr.applyCommentDefaultsToEntries(wd);
+                    }
+
+                    RollerFactory.getRoller().getRefererManager().applyRefererFilters(wd);
+                    
+                    RollerFactory.getRoller().flush();
+                    
+                    messages.add(null,
+                        new ActionMessage("websiteSettings.savedChanges"));
+                    
+                    request.getSession().setAttribute(
+                        RollerRequest.WEBSITEID_KEY, form.getId());
+                    
+                    // Clear cache entries associated with website
+                    CacheManager.invalidate(wd);
+            
+                    actionForm.reset(mapping,request);
+                }
+                
+                // set the Editor Page list
+                ServletContext ctx = request.getSession().getServletContext();
+                String editorPages =
+                        RollerRuntimeConfig.getProperty("users.editor.pages");
+                
+                List epages = Arrays.asList(StringUtils.split(
+                        org.apache.commons.lang.StringUtils.deleteWhitespace(editorPages), ","));
+                request.setAttribute("editorPagesList", epages);
+                
+                WebsitePageModel pageModel =
+                        new WebsitePageModel("websiteSettings.title",
+                        request, response, mapping, wd);
+                request.setAttribute("model",pageModel);
+                
+            } else {
+                forward = mapping.findForward("access-denied");
+            }
+            
+        } catch (RollerPermissionsException e) {
+            errors.add(null, new ActionError("error.permissions.deniedSave"));
+            forward = mapping.findForward("access-denied");
+        } catch (RollerException re) {
+            mLogger.error("Unexpected exception",re.getRootCause());
+            throw new ServletException(re);
+        } catch (Exception e) {
+            mLogger.error("Unexpected exception",e);
+            throw new ServletException(e);
+        }
+        if (errors.size() > 0) saveErrors(request, errors);
+        if (messages.size() > 0) saveMessages(request, messages);
+        return forward;
+    }
+    
+    /** Count string and regex ignore words, check regex for Syntax errors */
+    private void checkBlacklist(
+            ActionErrors errors, ActionMessages messages, String blacklist) {
+        List regexRules = new ArrayList();
+        List stringRules = new ArrayList();
+        try {
+            // just for testing/counting, this does not persist rules in any way
+            Blacklist.populateSpamRules(blacklist, stringRules, regexRules, null);
+            messages.add(null, new ActionMessage(
+                "websiteSettings.acceptedBlacklist",
+                new Integer(stringRules.size()), new Integer(regexRules.size())));
+        } catch (Throwable e) {
+            errors.add(null, new ActionMessage(
+                "websiteSettings.error.processingBlacklist", e.getMessage()));
+        }
+    }
+    
+    //-----------------------------------------------------------------------
+    /** Send user to remove confirmation page */
+    public ActionForward removeOk(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception {
+        WebsiteFormEx form = (WebsiteFormEx)actionForm;
+        UserManager umgr = RollerFactory.getRoller().getUserManager();
+        WebsiteData website = umgr.getWebsite(form.getId());
+        ActionForward forward = mapping.findForward("removeWebsite.page");
+        request.setAttribute("model", new WebsitePageModel(
+                "websiteRemove.title", request, response, mapping, website));
+        try {
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if (rses.isUserAuthorizedToAdmin(website)) {
+                form.copyFrom(website, request.getLocale());
+                request.setAttribute("website", website);
+            } else {
+                forward = mapping.findForward("access-denied");
+            }
+        } catch (Exception e) {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+    
+    //-----------------------------------------------------------------------
+    public ActionForward remove(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception {
+        ActionForward forward = mapping.findForward("yourWebsites");
+        try {
+            UserManager umgr = RollerFactory.getRoller().getUserManager();
+            WebsiteFormEx form = (WebsiteFormEx)actionForm;
+            WebsiteData website = umgr.getWebsite(form.getId());
+            
+            RollerSession rses = RollerSession.getRollerSession(request);
+            if ( rses.isUserAuthorizedToAdmin(website) ) {
+                
+                // remove website
+                umgr.removeWebsite(website);
+                RollerFactory.getRoller().flush();
+                
+                CacheManager.invalidate(website);
+                
+                actionForm.reset(mapping, request);
+            } else {
+                forward = mapping.findForward("access-denied");
+            }
+        } catch (RollerException e) {
+            ActionErrors errors = new ActionErrors();
+            errors.add(null, new ActionError(
+                    "error.internationalized",e.getRootCauseMessage()));
+            saveErrors(request, errors);
+        } catch (Exception e) {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+    
+    public class WebsitePageModel extends BasePageModel {
+        private List permissions = new ArrayList();
+        private boolean groupBloggingEnabled = false;
+        private boolean emailNotificationEnabled = false;
+        private boolean moderationRequired = false;
+        public WebsitePageModel(
+                String titleKey,
+                HttpServletRequest request,
+                HttpServletResponse response,
+                ActionMapping mapping,
+                WebsiteData website) throws RollerException {
+            super(titleKey, request, response, mapping);
+            this.website = website;
+            Roller roller = RollerFactory.getRoller();
+            RollerSession rollerSession = RollerSession.getRollerSession(request);
+            UserData user = rollerSession.getAuthenticatedUser();
+            permissions = roller.getUserManager().getAllPermissions(website);
+            groupBloggingEnabled =
+                RollerConfig.getBooleanProperty("groupblogging.enabled");
+            emailNotificationEnabled = 
+                RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
+            moderationRequired =  
+                RollerRuntimeConfig.getBooleanProperty("users.moderation.required");
+        }
+        public boolean isGroupBloggingEnabled() {
+            return groupBloggingEnabled;
+        }
+        public boolean isEmailNotificationEnabled() {
+            return emailNotificationEnabled;
+        }
+        public boolean isModerationRequired() {
+            return moderationRequired;
+        }
+        public boolean getHasPagePlugins() {
+            boolean ret = false;
+            try {
+                Roller roller = RollerFactory.getRoller();
+                PagePluginManager ppmgr = roller.getPagePluginManager();
+                ret = ppmgr.hasPagePlugins();
+            } catch (RollerException e) {
+                mLogger.error(e);
+            }
+            return ret;
+        }
+        
+        public List getPagePlugins() {
+            List list = new ArrayList();
+            try {
+                if (getHasPagePlugins()) {
+                    Roller roller = RollerFactory.getRoller();
+                    PagePluginManager ppmgr = roller.getPagePluginManager();
+                    Map plugins = ppmgr.createAndInitPagePlugins(
+                            getWebsite(),
+                            RollerContext.getRollerContext().getServletContext(),
+                            RollerContext.getRollerContext().getAbsoluteContextUrl(),
+                            new VelocityContext());
+                    Iterator it = plugins.values().iterator();
+                    while (it.hasNext()) list.add(it.next());
+                }
+            } catch (Exception e) {
+                mLogger.error(e);
+            }
+            return list;
+        }
+    }
+}
+

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourProfileAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourProfileAction.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourProfileAction.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourProfileAction.java Mon May  1 15:23:02 2006
@@ -0,0 +1,195 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.actions;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.roller.RollerException;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerSession;
+import org.apache.roller.presentation.website.formbeans.UserFormEx;
+import org.apache.roller.util.StringUtils;
+
+/**
+ * Allows user to edit his/her profile.
+ * 
+ * @struts.action name="userFormEx" path="/editor/yourProfile" parameter="method"
+ * @struts.action-forward name="yourProfile.page" path=".YourProfile"
+ */
+public class YourProfileAction extends UserBaseAction
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(YourProfileAction.class);
+
+    /** If method param is not specified, use HTTP verb to pick method to call */
+    public ActionForward unspecified(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        if (request.getMethod().equals("GET"))
+        {
+            return edit(mapping, actionForm, request, response);
+        }
+        return save(mapping, actionForm, request, response);
+    }
+    
+    public ActionForward cancel(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        return mapping.findForward("yourWebsites");
+    }
+    
+    /** Load form with authenticated user and forward to your-profile page */
+    public ActionForward edit(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("yourProfile.page");
+        try
+        {
+            RollerSession rollerSession = RollerSession.getRollerSession(request);
+            UserData ud = rollerSession.getAuthenticatedUser();
+            UserFormEx form = (UserFormEx)actionForm;
+            form.copyFrom(ud, request.getLocale());
+            form.setPasswordText(null);
+            form.setPasswordConfirm(null);
+            form.setLocale(ud.getLocale());
+            form.setTimeZone(ud.getTimeZone());
+            request.setAttribute("model", new BasePageModel(
+                "yourProfile.title", request, response, mapping));
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }        
+        // if user logged in with a cookie, display a warning that they
+        // can't change passwords
+        if (mLogger.isDebugEnabled()) 
+        {
+            log.debug("checking for cookieLogin...");
+        }
+        if (request.getSession().getAttribute("cookieLogin") != null) {
+            ActionMessages messages = new ActionMessages();
+
+            // add warning messages
+            messages.add(ActionMessages.GLOBAL_MESSAGE,
+                         new ActionMessage("yourProfile.cookieLogin"));
+            saveMessages(request, messages);
+        }
+        return forward;
+    }
+
+    /** Update user based on posted form data */
+    public ActionForward save(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws IOException, ServletException
+    {
+        UserFormEx form = (UserFormEx)actionForm;
+        ActionForward forward = mapping.findForward("yourProfile.page");
+        ActionMessages msgs = new ActionMessages();
+        try
+        {
+            ActionMessages errors = validate(form, new ActionErrors());
+            if (errors.size() == 0)
+            {
+                // We ONLY modify the user currently logged in
+                RollerSession rollerSession = RollerSession.getRollerSession(request);
+                UserData data = rollerSession.getAuthenticatedUser();
+                
+                // We want to be VERY selective about what data gets updated
+                data.setFullName(form.getFullName());
+                data.setEmailAddress(form.getEmailAddress());
+                data.setLocale(form.getLocale());
+                data.setTimeZone(form.getTimeZone());
+                
+                // If user set both password and passwordConfirm then reset password
+                if (    !StringUtils.isEmpty(form.getPasswordText()) 
+                     && !StringUtils.isEmpty(form.getPasswordConfirm()))
+                {
+                    try
+                    {
+                        data.resetPassword(RollerFactory.getRoller(), 
+                           form.getPasswordText(), 
+                           form.getPasswordConfirm());
+                    }
+                    catch (RollerException e)
+                    {
+                        msgs.add(ActionMessages.GLOBAL_MESSAGE, 
+                            new ActionMessage("yourProfile.passwordResetError"));
+                    }
+                } 
+                
+                // save the updated profile
+                UserManager mgr = RollerFactory.getRoller().getUserManager();
+                mgr.saveUser(data);
+                RollerFactory.getRoller().flush();
+
+                request.setAttribute("model", new BasePageModel(
+                        "yourProfile.title", request, response, mapping));
+                
+                saveMessages(request, msgs);
+            }
+            else 
+            {
+                saveErrors(request, errors);
+            }
+            return mapping.findForward("yourWebsites");
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+    }
+    
+}
+
+
+
+
+
+

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourWebsitesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourWebsitesAction.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourWebsitesAction.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/YourWebsitesAction.java Mon May  1 15:23:02 2006
@@ -0,0 +1,242 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.actions.DispatchAction;
+import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.model.Roller;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.PermissionsData;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.RollerSession;
+import org.apache.roller.presentation.website.formbeans.YourWebsitesForm;
+
+/**
+ * Allows user to view and pick from list of his/her websites.
+ * 
+ * @struts.action path="/editor/yourWebsites" name="yourWebsitesForm" parameter="method"
+ * @struts.action-forward name="yourWebsites.page" path=".YourWebsites"
+ */
+public class YourWebsitesAction extends DispatchAction
+{
+    private static Log mLogger = 
+        LogFactory.getFactory().getInstance(YourWebsitesAction.class);
+    
+    /** If method param is not specified, use HTTP verb to pick method to call */
+    public ActionForward unspecified(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        if (request.getMethod().equals("GET"))
+        {
+            return edit(mapping, actionForm, request, response);
+        }
+        return edit(mapping, actionForm, request, response);
+    }
+    
+    public ActionForward edit(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        request.setAttribute("model",
+                new YourWebsitesPageModel(request, response, mapping));
+        
+        ActionForward forward = mapping.findForward("yourWebsites.page");
+        return forward;
+    }
+        
+    public ActionForward accept(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        YourWebsitesForm form = (YourWebsitesForm)actionForm;
+        
+        UserManager userMgr = RollerFactory.getRoller().getUserManager();
+        PermissionsData perms = userMgr.getPermissions(form.getInviteId());
+        
+        // TODO ROLLER_2.0: notify inviter that invitee has accepted invitation  
+        // TODO EXCEPTIONS: better exception handling
+        perms.setPending(false);
+        userMgr.savePermissions(perms);
+        RollerFactory.getRoller().flush();
+        
+        ActionMessages msgs = new ActionMessages();
+        msgs.add(null, new ActionMessage(
+                "yourWebsites.accepted", perms.getWebsite().getHandle()));
+        saveMessages(request, msgs);
+        
+        request.setAttribute("model",
+                new YourWebsitesPageModel(request, response, mapping));
+        ActionForward forward = mapping.findForward("yourWebsites.page");
+        return forward;
+    }
+        
+    public ActionForward decline(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        YourWebsitesForm form = (YourWebsitesForm)actionForm;
+        
+        UserManager userMgr = RollerFactory.getRoller().getUserManager();
+        PermissionsData perms = userMgr.getPermissions(form.getInviteId());
+        
+        // TODO ROLLER_2.0: notify inviter that invitee has declined invitation
+        // TODO EXCEPTIONS: better exception handling here
+        userMgr.removePermissions(perms);
+        RollerFactory.getRoller().flush();
+        
+        ActionMessages msgs = new ActionMessages();
+        msgs.add(null, new ActionMessage(
+                "yourWebsites.declined", perms.getWebsite().getHandle()));
+        saveMessages(request, msgs);
+        
+        request.setAttribute("model",
+                new YourWebsitesPageModel(request, response, mapping));
+        ActionForward forward = mapping.findForward("yourWebsites.page");
+        return forward;
+    }
+   
+    public ActionForward resign(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        YourWebsitesForm form = (YourWebsitesForm)actionForm;
+        
+        RollerSession rses = RollerSession.getRollerSession(request);
+        UserData user = rses.getAuthenticatedUser();
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WebsiteData website = rreq.getWebsite();
+        
+        UserManager userMgr = RollerFactory.getRoller().getUserManager();
+        PermissionsData perms = userMgr.getPermissions(website, user);
+        
+        if (perms != null) 
+        {
+            // TODO ROLLER_2.0: notify website members that user has resigned
+            // TODO EXCEPTIONS: better exception handling
+            userMgr.removePermissions(perms);
+            RollerFactory.getRoller().flush();
+        }
+        
+        ActionMessages msgs = new ActionMessages();
+        msgs.add(null, new ActionMessage(
+                "yourWebsites.resigned", perms.getWebsite().getHandle()));
+        saveMessages(request, msgs);
+        
+        request.setAttribute("model",
+                new YourWebsitesPageModel(request, response, mapping));
+        ActionForward forward = mapping.findForward("yourWebsites.page");
+        return forward;
+    }
+    
+    public static class YourWebsitesPageModel extends BasePageModel
+    {
+        private boolean planetAggregatorEnabled = false;
+        private boolean groupBloggingEnabled = false;
+        private List permissions = new ArrayList();
+        private List pendings = new ArrayList();
+        private int userWeblogCount = 0;
+        
+        public YourWebsitesPageModel(HttpServletRequest request,
+          HttpServletResponse response, ActionMapping mapping) throws RollerException
+        {
+            super("yourWebsites.title", request, response, mapping);
+            Roller roller = RollerFactory.getRoller();
+            RollerSession rollerSession = RollerSession.getRollerSession(request);
+            UserData user = rollerSession.getAuthenticatedUser();
+            permissions = roller.getUserManager().getAllPermissions(user);
+            userWeblogCount = permissions.size();
+            pendings = roller.getUserManager().getPendingPermissions(user); 
+            groupBloggingEnabled = 
+                RollerConfig.getBooleanProperty("groupblogging.enabled");
+            setPlanetAggregatorEnabled(RollerConfig.getBooleanProperty("planet.aggregator.enabled"));
+        }
+        public List getPermissions()
+        {
+            return permissions;
+        }
+        public void setPermissions(List permissions)
+        {
+            this.permissions = permissions;
+        }
+        public List getPendings()
+        {
+            return pendings;
+        }
+        public void setPendings(List pendings)
+        {
+            this.pendings = pendings;
+        }
+
+        public boolean isGroupBloggingEnabled() {
+            return groupBloggingEnabled;
+        }
+
+        public void setGroupBloggingEnabled(boolean groupBloggingEnabled) {
+            this.groupBloggingEnabled = groupBloggingEnabled;
+        }
+
+        public boolean isPlanetAggregatorEnabled() {
+            return planetAggregatorEnabled;
+        }
+
+        public void setPlanetAggregatorEnabled(boolean planetAggregatorEnabled) {
+            this.planetAggregatorEnabled = planetAggregatorEnabled;
+        }
+
+        public int getUserWeblogCount() {
+            return userWeblogCount;
+        }
+        public void setUserWeblogCount(int count) {
+            userWeblogCount = count;
+        }
+    }
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/package.html
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/package.html?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/package.html (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/package.html Mon May  1 15:23:02 2006
@@ -0,0 +1,27 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  The ASF licenses this file to You
+  under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.  For additional information regarding
+  copyright in this work, please see the NOTICE file in the top level
+  directory of this distribution.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+Struts actions for managing Roller config, website settings and admin.
+
+</body>
+</html>

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/CreateWebsiteForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/CreateWebsiteForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/CreateWebsiteForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/CreateWebsiteForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,112 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.formbeans;
+
+import java.util.Locale;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.roller.pojos.WebsiteData;
+
+/**
+ * @struts.form name="createWebsiteForm"
+ * @author Dave M Johnson
+ */
+public class CreateWebsiteForm extends ActionForm
+{
+    private String handle;
+    private String name;
+    private String description;
+    private String emailAddress;
+    private String locale;
+    private String timeZone;
+    private String theme;
+    
+    public CreateWebsiteForm()
+    {
+        
+    }
+    public String getDescription()
+    {
+        return description;
+    }
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+    public String getEmailAddress()
+    {
+        return emailAddress;
+    }
+    public void setEmailAddress(String emailAddress)
+    {
+        this.emailAddress = emailAddress;
+    }
+    public String getHandle()
+    {
+        return handle;
+    }
+    public void setHandle(String handle)
+    {
+        this.handle = handle;
+    }
+    public String getLocale()
+    {
+        return locale;
+    }
+    public void setLocale(String locale)
+    {
+        this.locale = locale;
+    }
+    public String getName()
+    {
+        return name;
+    }
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    public String getTheme()
+    {
+        return theme;
+    }
+    public void setTheme(String theme)
+    {
+        this.theme = theme;
+    }
+    public String getTimeZone()
+    {
+        return timeZone;
+    }
+    public void setTimeZone(String timeZone)
+    {
+        this.timeZone = timeZone;
+    }
+    
+    /**
+     * @param wd
+     * @param locale2
+     */
+    public void copyTo(WebsiteData wd, Locale locale)
+    {
+        wd.setHandle(handle);
+        wd.setName(name);
+        wd.setDescription(description);
+        wd.setLocale(this.locale);
+        wd.setTimeZone(timeZone);
+    }
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/InviteMemberForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/InviteMemberForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/InviteMemberForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/InviteMemberForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.formbeans;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @struts.form name="inviteMemberForm"
+ * @author Dave M Johnson
+ */
+public class InviteMemberForm extends ActionForm
+{
+    private String userName;
+    private String websiteId;
+    
+    public String getUserName()
+    {
+        return userName;
+    }
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    public String getWebsiteId() 
+    {
+        return websiteId;
+    }
+
+    public void setWebsiteId(String websiteId) 
+    {
+        this.websiteId = websiteId;
+    }
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MaintenanceForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MaintenanceForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MaintenanceForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MaintenanceForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,28 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.formbeans;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @struts.form name="maintenanceForm"
+ * @author Dave M Johnson
+ */
+public class MaintenanceForm extends ActionForm
+{
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MemberPermissionsForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MemberPermissionsForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MemberPermissionsForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/MemberPermissionsForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.formbeans;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @struts.form name="memberPermissionsForm"
+ * @author Dave M Johnson
+ */
+public class MemberPermissionsForm extends ActionForm
+{
+    private String websiteId; 
+    public String getWebsiteId()
+    {
+        return websiteId;
+    }
+    public void setWebsiteId(String websiteId)
+    {
+        this.websiteId = websiteId;
+    }
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/RollerConfigFormEx.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/RollerConfigFormEx.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/RollerConfigFormEx.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/RollerConfigFormEx.java Mon May  1 15:23:02 2006
@@ -0,0 +1,89 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.presentation.website.formbeans;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.ActionMapping;
+import org.apache.roller.RollerException;
+import org.apache.roller.pojos.RollerConfigData;
+import org.apache.roller.presentation.forms.RollerConfigForm;
+
+/**
+ * These properties are not persistent and are only needed for the UI.
+ *
+ * @struts.form name="rollerConfigFormEx"
+ * @author Lance Lavandowska
+ */
+public class RollerConfigFormEx extends RollerConfigForm
+{
+    public RollerConfigFormEx()
+    {
+    }
+
+    public RollerConfigFormEx( RollerConfigData config, java.util.Locale locale ) throws RollerException
+    {
+        super(config, locale);
+    }
+
+    /**
+     * Override for non-primitive values
+     */
+    public void copyFrom(org.apache.roller.pojos.RollerConfigData dataHolder, java.util.Locale locale) throws RollerException
+    {
+    	super.copyFrom(dataHolder, locale);
+        fixNulls();
+        this.uploadMaxFileMB = dataHolder.getUploadMaxFileMB();
+        this.uploadMaxDirMB = dataHolder.getUploadMaxDirMB();
+    }
+
+    /**
+     * Override for non-primitive values
+     */
+    public void copyTo(org.apache.roller.pojos.RollerConfigData dataHolder, java.util.Locale locale) throws RollerException
+    {
+        fixNulls();
+        super.copyTo(dataHolder, locale);
+        dataHolder.setUploadMaxFileMB(this.uploadMaxFileMB);
+        dataHolder.setUploadMaxDirMB(this.uploadMaxDirMB);
+    }
+
+    /**
+     * Method allows Struts to handle empty checkboxes for booleans
+     */
+	public void reset(ActionMapping mapping, HttpServletRequest request) 
+	{
+        setAbsoluteURL( null );
+        fixNulls();
+	}
+    
+    private void fixNulls()
+    {
+        if (getRssUseCache() == null) setRssUseCache( Boolean.FALSE );
+        if (getNewUserAllowed() == null) setNewUserAllowed( Boolean.FALSE );
+        if (getEnableAggregator() == null) setEnableAggregator( Boolean.FALSE );
+        if (getUploadEnabled() == null) setUploadEnabled( Boolean.FALSE );
+        if (getMemDebug() == null) setMemDebug( Boolean.FALSE );
+        if (getAutoformatComments() == null) setAutoformatComments( Boolean.FALSE );
+        if (getEscapeCommentHtml() == null) setEscapeCommentHtml( Boolean.FALSE );
+        if (getEmailComments() == null) setEmailComments( Boolean.FALSE );
+        if (getEnableLinkback() == null) setEnableLinkback( Boolean.FALSE );        
+        if (getEncryptPasswords() == null) setEncryptPasswords( Boolean.FALSE );        
+    }
+}
\ No newline at end of file

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/ThemeEditorForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/ThemeEditorForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/ThemeEditorForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/ThemeEditorForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,70 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.presentation.website.formbeans;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * Holds the name of the theme chosen or
+ * the template being edited.
+ * 
+ * @struts.form name="themeEditorForm"
+ * 
+ * @author llavandowska
+ */
+public class ThemeEditorForm extends ActionForm
+{
+	private String themeName;
+	private String themeTemplate;
+	/**
+	 * Returns the themeName.
+	 * @return String
+	 */
+	public String getThemeName()
+	{
+		return themeName;
+	}
+
+	/**
+	 * Returns the themeTemplate.
+	 * @return String
+	 */
+	public String getThemeTemplate()
+	{
+		return themeTemplate;
+	}
+
+	/**
+	 * Sets the themeName.
+	 * @param themeName The themeName to set
+	 */
+	public void setThemeName(String themeName)
+	{
+		this.themeName = themeName;
+	}
+
+	/**
+	 * Sets the themeTemplate.
+	 * @param themeTemplate The themeTemplate to set
+	 */
+	public void setThemeTemplate(String themeTemplate)
+	{
+		this.themeTemplate = themeTemplate;
+	}
+
+}

Added: incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/UploadFileForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/UploadFileForm.java?rev=398712&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/UploadFileForm.java (added)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/formbeans/UploadFileForm.java Mon May  1 15:23:02 2006
@@ -0,0 +1,104 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.presentation.website.formbeans;
+
+import java.util.ArrayList;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts.upload.FormFile;
+
+
+/**
+ * Form holds data for 5 uploaded files and array of file names of files to be deleted.
+ * @struts.form name="uploadFiles"
+ */
+public class UploadFileForm
+        extends org.apache.struts.action.ActionForm {
+    
+    // TODO: can file-upload be improved to allow an arbitrary number of files?
+    protected transient FormFile upload0 = null;
+    protected transient FormFile upload1 = null;
+    protected transient FormFile upload2 = null;
+    protected transient FormFile upload3 = null;
+    protected transient FormFile upload4 = null;
+    protected transient FormFile upload5 = null;
+    protected transient FormFile upload6 = null;
+    protected transient FormFile upload7 = null;
+    protected transient FormFile upload8 = null;
+    protected transient FormFile upload9 = null;
+    
+    protected String[] deleted;
+    
+    public UploadFileForm() {
+        super();
+    }
+    
+    public FormFile[] getUploadedFiles() {
+        ArrayList formFiles = new ArrayList();
+        if (upload0 != null && !StringUtils.isEmpty(upload0.getFileName())) 
+            formFiles.add(upload0);
+        if (upload1 != null && !StringUtils.isEmpty(upload1.getFileName())) 
+            formFiles.add(upload1);
+        if (upload2 != null && !StringUtils.isEmpty(upload2.getFileName())) 
+            formFiles.add(upload2);
+        if (upload3 != null && !StringUtils.isEmpty(upload3.getFileName())) 
+            formFiles.add(upload3);
+        if (upload4 != null && !StringUtils.isEmpty(upload4.getFileName())) 
+            formFiles.add(upload4);
+        if (upload5 != null && !StringUtils.isEmpty(upload5.getFileName())) 
+            formFiles.add(upload5);
+        if (upload6 != null && !StringUtils.isEmpty(upload6.getFileName())) 
+            formFiles.add(upload6);
+        if (upload7 != null && !StringUtils.isEmpty(upload7.getFileName())) 
+            formFiles.add(upload7);
+        if (upload8 != null && !StringUtils.isEmpty(upload8.getFileName())) 
+            formFiles.add(upload8);
+        if (upload9 != null && !StringUtils.isEmpty(upload9.getFileName())) 
+            formFiles.add(upload9);
+        return (FormFile[])formFiles.toArray(new FormFile[formFiles.size()]);
+    }
+    
+    public void setUploadedFile0(FormFile file) { upload0 = file; }
+    public void setUploadedFile1(FormFile file) { upload1 = file; }
+    public void setUploadedFile2(FormFile file) { upload2 = file; }
+    public void setUploadedFile3(FormFile file) { upload3 = file; }
+    public void setUploadedFile4(FormFile file) { upload4 = file; }    
+    public void setUploadedFile5(FormFile file) { upload5 = file; }
+    public void setUploadedFile6(FormFile file) { upload6 = file; }
+    public void setUploadedFile7(FormFile file) { upload7 = file; }
+    public void setUploadedFile8(FormFile file) { upload8 = file; }
+    public void setUploadedFile9(FormFile file) { upload9 = file; }
+    
+    public FormFile getUploadedFile0() { return upload0; }
+    public FormFile getUploadedFile1() { return upload1; }
+    public FormFile getUploadedFile2() { return upload2; }
+    public FormFile getUploadedFile3() { return upload3; }
+    public FormFile getUploadedFile4() { return upload4; }   
+    public FormFile getUploadedFile5() { return upload5; }
+    public FormFile getUploadedFile6() { return upload6; }
+    public FormFile getUploadedFile7() { return upload7; }
+    public FormFile getUploadedFile8() { return upload8; }
+    public FormFile getUploadedFile9() { return upload9; }
+    
+    public void setDeleteFiles(String[] fileNames) {
+        deleted = fileNames;
+    }
+    
+    public String[] getDeleteFiles() { return deleted; }
+}
+



Mime
View raw message