roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r189695 [37/67] - in /incubator/roller/trunk: ./ contrib/ contrib/lib/ contrib/plugins/ contrib/plugins/src/ contrib/plugins/src/org/ contrib/plugins/src/org/roller/ contrib/plugins/src/org/roller/presentation/ contrib/plugins/src/org/roller/presentation/velocity/ contrib/plugins/src/org/roller/presentation/velocity/plugins/ contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/ contrib/plugins/src/org/roller/presentation/velocity/plugins/bookmarks/ contrib/plugins/src/org/roller/presentation/velocity/plugins/email/ contrib/plugins/src/org/roller/presentation/velocity/plugins/jspwiki/ contrib/plugins/src/org/roller/presentation/velocity/plugins/radeox/ contrib/plugins/src/org/roller/presentation/velocity/plugins/readmore/ contrib/plugins/src/org/roller/presentation/velocity/plugins/smileys/ contrib/plugins/src/org/roller/presentation/velocity/plugins/textile/ contrib/plugins/src/org/roller/presentation/velocity/plugins/topictag/ custom/ custom/src/ custom/web/ docs/ docs/images/ docs/installguide/ docs/installguide/old/ docs/userguide/ docs/userguide/images/ docs/userguide/old/ metadata/ metadata/database/ metadata/database/hibernate/ metadata/xdoclet/ nbproject/ personal/ personal/eclipse/ personal/testing/ sandbox/ sandbox/planetroller/ sandbox/planetroller/metadata/ sandbox/planetroller/metadata/database/ sandbox/planetroller/src/ sandbox/planetroller/src/org/ sandbox/planetroller/src/org/roller/ sandbox/planetroller/src/org/roller/tools/ sandbox/planetroller/src/org/roller/tools/planet/ sandbox/planetroller/templates/ sandbox/planetroller/test/ sandbox/planetroller/test/org/ sandbox/planetroller/test/org/roller/ sandbox/planetroller/test/org/roller/model/ sandbox/planetroller/test/org/roller/tools/ sandbox/planetroller/test/org/roller/tools/planet/ sandbox/planetroller/testdata/ sandbox/planetroller/testdata/cache/ sandbox/planetroller/testdata/output/ sandbox/standalone/ sandbox/standalone/jspwiki/ sandbox/standalone/jspwiki/default/ sandbox/standalone/jspwiki/default/images/ sandbox/standalone/lib/ sandbox/standalone/src/ sandbox/standalone/src/org/ sandbox/standalone/src/org/roller/ sandbox/standalone/src/org/roller/jspwiki/ sandbox/standalone/src/org/roller/tomcat/ sandbox/standalone/src/org/roller/util/ sandbox/standalone/tests/ sandbox/standalone/tests/org/ sandbox/standalone/tests/org/roller/ sandbox/standalone/tests/org/roller/util/ sandbox/standalone/tomcat/ src/ src/org/ src/org/roller/ src/org/roller/business/ src/org/roller/business/hibernate/ src/org/roller/business/search/ src/org/roller/business/search/operations/ src/org/roller/business/utils/ src/org/roller/config/ src/org/roller/config/runtime/ src/org/roller/model/ src/org/roller/pojos/ src/org/roller/presentation/ src/org/roller/presentation/atomapi/ src/org/roller/presentation/bookmarks/ src/org/roller/presentation/bookmarks/actions/ src/org/roller/presentation/bookmarks/formbeans/ src/org/roller/presentation/bookmarks/tags/ src/org/roller/presentation/filters/ src/org/roller/presentation/forms/ src/org/roller/presentation/newsfeeds/ src/org/roller/presentation/pagecache/ src/org/roller/presentation/pagecache/rollercache/ src/org/roller/presentation/pings/ src/org/roller/presentation/planet/ src/org/roller/presentation/tags/ src/org/roller/presentation/tags/calendar/ src/org/roller/presentation/tags/menu/ src/org/roller/presentation/util/ src/org/roller/presentation/velocity/ src/org/roller/presentation/weblog/ src/org/roller/presentation/weblog/actions/ src/org/roller/presentation/weblog/formbeans/ src/org/roller/presentation/weblog/tags/ src/org/roller/presentation/website/ src/org/roller/presentation/website/actions/ src/org/roller/presentation/website/formbeans/ src/org/roller/presentation/website/tags/ src/org/roller/presentation/xmlrpc/ src/org/roller/util/ src/org/roller/util/rome/ tests/ tests/org/ tests/org/roller/ tests/org/roller/ant/ tests/org/roller/business/ tests/org/roller/presentation/ tests/org/roller/presentation/atomapi/ tests/org/roller/presentation/bookmarks/ tests/org/roller/presentation/filters/ tests/org/roller/presentation/velocity/ tests/org/roller/presentation/velocity/plugins/ tests/org/roller/presentation/velocity/plugins/smileys/ tests/org/roller/presentation/velocity/plugins/textile/ tests/org/roller/presentation/weblog/ tests/org/roller/presentation/xmlrpc/ tests/org/roller/util/ tests/org/roller/util/rome/ tools/ tools/buildtime/ tools/buildtime/ant-1.6.2/ tools/buildtime/findbugs/ tools/buildtime/findbugs/lib/ tools/buildtime/findbugs/plugin/ tools/buildtime/mockrunner-0.3/ tools/buildtime/mockrunner-0.3/lib/ tools/buildtime/mockrunner-0.35/ tools/buildtime/mockrunner-0.35/lib/ tools/buildtime/tomcat-4.1.24/ tools/buildtime/xdoclet-1.2/ tools/buildtime/xdoclet-1.2/lib/ tools/hibernate-2.1/ tools/hibernate-2.1/lib/ tools/lib/ tools/standard-1.0.3/ tools/standard-1.0.3/lib/ tools/standard-1.0.3/tld/ tools/struts-1.2.4/ tools/struts-1.2.4/lib/ web/ web/WEB-INF/ web/WEB-INF/classes/ web/WEB-INF/classes/flavors/ web/WEB-INF/classes/themes/ web/bookmarks/ web/editor/ web/editor/images/ web/images/ web/images/editor/ web/images/midas/ web/images/preview/ web/images/smileys/ web/planet/ web/tags/ web/templates/ web/theme/ web/theme/images/ web/theme/lavender/ web/theme/scripts/ web/theme/scripts/classes/ web/themes/ web/themes/basic/ web/themes/berkley/ web/themes/berkley/images/ web/themes/brushedmetal/ web/themes/brushedmetal/images/ web/themes/cheb/ web/themes/cheb/images/ web/themes/cheb/scripts/ web/themes/clean/ web/themes/currency-i18n/ web/themes/currency-i18n/images/ web/themes/currency/ web/themes/currency/images/ web/themes/grey2/ web/themes/moonshine/ web/themes/movablemanila/ web/themes/movablemanila/images/ web/themes/pacifica/ web/themes/robot/ web/themes/rolling/ web/themes/rolling/images/ web/themes/sotto/ web/themes/sotto/images/ web/themes/sotto/styles/ web/themes/sunsets/ web/themes/sunsets/images/ web/themes/sunsets/scripts/ web/themes/sunsets/styles/ web/themes/werner/ web/themes/x2/ web/themes/x2/images/ web/themes/x2/scripts/ web/themes/x2/styles/ web/weblog/ web/website/
Date Thu, 09 Jun 2005 03:19:20 GMT
Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoriesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoriesAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoriesAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoriesAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,223 @@
+/*
+ * Created on Oct 21, 2003
+ */
+package org.roller.presentation.weblog.actions;
+
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.TreeSet;
+
+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.roller.RollerException;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.pojos.WebsiteData;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.weblog.formbeans.CategoriesForm;
+
+/**
+ * Actions that are initiated from the CategoriesForm.
+ * 
+ * @struts.action name="categoriesForm" path="/editor/categories" parameter="method"
+ * @struts.action-forward name="CategoriesForm" path="/weblog/CategoriesForm.jsp"
+ * 
+ * @author Dave Johnson
+ */
+public class CategoriesAction extends DispatchAction
+{
+    private static Log mLogger = 
+        LogFactory.getFactory().getInstance(CategoriesAction.class);
+
+    /**
+     * Present the CategoriesForm loaded with category specified by request.
+     * @param mapping Action mapping.
+     * @param actionForm Form bean.
+     * @param request Request.
+     * @param response Response.
+     * @return Forward to CategoriesForm or access-denied.
+     * @throws RollerException
+     */
+    public ActionForward selectCategory(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws RollerException
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        if (rreq.isUserAuthorizedToEdit())
+        {
+            addModelObjects(request, (CategoriesForm)actionForm);
+            return mapping.findForward("CategoriesForm");
+        }
+        else
+        {
+            return mapping.findForward("access-denied");
+        }
+    }
+
+     /**
+     * Move Categories and bookmarks indicated by CategoriesForm bean.
+     * @param mapping Action mapping.
+     * @param actionForm  Form bean.
+     * @param request Request.
+     * @param response Response.
+     * @return Forward to CategoriesForm or access-denied.
+     * @throws RollerException
+     */
+    public ActionForward moveSelected(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws RollerException
+    {
+        ActionMessages messages = new ActionMessages();
+        ActionForward forward = mapping.findForward("CategoriesForm");
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        if (rreq.isUserAuthorizedToEdit())
+        {
+            try 
+            {
+                WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+                CategoriesForm form = (CategoriesForm)actionForm; 
+    
+                mLogger.debug("Moving categories to category, id=" 
+                    + form.getMoveToCategoryId());
+                    
+                // Move subCategories to new category.
+                String Categories[] = form.getSelectedCategories();
+                WeblogCategoryData parent = 
+                    wmgr.retrieveWeblogCategory(form.getMoveToCategoryId());
+                if (null != Categories)
+                {
+                    for (int i = 0; i < Categories.length; i++)
+                    {
+                        WeblogCategoryData cd = 
+                            wmgr.retrieveWeblogCategory(Categories[i]); 
+                        
+                        // Don't move category into itself.                  
+                        if (    !cd.getId().equals(parent.getId()) 
+                             && !parent.descendentOf(cd))
+                        {
+                            cd.setParent(parent);
+                            cd.save();
+                        }
+                        else 
+                        {
+                            messages.add(null, new ActionMessage(
+                                "categoriesForm.warn.notMoving",cd.getName()));
+                        }
+                    }
+                }
+    
+                rreq.getRoller().commit();
+                
+                addModelObjects(request, (CategoriesForm)actionForm);
+                saveMessages(request, messages);
+            }
+            catch (RollerException e)
+            {
+                ActionErrors errors = new ActionErrors();
+                errors.add(null, new ActionError("categoriesForm.error.move"));
+                saveErrors(request, errors);       
+            }
+        }
+        else
+        {
+            forward = mapping.findForward("access-denied");
+        }
+        return forward;
+    }
+
+    /**
+     * Load model objects for display in CategoriesForm.
+     * @param request
+     * @throws RollerException
+     */
+    private void addModelObjects(HttpServletRequest request, CategoriesForm form) 
+        throws RollerException
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WebsiteData wd = rreq.getWebsite();
+        WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+        
+        TreeSet allCategories = new TreeSet(new CategoryPathComparator());
+        
+        // Find catid wherever it may be
+        String catId = (String)request.getAttribute(RollerRequest.WEBLOGCATEGORYID_KEY);
+        if (null == catId) 
+        {
+            catId = request.getParameter(RollerRequest.WEBLOGCATEGORYID_KEY);
+        }  
+        if (null == catId)
+        {
+            catId = form.getId();     
+        }
+       
+        WeblogCategoryData cat = null;
+        if (null == catId || catId.equals("null"))
+        {
+            cat = wmgr.getRootWeblogCategory(wd);
+        }
+        else 
+        {
+            cat = wmgr.retrieveWeblogCategory(catId);            
+        }
+        form.setId(cat.getId());
+        
+        request.setAttribute("category", cat);
+        request.setAttribute("categories", cat.getWeblogCategories());
+        
+        if (null != cat.getParent())
+        {
+            LinkedList catPath = new LinkedList();
+            catPath.add(0, cat);
+            WeblogCategoryData parent = cat.getParent();
+            while (parent != null) 
+            {
+                catPath.add(0, parent);
+                parent = parent.getParent();   
+            }
+            request.setAttribute("categoryPath", catPath);
+            
+            request.setAttribute(
+                RollerRequest.PARENTID_KEY, cat.getParent().getId());
+        }
+    
+        // Build collection of all Categories, except for current one, 
+        // sorted by path.
+        Iterator iter = wmgr.getWeblogCategories(wd).iterator();
+        while (iter.hasNext())
+        {
+            WeblogCategoryData cd = (WeblogCategoryData) iter.next();
+            if (!cd.getId().equals(catId))
+            {
+                allCategories.add(cd);
+            }
+        }
+        request.setAttribute("allCategories", allCategories);
+    }
+
+    private static final class CategoryPathComparator implements Comparator
+    {
+        public int compare(Object o1, Object o2) {
+            WeblogCategoryData f1 = (WeblogCategoryData)o1; 
+            WeblogCategoryData f2 = (WeblogCategoryData)o2; 
+            return f1.getPath().compareTo(f2.getPath());
+        }
+    }
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryDeleteAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryDeleteAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryDeleteAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryDeleteAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,132 @@
+/*
+ * Created on Oct 21, 2003
+ */
+package org.roller.presentation.weblog.actions;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.pojos.WebsiteData;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.weblog.formbeans.CategoryDeleteForm;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @struts.action path="/editor/categoryDelete" name="categoryDeleteForm"
+ * @struts.action-forward name="Categories" path="/editor/categories.do?method=selectCategory"
+ * @struts.action-forward name="CategoryDeleteOK" path="/weblog/CategoryDeleteOK.jsp"
+ * 
+ * @author Dave Johnson
+ */
+public class CategoryDeleteAction extends Action
+{
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws Exception
+    {
+        ActionForward forward = null;
+        CategoryDeleteForm form = (CategoryDeleteForm)actionForm;
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+        
+        if (rreq.isUserAuthorizedToEdit())
+        {
+            String catid = request.getParameter("catid");
+            WeblogCategoryData catToDelete = 
+                wmgr.retrieveWeblogCategory(catid);
+            String returnId = null;
+            if (catToDelete.getParent() != null)
+            {
+                returnId = catToDelete.getParent().getId();
+            }
+            if (form.isDelete() == null)
+            {
+                // Present CategoryDeleteOK? page to user
+                WebsiteData website = rreq.getWebsite();
+                WeblogCategoryData theCat = wmgr.retrieveWeblogCategory(catid);
+                Iterator allCats = 
+                    wmgr.getWeblogCategories(website).iterator();
+                List destCats = new LinkedList();
+                while (allCats.hasNext())
+                {
+                    WeblogCategoryData cat = (WeblogCategoryData)allCats.next();
+                    // Allow entries to be moved to any other category except 
+                    // root and the sub-cats of the category being deleted.
+                    if (!cat.getId().equals(catid) 
+                        && cat.getParent()!=null
+                        && !cat.descendentOf(catToDelete))
+                    {
+                        destCats.add(cat);
+                    }                    
+                }
+                if (destCats.size() > 0)
+                {
+                    form.setName(theCat.getName());
+                    form.setCatid(catid);
+                    form.setCats(destCats);
+                    form.setInUse(Boolean.valueOf(catToDelete.isInUse()));
+                    forward = mapping.findForward("CategoryDeleteOK");
+                }
+                else
+                {
+                    // Can't delete last category, send 'em back!
+                    if (null != returnId) 
+                    {
+                        request.setAttribute(
+                                RollerRequest.WEBLOGCATEGORYID_KEY, returnId);
+                    }               
+                    forward = mapping.findForward("Categories");
+                }
+            }
+            else if (form.isDelete().booleanValue()) 
+            {
+                // User clicked YES to delete
+                WeblogCategoryData destCat = null;
+                if (form.getMoveToWeblogCategoryId() != null) 
+                {
+                    destCat = wmgr.retrieveWeblogCategory(form.getMoveToWeblogCategoryId());
+                }
+                  
+                // move entries to destCat and remove catToDelete
+                catToDelete.remove(destCat);
+                
+                rreq.getRoller().commit();
+                
+                if (null != returnId) 
+                {
+                    request.setAttribute(
+                        RollerRequest.WEBLOGCATEGORYID_KEY, returnId);
+                }               
+                forward = mapping.findForward("Categories");
+            }
+            else 
+            {
+                // User clicked NO to delete, do back to categories form
+                if (null != returnId) 
+                {
+                    request.setAttribute(
+                       RollerRequest.WEBLOGCATEGORYID_KEY, returnId);
+                }               
+                forward = mapping.findForward("Categories");   
+            }
+        }
+        else
+        {
+            forward = mapping.findForward("access-denied");
+        }
+        return forward;
+    }
+
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryEditAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryEditAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryEditAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategoryEditAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,93 @@
+/*
+ * Created on Oct 21, 2003
+ */
+package org.roller.presentation.weblog.actions;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.pojos.WebsiteData;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.weblog.formbeans.WeblogCategoryFormEx;
+
+import java.util.LinkedList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @struts.action path="/editor/categoryEdit" name="weblogCategoryFormEx" validate="false"
+ * @struts.action-forward name="CategoryForm" path="/weblog/CategoryForm.jsp"
+ * 
+ * @author Dave Johnson
+ */
+public class CategoryEditAction extends Action
+{
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws Exception
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WebsiteData wd = rreq.getWebsite();
+        WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+        WeblogCategoryFormEx form = (WeblogCategoryFormEx)actionForm;
+        
+        WeblogCategoryData parentCat = null;
+        if (null!=rreq.getWeblogCategory() && null==request.getParameter("correct")) 
+        {
+            // If request specifies Category and we are not correcting an 
+            // already submitted form then load that Category into the form.
+            WeblogCategoryData cd = rreq.getWeblogCategory();
+            form.copyFrom(cd, request.getLocale());
+            request.setAttribute("state","edit"); 
+                
+            // Pass Category's parent id on as attribute.                 
+            parentCat = cd.getParent();
+            request.setAttribute(
+                RollerRequest.WEBLOGCATEGORYID_KEY, parentCat.getId());
+        }
+        else if (null != request.getParameter("correct"))
+        {
+            // We are correcting a previously submtted form.
+            request.setAttribute("state","correcting"); 
+                
+            // Cat is specified by request param, pass it on as attribute.                 
+            parentCat = wmgr.retrieveWeblogCategory(rreq.getWeblogCategory().getId());
+            request.setAttribute(
+                RollerRequest.WEBLOGCATEGORYID_KEY, parentCat.getId());                
+        }
+        else
+        {
+            // We are adding a new Category
+            request.setAttribute("state","add");
+            
+            // Cat is specified by request param, pass it on as attribute. 
+            String parentId = request.getParameter(RollerRequest.PARENTID_KEY);
+            form.setParentId(parentId);                            
+        }
+        
+        // Build cat path for display on page
+        if (null != parentCat)
+        {
+            LinkedList categoryPath = new LinkedList();
+            categoryPath.add(0, parentCat);
+            WeblogCategoryData parent = parentCat.getParent();
+            while (parent != null) 
+            {
+                categoryPath.add(0, parent);
+                parent = parent.getParent();   
+            }
+            request.setAttribute("parentCategory", parentCat);
+            request.setAttribute("categoryPath", categoryPath);
+        }
+
+        return mapping.findForward("CategoryForm");
+    }
+    
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategorySaveAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategorySaveAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategorySaveAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CategorySaveAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,75 @@
+/*
+ * Created on Oct 21, 2003
+ */
+package org.roller.presentation.weblog.actions;
+
+import org.apache.struts.action.Action;
+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.roller.RollerPermissionsException;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.weblog.formbeans.WeblogCategoryFormEx;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @struts.action path="/editor/categorySave" name="weblogCategoryFormEx"
+ *    validate="true" input="/editor/categoryEdit.do"
+ * 
+ * @struts.action-forward name="Categories" path="/editor/categories.do?method=selectCategory"
+ * 
+ * @author Dave Johnson
+ */
+public class CategorySaveAction extends Action
+{
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws Exception
+    {
+        ActionForward forward = mapping.findForward("Categories");
+        try 
+        {
+            WeblogCategoryFormEx form = (WeblogCategoryFormEx)actionForm;
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+            
+            WeblogCategoryData cd = null;
+            if (null != form.getId() && !form.getId().trim().equals("")) 
+            {
+                cd = wmgr.retrieveWeblogCategory(form.getId());
+                cd.save(); // should throw if save not permitted
+            }
+            else 
+            {
+                cd = wmgr.createWeblogCategory();
+                cd.setWebsite(rreq.getWebsite());
+                
+                String parentId = form.getParentId();
+                cd.setParent(wmgr.retrieveWeblogCategory(parentId));
+            }
+            form.copyTo(cd, request.getLocale());
+            cd.save();
+            rreq.getRoller().commit();
+            
+            request.setAttribute(
+                RollerRequest.WEBLOGCATEGORYID_KEY, cd.getParent().getId());         
+        }
+        catch (RollerPermissionsException e)
+        {
+            ActionErrors errors = new ActionErrors();
+            errors.add(null, new ActionError("error.permissions.deniedSave"));
+            saveErrors(request, errors);
+            forward = mapping.findForward("access-denied");
+        }
+        return forward;
+    }
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/CustomPingTargetsAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2005
+ * Anil R. Gangolli. All rights reserved.
+ *
+ * Distributed with the Roller Weblogger Project under the terms of the Roller Software
+ * License
+ */
+
+package org.roller.presentation.weblog.actions;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.RollerException;
+import org.roller.model.PingTargetManager;
+import org.roller.pojos.PingTargetData;
+import org.roller.presentation.RollerRequest;
+import org.roller.config.PingConfig;
+import org.roller.presentation.forms.PingTargetForm;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * Administer custom ping targets.
+ *
+ * @struts.action name="pingTargetForm" path="/editor/customPingTargets" scope="request" parameter="method"
+ * @struts.action-forward name="pingTargets.page" path="/weblog/CustomPingTargets.jsp"
+ * @struts.action-forward name="pingTargetEdit.page" path="/weblog/CustomPingTargetEdit.jsp"
+ * @struts.action-forward name="pingTargetDeleteOK.page" path="/weblog/CustomPingTargetDeleteOK.jsp"
+ */
+public class CustomPingTargetsAction
+    extends BasePingTargetsAction
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(CustomPingTargetsAction.class);
+
+
+    public CustomPingTargetsAction() {
+        super();
+    }
+
+    protected Log getLogger() {
+        return mLogger;
+    }
+
+    /*
+     * Get the ping targets for the view.  Here we return the custom ping targets for the
+     * website and  set the value of attribute <code>allowCustomTargets</code> in the request.
+     * If custom ping targets have been disallowed, we just return the empty list.
+     */
+    protected List getPingTargets(RollerRequest rreq) throws RollerException
+    {
+        HttpServletRequest req = rreq.getRequest();
+        PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
+
+        Boolean allowCustomTargets = new Boolean(!PingConfig.getDisallowCustomTargets());
+        req.setAttribute("allowCustomTargets", allowCustomTargets);
+
+        List customPingTargets = allowCustomTargets.booleanValue() ?
+            pingTargetMgr.getCustomPingTargets(rreq.getWebsite()) : Collections.EMPTY_LIST;
+
+        return customPingTargets;
+    }
+
+    /*
+     * Create a new ping target (blank). Here we create a custom ping target for the website.
+     */
+    protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm)
+        throws RollerException
+    {
+        PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
+        return pingTargetMgr.createCustomPingTarget(
+            pingTargetForm.getName(), pingTargetForm.getPingUrl(), rreq.getWebsite());
+    }
+
+
+    /*
+     *  Check if the user has editing rights.
+     */
+    protected boolean hasRequiredRights(RollerRequest rreq) throws RollerException
+    {
+        return (rreq.isUserAuthorizedToEdit() && !PingConfig.getDisallowCustomTargets());
+    }
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ExportEntriesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ExportEntriesAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ExportEntriesAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ExportEntriesAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,292 @@
+/*
+ * Created on Mar 25, 2004
+ */
+package org.roller.presentation.weblog.actions;
+
+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.struts.util.RequestUtils;
+import org.roller.RollerException;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.WeblogEntryData;
+import org.roller.presentation.BasePageModel;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.velocity.ExportRss;
+import org.roller.presentation.weblog.formbeans.WeblogQueryForm;
+import org.roller.util.DateUtil;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+
+/**
+ * @struts.action path="/editor/exportEntries" name="weblogQueryForm" 
+ *    scope="request" parameter="method"
+ * 
+ * @struts.action-forward name="exportEntries.page" path="/weblog/export-entries.jsp"
+ * 
+ * @author lance.lavandowska
+ */
+public class ExportEntriesAction extends DispatchAction
+{
+    private SimpleDateFormat dayFormat = new SimpleDateFormat("yyyyMMdd");
+    private SimpleDateFormat monthFormat = new SimpleDateFormat("yyyyMM");
+    private SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
+
+    public ActionForward unspecified(
+                              ActionMapping       mapping,
+                              ActionForm          actionForm,
+                              HttpServletRequest  request,
+                              HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        return edit(mapping, actionForm, request, response);
+    }
+    
+    /**
+     * Prepare the form for selecting date-range to export.
+     * 
+     * @param mapping
+     * @param actionForm
+     * @param request
+     * @param response
+     * @return
+     * @throws IOException
+     * @throws ServletException
+     */
+    public ActionForward edit(
+                              ActionMapping       mapping,
+                              ActionForm          actionForm,
+                              HttpServletRequest  request,
+                              HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("exportEntries.page");
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            if ( !rreq.isUserAuthorizedToEdit() )
+            {
+                forward = mapping.findForward("access-denied");
+            }
+            else
+            {
+                request.setAttribute("model",
+                    new BasePageModel(request, response, mapping));
+            }
+        }
+        catch (Exception e)
+        {
+            request.getSession().getServletContext().log("ERROR",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    /**
+     * Export entries from the requested date-range to XML.
+     * 
+     * @param mapping
+     * @param actionForm
+     * @param request
+     * @param response
+     * @return
+     * @throws IOException
+     * @throws ServletException
+     */
+    public ActionForward export(
+                              ActionMapping       mapping,
+                              ActionForm          actionForm,
+                              HttpServletRequest  request,
+                              HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("exportEntries.page");
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            WeblogQueryForm form = (WeblogQueryForm)actionForm;
+            if ( rreq.isUserAuthorizedToEdit() )
+            {               
+                request.setAttribute("model",
+                                     new BasePageModel(request, response, mapping));
+                
+                Locale locale = Locale.getDefault();//rreq.getWebsite().getLocaleInstance();
+                final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+                Date startDate;
+                Date endDate;
+                try
+                {
+                    startDate = DateUtil.getStartOfDay(df.parse(form.getStartDateString()));
+                    endDate = DateUtil.getEndOfDay(df.parse(form.getEndDateString()));
+                }
+                catch (ParseException e)
+                {
+                    throw new RollerException("ERROR parsing date:" + e.getMessage());
+                }
+                
+                if (startDate != null && endDate != null) 
+                {
+                    // this work should go into a Thread!
+                    WeblogManager weblogMgr =
+                        rreq.getRoller().getWeblogManager();
+                    
+                    //List entries = weblogMgr.getWeblogEntriesInDateRange(
+                        //rreq.getUser().getUserName(), null, startDate, endDate, false);
+                    //System.out.println("Export: got " + entries.size() + " entries.");
+                    
+                    List entries = weblogMgr.getWeblogEntries(
+                                    rreq.getWebsite(), // userName
+                                    startDate,         // startDate
+                                    endDate,           // endDate
+                                    null,              // catName
+                                    WeblogManager.ALL,  // status
+                                    null);              // maxEntries
+
+                    ActionMessages messages = writeSuccessMessage(request, response, rreq, form);
+
+                    // seperate the entries as specified: day, month, year
+                    Map entryMap = seperateByPeriod(entries, form.getFileBy());
+
+                    // now export each List in the entryMap
+                    ExportRss exporter = new ExportRss(rreq.getWebsite());
+                    String exportTo = form.getExportFormat().toLowerCase();
+                    if ("atom".equals(exportTo))
+                    {
+                        exporter.setExportAtom(true);
+                    }
+                    ArrayList fileNames = new ArrayList();
+                    Iterator it = entryMap.keySet().iterator();
+                    while(it.hasNext())
+                    {
+                        String key = (String)it.next();
+                        ArrayList list = (ArrayList)entryMap.get(key);
+                        exporter.exportEntries(list, key+"_"+exportTo+".xml");
+                        fileNames.add("Exported " + list.size() + " entry(s) to " + key+"_"+exportTo+".xml<br />");
+                        //System.out.println("Exported: " + list.size() + " entries for " + key);
+                    }
+                    
+                    StringBuffer fileMessage = new StringBuffer();
+                    it = fileNames.iterator();
+                    while (it.hasNext())
+                    {
+                        fileMessage.append((String)it.next());
+                    }
+                    if (fileMessage.length() > 0) 
+                    {
+                        messages.add(ActionMessages.GLOBAL_MESSAGE, 
+                                     new ActionMessage("weblogEntryExport.exportFiles", 
+                                                       fileMessage.toString()));
+                    }
+                    saveMessages(request, messages);
+                }
+                else
+                {
+                    form.reset(mapping, (ServletRequest)request);
+                    return edit(mapping, actionForm, request, response);
+                }
+
+                //forward = mapping.findForward("exportEntries.done");
+            }
+            else
+            {    
+                forward = mapping.findForward("access-denied");
+            }
+        }
+        catch (Exception e)
+        {
+            request.getSession().getServletContext().log("ERROR",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    /**
+     * Place entries into Lists, placed into date-related
+     * buckets.  The individual buckets may represent a
+     * day, month, or year, depending on which the user specified.
+     * 
+     * @param entries
+     * @return
+     */
+    private Map seperateByPeriod(List entries, String period)
+    {
+        HashMap map = new HashMap();
+        WeblogEntryData entry = null;
+        String key = null;
+        ArrayList list = null;
+        SimpleDateFormat formatter = monthFormat;
+        if ("year".equals(period))
+        {
+            formatter = yearFormat;
+        }
+        else if ("day".equals(period))
+        {
+            formatter = dayFormat;
+        }
+        
+        Iterator it = entries.iterator();
+        while (it.hasNext()) 
+        {
+            entry = (WeblogEntryData)it.next();
+            key = formatter.format(entry.getPubTime());
+            list = (ArrayList)map.get(key);
+            if (list == null)
+            {
+                list = new ArrayList();
+                map.put(key, list);
+            }
+            list.add(entry);
+        }
+        return map;
+    }
+
+    private ActionMessages writeSuccessMessage(
+                    HttpServletRequest request, 
+                    HttpServletResponse response, 
+                    RollerRequest rreq, 
+                    WeblogQueryForm form) throws MalformedURLException
+    {
+        PageContext pageContext =
+            JspFactory.getDefaultFactory().getPageContext( 
+                this.getServlet(), request, response, "", true, 8192, true);
+        Map params = new HashMap();
+        params.put( RollerRequest.USERNAME_KEY,  rreq.getUser().getUserName());
+        params.put("rmik", "Files");
+        String filesLink = RequestUtils.computeURL(
+             pageContext, (String)null, (String)null, (String)null,
+             "uploadFiles", params, (String)null, false);
+        
+        String message = 
+            "Exporting Entries from " + 
+            form.getStartDateString() + " to " +
+            form.getEndDateString() + ".<br />" +
+            "Check your <a href=\"" + filesLink + "\">Files</a>.";
+
+        ActionMessages messages = new ActionMessages();
+        messages.add(ActionMessages.GLOBAL_MESSAGE, 
+                     new ActionMessage("weblogEntryExport.exportSuccess", message));
+                                                                      
+        return messages;
+    }
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,168 @@
+/*
+ * Created on Mar 31, 2004
+ */
+package org.roller.presentation.weblog.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.roller.pojos.UserData;
+import org.roller.presentation.MainPageAction;
+import org.roller.presentation.RollerContext;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.weblog.formbeans.ImportEntriesForm;
+import org.roller.util.StringUtils;
+
+/**
+ * TODO: revisit this class once Atom 1.0 support comes to Rome
+ * @struts.action name="importEntries" path="/editor/importEntries"
+ *                scope="request" parameter="method"
+ * 
+ * @struts.action-forward name="importEntries.page" path="/weblog/import-entries.jsp"
+ *
+ * @author lance.lavandowska
+ */
+public class ImportEntriesAction extends DispatchAction
+{
+    public ActionForward importEntries(
+                              ActionMapping       mapping,
+                              ActionForm          actionForm,
+                              HttpServletRequest  request,
+                              HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("importEntries.page");
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            if ( !rreq.isUserAuthorizedToEdit() )
+            {
+                forward = mapping.findForward("access-denied");
+            }
+            else
+            {
+				getXmlFiles(actionForm, rreq);
+                ImportEntriesForm form = (ImportEntriesForm)actionForm;
+                if (StringUtils.isNotEmpty(form.getImportFileName()))
+                {
+                    // "default" values
+                    UserData user = rreq.getUser();
+
+                    // load selected file
+                    ServletContext app = this.getServlet().getServletConfig().getServletContext();
+                    String dir = RollerContext.getUploadDir( app );
+                    File f = new File(dir + user.getUserName() +
+                                      "/" + form.getImportFileName());
+
+                    //ArchiveParser archiveParser =
+                        //new ArchiveParser(rreq.getRoller(), rreq.getWebsite(), f);
+                    String parseMessages = null; // archiveParser.parse();
+
+                    // buf will be non-zero if Entries were imported
+                    if (parseMessages.length() > 0)
+                    {
+                        ActionMessages notices = new ActionMessages();
+                        notices.add(ActionMessages.GLOBAL_MESSAGE, 
+                                     new ActionMessage("weblogEntryImport.importFiles", 
+                                                   parseMessages));
+                        saveMessages(request, notices);
+
+                        // Flush the page cache
+                        PageCacheFilter.removeFromCache( request, user );
+                        // refresh the front page cache
+                        MainPageAction.flushMainPageCache();
+                    }
+                    else
+                    {
+                        ActionErrors errors = new ActionErrors();
+                        errors.add(ActionErrors.GLOBAL_ERROR,
+                                   new ActionError("error.importing.entries", ""));
+                        saveErrors(request,errors);
+                    }
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            request.getSession().getServletContext().log("ERROR",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    /**
+     * Load list of XML files available for import.
+     * @param mapping
+     * @param actionForm
+     * @param request
+     * @param response
+     * @return
+     * @throws IOException
+     * @throws ServletException
+     */
+    public ActionForward edit(
+                              ActionMapping       mapping,
+                              ActionForm          actionForm,
+                              HttpServletRequest  request,
+                              HttpServletResponse response)
+    throws IOException, ServletException
+    {
+        ActionForward forward = mapping.findForward("importEntries.page");
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            if ( !rreq.isUserAuthorizedToEdit() )
+            {
+                forward = mapping.findForward("access-denied");
+            }
+            else
+            {
+				getXmlFiles(actionForm, rreq);
+            }
+        }
+        catch (Exception e)
+        {
+            request.getSession().getServletContext().log("ERROR",e);
+            throw new ServletException(e);
+        }
+        return forward;
+    }
+
+    private void getXmlFiles(ActionForm actionForm, RollerRequest rreq)
+    {
+		ServletContext app = this.getServlet().getServletConfig().getServletContext();
+		String dir = RollerContext.getUploadDir( app );
+		File d = new File(dir + rreq.getUser().getUserName());
+		ArrayList xmlFiles = new ArrayList();
+		if (d.mkdirs() || d.exists())
+		{
+			File[] files = d.listFiles();
+			for (int i=0; i<files.length; i++)
+			{
+				if (!files[i].isDirectory() &&
+					files[i].getName().toLowerCase().endsWith(".xml"))
+					// TODO : later change detection to use FileInfo
+				{
+					xmlFiles.add(files[i].getName());
+				}
+			}
+		}
+		ImportEntriesForm form = (ImportEntriesForm)actionForm;
+		form.setXmlFiles(xmlFiles);
+	}
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/PingSetupAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/PingSetupAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/PingSetupAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/PingSetupAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2005
+ * Anil R. Gangolli. All rights reserved.
+ *
+ * Distributed with the Roller Weblogger Project under the terms of the Roller Software
+ * License
+ */
+
+package org.roller.presentation.weblog.actions;
+
+import org.apache.struts.actions.DispatchAction;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.ActionMessage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xmlrpc.XmlRpcException;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.RollerContext;
+import org.roller.presentation.pings.WeblogUpdatePinger;
+import org.roller.config.PingConfig;
+import org.roller.model.PingTargetManager;
+import org.roller.model.AutoPingManager;
+import org.roller.pojos.PingTargetData;
+import org.roller.pojos.WebsiteData;
+import org.roller.pojos.AutoPingData;
+import org.roller.RollerException;
+import org.roller.config.PingConfig;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collections;
+import java.net.UnknownHostException;
+import java.net.SocketException;
+import java.io.IOException;
+
+
+/**
+ * Actions for setting up automatic ping configuration for a weblog.
+ *
+ * @struts.action name="pingSetupForm" path="/editor/pingSetup" scope="request" parameter="method"
+ * @struts.action-forward name="pingSetup.page" path="/weblog/Pings.jsp"
+ * @struts.action-forward name="pingResult.page" path="/weblog/PingResult.jsp"
+ */
+public class PingSetupAction extends DispatchAction
+{
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(PingSetupAction.class);
+
+    private static final String PING_SETUP_PAGE = "pingSetup.page";
+    private static final String PING_RESULT_PAGE = "pingResult.page";
+
+    /* (non-Javadoc)
+     * @see org.apache.struts.actions.DispatchAction#unspecified(
+     * 	org.apache.struts.action.ActionMapping,
+     *  org.apache.struts.action.ActionForm,
+     *  javax.servlet.http.HttpServletRequest,
+     *  javax.servlet.http.HttpServletResponse)
+     */
+    protected ActionForward unspecified(ActionMapping mapping,
+                                        ActionForm actionForm,
+                                        HttpServletRequest request,
+                                        HttpServletResponse response)
+        throws Exception
+    {
+        return view(mapping, actionForm, request, response);
+    }
+
+    /*
+     * Display the common ping targets with page
+     */
+    public ActionForward view(ActionMapping mapping, ActionForm form,
+                              HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        ActionForward forward = mapping.findForward(PING_SETUP_PAGE);
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
+        WebsiteData website = rreq.getWebsite();
+        try
+        {
+            if (!isAuthorized(rreq))
+            {
+                return mapping.findForward("access-denied");
+            }
+
+            List commonPingTargets = pingTargetMgr.getCommonPingTargets();
+            req.setAttribute("commonPingTargets", commonPingTargets);
+
+            Boolean allowCustomTargets = new Boolean(!PingConfig.getDisallowCustomTargets());
+            req.setAttribute("allowCustomTargets", allowCustomTargets);
+
+            List customPingTargets = allowCustomTargets.booleanValue() ?
+                pingTargetMgr.getCustomPingTargets(website) : Collections.EMPTY_LIST;
+            req.setAttribute("customPingTargets", customPingTargets);
+
+            // Build isEnabled map (keyed by ping target id and values Boolean.TRUE/Boolean.FALSE)
+            Map isEnabled = buildIsEnabledMap(rreq, commonPingTargets, customPingTargets);
+            req.setAttribute("isEnabled", isEnabled);
+
+            return forward;
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action", e);
+            throw new ServletException(e);
+        }
+    }
+
+    /*
+     * Private helper to build a map indexed by ping target id with values Boolean.TRUE and Boolean.FALSE
+     * based on whether the ping target is enabled (has a corresponding auto ping configuration).
+     */
+    private Map buildIsEnabledMap(RollerRequest rreq, List commonPingTargets, List customPingTargets)
+        throws RollerException
+    {
+        AutoPingManager autoPingMgr = rreq.getRoller().getAutopingManager();
+        WebsiteData website = rreq.getWebsite();
+
+        // Build isEnabled map (keyed by ping target id and values Boolean.TRUE/Boolean.FALSE)
+        Map isEnabled = new HashMap();
+        List autopings = autoPingMgr.getAutoPingsByWebsite(website);
+        // Add the enabled auto ping configs with TRUE
+        for (Iterator i = autopings.iterator(); i.hasNext();)
+        {
+            AutoPingData autoPing = (AutoPingData) i.next();
+            isEnabled.put(autoPing.getPingTarget().getId(), Boolean.TRUE);
+        }
+        // Somewhat awkward, but the two loops save building a separate combined list.
+        // Add disabled common ones with FALSE
+        for (Iterator i = commonPingTargets.iterator(); i.hasNext();)
+        {
+            PingTargetData pingTarget = (PingTargetData) i.next();
+            if (isEnabled.get(pingTarget.getId()) == null)
+            {
+                isEnabled.put(pingTarget.getId(), Boolean.FALSE);
+            }
+        }
+        // Add disabled custom ones with FALSE
+        for (Iterator i = customPingTargets.iterator(); i.hasNext();)
+        {
+            PingTargetData pingTarget = (PingTargetData) i.next();
+            if (isEnabled.get(pingTarget.getId()) == null)
+            {
+                isEnabled.put(pingTarget.getId(), Boolean.FALSE);
+            }
+        }
+        return isEnabled;
+    }
+
+    /*
+     * Enable a ping target.
+     */
+    public ActionForward enableSelected(ActionMapping mapping, ActionForm form,
+                                        HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        AutoPingManager autoPingMgr = rreq.getRoller().getAutopingManager();
+        try
+        {
+            if (!isAuthorized(rreq))
+            {
+                return mapping.findForward("access-denied");
+            }
+            PingTargetData pingTarget = select(rreq);
+            AutoPingData autoPing = autoPingMgr.createAutoPing(pingTarget, rreq.getWebsite());
+            autoPingMgr.storeAutoPing(autoPing);
+            rreq.getRoller().commit();
+
+            return view(mapping, form, req, res);
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action", e);
+            throw new ServletException(e);
+        }
+    }
+
+    /*
+     * Load delete confirmation view.
+     */
+    public ActionForward disableSelected(ActionMapping mapping, ActionForm form,
+                                         HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        AutoPingManager autoPingMgr = rreq.getRoller().getAutopingManager();
+        try
+        {
+            if (!isAuthorized(rreq))
+            {
+                return mapping.findForward("access-denied");
+            }
+            PingTargetData pingTarget = select(rreq);
+            autoPingMgr.removeAutoPing(pingTarget, rreq.getWebsite());
+            rreq.getRoller().commit();
+
+            return view(mapping, form, req, res);
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action", e);
+            throw new ServletException(e);
+        }
+    }
+
+    /*
+     * Ping the selected target now.
+     */
+    public ActionForward pingSelectedNow(ActionMapping mapping, ActionForm form,
+                                         HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        try
+        {
+            RollerRequest rreq = RollerRequest.getRollerRequest(req);
+            String absoluteUrl = RollerContext.getRollerContext(req).getAbsoluteContextUrl(req);
+            PingTargetData pingTarget = select(rreq);
+            WebsiteData website = rreq.getWebsite();
+            try
+            {
+                if (!isAuthorized(rreq))
+                {
+                    return mapping.findForward("access-denied");
+                }
+                if (PingConfig.getSuspendPingProcessing())
+                {
+                    if (mLogger.isDebugEnabled()) mLogger.debug("Ping processing is disabled.");
+                    ActionMessages errors = new ActionMessages();
+                    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.pingProcessingIsSuspended"));
+                    saveErrors(req, errors);
+                }
+                else
+                {
+                    WeblogUpdatePinger.PingResult pingResult = WeblogUpdatePinger.sendPing(absoluteUrl, pingTarget, website);
+                    if (pingResult.isError())
+                    {
+                        if (mLogger.isDebugEnabled()) mLogger.debug("Ping Result: " + pingResult);
+                        ActionMessages errors = new ActionMessages();
+                        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.transmittedButErrorReturned"));
+                        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(pingResult.getMessage()));
+                        saveErrors(req, errors);
+                    }
+                    else
+                    {
+                        ActionMessages messages = new ActionMessages();
+                        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.successful"));
+                        saveMessages(req, messages);
+                    }
+                }
+            }
+            catch (IOException ex)
+            {
+                mLogger.debug(ex);
+                ActionMessages errors = new ActionMessages();
+                errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.transmissionFailed"));
+                addSpecificMessages(ex, errors);
+                saveErrors(req, errors);
+            }
+            catch (XmlRpcException ex)
+            {
+                mLogger.debug(ex);
+                ActionMessages errors = new ActionMessages();
+                errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.transmissionFailed"));
+                addSpecificMessages(ex, errors);
+                saveErrors(req, errors);
+            }
+            return mapping.findForward(PING_RESULT_PAGE);
+        }
+        catch (Exception ex)
+        {
+            mLogger.error("ERROR in action", ex);
+            throw new ServletException(ex);
+        }
+    }
+
+    // TODO: Consider unifying with other RollerRequest methods
+    // Private helper to get ping target specified by request
+    private PingTargetData select(RollerRequest rreq) throws RollerException
+    {
+        String pingTargetId = rreq.getRequest().getParameter(RollerRequest.PINGTARGETID_KEY);
+        PingTargetManager pingTargetMgr = rreq.getRoller().getPingTargetManager();
+        if (pingTargetId == null || pingTargetId.length() == 0)
+        {
+            throw new RollerException("Missing ping target id: " + pingTargetId);
+        }
+
+        PingTargetData pingTarget = pingTargetMgr.retrievePingTarget(pingTargetId);
+        if (pingTarget == null)
+        {
+            throw new RollerException("No such ping target id: " + pingTargetId);
+        }
+        return pingTarget;
+    }
+
+    private void addSpecificMessages(Exception ex, ActionMessages errors)
+    {
+        if (ex instanceof UnknownHostException)
+        {
+            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.unknownHost"));
+        }
+        else if (ex instanceof SocketException)
+        {
+            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.networkConnectionFailed"));
+        }
+    }
+
+    private boolean isAuthorized(RollerRequest rreq) throws RollerException
+    {
+        return rreq.isUserAuthorizedToEdit() && !PingConfig.getDisablePingUsage();
+    }
+}

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ReferersAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ReferersAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ReferersAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ReferersAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,152 @@
+
+package org.roller.presentation.weblog.actions;
+
+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.roller.model.RefererManager;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WebsiteData;
+import org.roller.presentation.RollerRequest;
+
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Display today's referers.
+ * @struts.action name="refererForm" path="/editor/referers"
+ *      scope="session" parameter="method"
+ * 
+ * @struts.action-forward name="referers.page" path="/weblog/referers.jsp"
+ */
+public class ReferersAction extends DispatchAction
+{    
+    private static Log mLogger = 
+        LogFactory.getFactory().getInstance(ReferersAction.class);
+        
+    public ActionForward unspecified(
+        ActionMapping       mapping,
+        ActionForm          actionForm,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+        throws Exception
+    {
+        return view(mapping, actionForm, request, response);
+    }
+    
+    /**
+     * execute
+     */
+    public ActionForward view(
+        ActionMapping mapping, ActionForm form,
+        HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        ActionForward forward = mapping.findForward("referers.page");
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        RefererManager refmgr = rreq.getRoller().getRefererManager();
+        try
+        {
+            if ( rreq.isUserAuthorizedToEdit() )
+            {
+                UserData ud = rreq.getUser();
+                
+                req.setAttribute("pageHits",
+                    new Integer(refmgr.getDayHits(rreq.getWebsite())));
+                    
+                req.setAttribute("totalHits",
+                    new Integer(refmgr.getTotalHits(rreq.getWebsite())));
+                    
+                List refs = refmgr.getTodaysReferers(rreq.getWebsite());
+                req.setAttribute("referers",refs);        
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        
+        return forward;
+    }
+    
+    public ActionForward reset(
+        ActionMapping mapping, ActionForm form,
+        HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        this.servlet.log("ReferersAction.reset()");
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        try
+        {
+            if ( rreq.isUserAuthorizedToEdit() )
+            {
+                RefererManager refmgr = rreq.getRoller().getRefererManager();
+                WebsiteData website = rreq.getWebsite();
+                refmgr.forceTurnover(website.getId());
+                rreq.getRoller().commit();
+            }
+            this.servlet.log("ReferersAction.reset(): don't have permission");
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return view(mapping, form, req, res);
+    }
+    
+    public ActionForward delete(
+            ActionMapping mapping, ActionForm form,
+            HttpServletRequest req, HttpServletResponse res)
+        throws Exception
+    {
+        //this.servlet.log("ReferersAction.delete()");
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        try
+        {
+            if ( rreq.isUserAuthorizedToEdit() )
+            {
+                RefererManager refmgr = rreq.getRoller().getRefererManager();
+                WebsiteData website = rreq.getWebsite();
+
+                String[] deleteIds = req.getParameterValues("id");
+                if (deleteIds != null)
+                {
+                    for (int i=0; i<deleteIds.length; i++)
+                    {
+                        refmgr.removeReferer(deleteIds[i]);
+                    }
+                    rreq.getRoller().commit();
+                    ActionMessages messages = new ActionMessages();
+                    messages.add(null, new ActionMessage("referers.deletedReferers"));
+                    saveMessages(req, messages);
+                }
+                else 
+                {
+                    ActionErrors errors = new ActionErrors();
+                    errors.add(null, new ActionError("referers.noReferersSpecified"));
+                    saveErrors(req, errors);
+                }
+            }
+            //this.servlet.log("ReferersAction.delete(): don't have permission");
+        }
+        catch (Exception e)
+        {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return view(mapping, form, req, res);
+    }
+}
+

Added: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,85 @@
+package org.roller.presentation.weblog.actions;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.roller.model.RefererManager;
+import org.roller.pojos.RefererData;
+import org.roller.presentation.RollerContext;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.pagecache.PageCacheFilter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Toggle display of a linkback.
+ * @struts.action name="toggleLinkback" path="/editor/toggleLinkback" scope="session"
+ */
+public class ToggleLinkbackDisplayAction extends Action
+{
+    private static Log mLogger = LogFactory.getFactory().getInstance(
+        ToggleLinkbackDisplayAction.class);
+        
+	/**
+	 * execute
+     */
+	public ActionForward execute(
+		ActionMapping mapping, ActionForm form,
+		HttpServletRequest req, HttpServletResponse res)
+		throws Exception
+	{
+         
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        String userName = rreq.getUser().getUserName();
+
+        try
+        {
+            if ( rreq.isUserAuthorizedToEdit() )
+            {
+                String refid = req.getParameter(RollerRequest.REFERERID_KEY);
+                if ( refid != null )
+                {
+                    RefererManager refmgr = 
+                        rreq.getRoller().getRefererManager();                        
+                    RefererData ref = refmgr.retrieveReferer(refid); 
+                    boolean was = ref.getVisible()==null ? 
+                                  false : ref.getVisible().booleanValue(); 
+                    ref.setVisible(Boolean.valueOf( !was )); // what up, dog?                     
+                    ref.save();
+                    
+                    rreq.getRoller().commit();
+                    
+                    PageCacheFilter.removeFromCache( req, rreq.getUser() );
+                }                
+            }
+        }
+        catch (Exception e)
+        {
+            mLogger.error("Toggling linkback display",e);
+            throw new ServletException(e);
+        }
+        
+        // forward to user's website URL
+		String url = null;
+		try
+		{
+			RollerContext rctx = RollerContext.getRollerContext(
+				rreq.getServletContext());
+			url = rctx.getContextUrl( req, userName);
+			res.sendRedirect(url);
+		}
+		catch (Exception e)
+		{
+			mLogger.error("Unexpected exception",e);
+		}
+
+        return null;
+	}
+}
+



Mime
View raw message