You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/04/12 22:14:15 UTC

svn commit: r528219 - in /roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions: PlanetGroupsAction.java PlanetSubscriptionsAction.java

Author: agilliland
Date: Thu Apr 12 13:14:14 2007
New Revision: 528219

URL: http://svn.apache.org/viewvc?view=rev&rev=528219
Log:
code reformatting.


Modified:
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java
    roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java

Modified: roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java?view=diff&rev=528219&r1=528218&r2=528219
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java (original)
+++ roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetGroupsAction.java Thu Apr 12 13:14:14 2007
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.roller.planet.ui.admin.struts.actions;
 
 import java.io.IOException;
@@ -45,105 +46,88 @@
 import org.apache.roller.ui.core.RollerSession;
 
 
-/////////////////////////////////////////////////////////////////////////////
 /**
  * Add, remove, and view user defined groups.
- * 
+ *
  * @struts.action name="planetGroupForm" path="/roller-ui/admin/planetGroups"
  *                scope="request" parameter="method"
- * 
- * @struts.action-forward name="planetGroups.page" 
+ *
+ * @struts.action-forward name="planetGroups.page"
  *                        path=".PlanetGroups"
  */
-public final class PlanetGroupsAction extends DispatchAction
-{
-    private static Log logger = LogFactory.getFactory().getInstance(
-            PlanetGroupsAction.class);
-
+public final class PlanetGroupsAction extends DispatchAction {
+    
+    private static Log logger = LogFactory.getLog(PlanetGroupsAction.class);
+    
+    
     /** Populate page model and forward to subscription page */
     public ActionForward getGroups(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
-            HttpServletResponse response) throws IOException, ServletException
-    {
+            HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetGroups.page");
-        try
-        {
+        try {
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            if (RollerSession.getRollerSession(request).isGlobalAdminUser())
-            {
+            if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                 PlanetGroupForm form = (PlanetGroupForm)actionForm;
-                if (request.getParameter("groupHandle") != null)
-                {
+                if (request.getParameter("groupHandle") != null) {
                     String handle = request.getParameter("groupHandle");
                     PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                     PlanetGroupData group = pmgr.getGroup(defaultPlanet, handle);
                     form.copyFrom(group, request.getLocale());
-                }
-                else 
-                {
+                } else {
                     form.doReset(mapping, request);
                 }
-                request.setAttribute("model", 
-                    new GroupsPageModel(request, response, mapping));
-            }
-            else
-            {
+                request.setAttribute("model",
+                        new GroupsPageModel(request, response, mapping));
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             request.getSession().getServletContext().log("ERROR", e);
             throw new ServletException(e);
         }
         return forward;
     }
-
+    
+    
     /** Cancel editing, reset form */
     public ActionForward cancelEditing(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
-            HttpServletResponse response) throws IOException, ServletException
-    {
+            HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetGroups.page");
-        try
-        {
-            if (RollerSession.getRollerSession(request).isGlobalAdminUser())
-            {
-                PlanetGroupForm form = (PlanetGroupForm)actionForm;              
+        try {
+            if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
+                PlanetGroupForm form = (PlanetGroupForm)actionForm;
                 form.doReset(mapping, request);
                 
-                request.setAttribute("model", 
-                    new GroupsPageModel(request, response, mapping));
-            }
-            else
-            {
+                request.setAttribute("model",
+                        new GroupsPageModel(request, response, mapping));
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             request.getSession().getServletContext().log("ERROR", e);
             throw new ServletException(e);
         }
         return forward;
     }
     
+    
     /** Delete subscription, reset form  */
     public ActionForward deleteGroup(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
-            HttpServletResponse response) throws IOException, ServletException 
-    {
+            HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetGroups.page");
-        try
-        {
+        try {
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            if (RollerSession.getRollerSession(request).isGlobalAdminUser())
-            {
+            if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                 PlanetGroupForm form = (PlanetGroupForm)actionForm;
-                if (form.getHandle() != null)
-                {
+                if (form.getHandle() != null) {
                     PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                     PlanetGroupData group = pmgr.getGroup(defaultPlanet, form.getHandle());
                     pmgr.deleteGroup(group);
@@ -153,56 +137,47 @@
                     
                     form.doReset(mapping, request);
                     
-                    request.setAttribute("model", 
-                        new GroupsPageModel(request, response, mapping));
+                    request.setAttribute("model",
+                            new GroupsPageModel(request, response, mapping));
                     
                     ActionMessages messages = new ActionMessages();
-                    messages.add(null, 
-                        new ActionMessage("planetSubscription.success.deleted"));
+                    messages.add(null,
+                            new ActionMessage("planetSubscription.success.deleted"));
                     saveMessages(request, messages);
                 }
-            }
-            else
-            {
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             ActionErrors errors = new ActionErrors();
             errors.add(null, new ActionError("planetGroup.error.deleting"));
-            saveErrors(request, errors);       
+            saveErrors(request, errors);
         }
         return forward;
     }
-
+    
+    
     /** Save subscription, add to "external" group */
     public ActionForward saveGroup(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
-            HttpServletResponse response) throws IOException, ServletException
-    {
+            HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetGroups.page");
-        try
-        {
+        try {
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            if (RollerSession.getRollerSession(request).isGlobalAdminUser())
-            {
+            if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
                 PlanetGroupForm form = (PlanetGroupForm)actionForm;
                 PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                 PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
                 ActionErrors errors = validate(pmgr, form);
-                if (errors.isEmpty())
-                {
+                if (errors.isEmpty()) {
                     PlanetGroupData group = null;
-                    if (form.getId() == null || form.getId().trim().length() == 0)
-                    {
+                    if (form.getId() == null || form.getId().trim().length() == 0) {
                         group = new PlanetGroupData();
                         group.setPlanet(defaultPlanet);
-                    }
-                    else 
-                    {
+                    } else {
                         group = pmgr.getGroupById(form.getId());
-                    }                
+                    }
                     form.copyTo(group, request.getLocale());
                     
                     // the form copy is a little dumb and will set the id value
@@ -212,88 +187,76 @@
                         group.setId(null);
                     }
                     
-                    pmgr.saveGroup(group);  
+                    pmgr.saveGroup(group);
                     PlanetFactory.getPlanet().flush();
-
+                    
                     ActionMessages messages = new ActionMessages();
-                    messages.add(null, 
+                    messages.add(null,
                             new ActionMessage("planetGroups.success.saved"));
                     saveMessages(request, messages);
                     form.doReset(mapping, request);
-
-                    request.setAttribute("model", 
+                    
+                    request.setAttribute("model",
                             new GroupsPageModel(request, response, mapping));
-                }
-                else
-                {
+                } else {
                     saveErrors(request, errors);
                 }
-            }
-            else
-            {
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             ActionErrors errors = new ActionErrors();
             errors.add(null, new ActionError(
-              "planetSubscriptions.error.duringSave",e.getRootCauseMessage()));
+                    "planetSubscriptions.error.duringSave",e.getRootCauseMessage()));
             saveErrors(request, errors);
         }
         return forward;
     }
     
+    
     /** Validate posted group */
     private ActionErrors validate(
-            PlanetManager planet, PlanetGroupForm form)
-    {
+            PlanetManager planet, PlanetGroupForm form) {
         ActionErrors errors = new ActionErrors();
-        if (form.getTitle()==null || form.getTitle().trim().length()==0)
-        {            
+        if (form.getTitle()==null || form.getTitle().trim().length()==0) {
             errors.add(null, new ActionError("planetGroups.error.title"));
         }
-        if (form.getHandle()==null || form.getHandle().trim().length()==0)
-        {            
+        if (form.getHandle()==null || form.getHandle().trim().length()==0) {
             errors.add(null, new ActionError("planetGroups.error.handle"));
         }
-        if (form.getHandle() != null && 
-        (form.getHandle().equals("all") || form.getHandle().equals("external")))
-        {
-           errors.add(null, new ActionError("planetGroups.error.nameReserved"));
+        if (form.getHandle() != null &&
+                (form.getHandle().equals("all") || form.getHandle().equals("external"))) {
+            errors.add(null, new ActionError("planetGroups.error.nameReserved"));
         }
         return errors;
     }
-
+    
+    
     /** Page model */
-    public class GroupsPageModel extends BasePageModel
-    {
+    public class GroupsPageModel extends BasePageModel {
         private List groups = new ArrayList();
         private boolean unconfigured = false;
         public GroupsPageModel(
-            HttpServletRequest request,
-            HttpServletResponse response,
-            ActionMapping mapping) throws RollerException
-        {
+                HttpServletRequest request,
+                HttpServletResponse response,
+                ActionMapping mapping) throws RollerException {
             super("planetGroups.pagetitle", request, response, mapping);
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();            
+            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
             PlanetData defaultPlanet = pmgr.getPlanet("zzz_default_planet_zzz");
             PlanetGroupData externalGroup = pmgr.getGroup(defaultPlanet, "external");
             Iterator allgroups = defaultPlanet.getGroups().iterator();
-            while (allgroups.hasNext()) 
-            {
+            while (allgroups.hasNext()) {
                 PlanetGroupData agroup = (PlanetGroupData)allgroups.next();
                 if (    !agroup.getHandle().equals("external")
-                     && !agroup.getHandle().equals("all")) 
-                  {
-                      groups.add(agroup);
-                  }
+                && !agroup.getHandle().equals("all")) {
+                    groups.add(agroup);
+                }
             }
         }
-        public List getGroups()
-        {
+        public List getGroups() {
             return groups;
         }
     }
+    
 }

Modified: roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java
URL: http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java?view=diff&rev=528219&r1=528218&r2=528219
==============================================================================
--- roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java (original)
+++ roller/trunk/src/org/apache/roller/planet/ui/admin/struts/actions/PlanetSubscriptionsAction.java Thu Apr 12 13:14:14 2007
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.roller.planet.ui.admin.struts.actions;
 
 import java.io.IOException;
@@ -49,8 +50,6 @@
 import org.apache.roller.ui.core.RollerSession;
 
 
-
-/////////////////////////////////////////////////////////////////////////////
 /**
  * Add, remove, and view existing subscriptions in a group.
  * If no group is specified via the groupHandle parameter, then uses "external".
@@ -62,13 +61,15 @@
  *                        path=".PlanetSubscriptions"
  */
 public final class PlanetSubscriptionsAction extends DispatchAction {
-    private static Log logger = LogFactory.getFactory().getInstance(
-            PlanetSubscriptionsAction.class);
+    
+    private static Log logger = LogFactory.getLog(PlanetSubscriptionsAction.class);
+    
     
     /** Populate page model and forward to subscription page */
     public ActionForward getSubscriptions(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetSubscriptions.page");
         try {
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
@@ -103,10 +104,12 @@
         return forward;
     }
     
+    
     /** Cancel editing, reset form */
     public ActionForward cancelEditing(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetSubscriptions.page");
         try {
             if (RollerSession.getRollerSession(request).isGlobalAdminUser()) {
@@ -135,10 +138,12 @@
         return forward;
     }
     
+    
     /** Delete subscription, reset form  */
     public ActionForward deleteSubscription(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetSubscriptions.page");
         try {
             //RollerRequest rreq = RollerRequest.getRollerRequest(request);
@@ -185,10 +190,12 @@
         return forward;
     }
     
+    
     /** Save subscription, add to current group */
     public ActionForward saveSubscription(ActionMapping mapping,
             ActionForm actionForm, HttpServletRequest request,
             HttpServletResponse response) throws IOException, ServletException {
+        
         ActionForward forward = mapping.findForward("planetSubscriptions.page");
         try {
             PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
@@ -207,19 +214,19 @@
                 PlanetSubscriptionData sub = null;
                 ActionErrors errors = validate(pmgr, form);
                 if (errors.isEmpty()) {
-                    if (form.getId() == null || form.getId().trim().length() == 0) {                        
-                        // Adding new subscription to group                        
+                    if (form.getId() == null || form.getId().trim().length() == 0) {
+                        // Adding new subscription to group
                         // But, does subscription to that feed already exist?
                         if (form.getFeedURL() != null) {
-                            sub = pmgr.getSubscription(form.getFeedURL()); 
+                            sub = pmgr.getSubscription(form.getFeedURL());
                         }
                         if (sub != null) {
                             // Yes, we'll use it instead
                             messages.add(null, new ActionMessage(
-                                "planetSubscription.foundExisting", sub.getTitle()));
+                                    "planetSubscription.foundExisting", sub.getTitle()));
                         } else {
                             // No, add new subscription
-                            sub = new PlanetSubscriptionData(); 
+                            sub = new PlanetSubscriptionData();
                             form.copyTo(sub, request.getLocale());
                             
                             // the form copy is a little dumb and will set the id value
@@ -228,16 +235,16 @@
                             if(sub.getId() != null && sub.getId().trim().equals("")) {
                                 sub.setId(null);
                             }
-
+                            
                             pmgr.saveSubscription(sub);
-                        }                        
+                        }
                         targetGroup.getSubscriptions().add(sub);
                         
                     } else {
                         // User editing an existing subscription within a group
                         sub = pmgr.getSubscriptionById(form.getId());
-                        form.copyTo(sub, request.getLocale());                        
-                    }                    
+                        form.copyTo(sub, request.getLocale());
+                    }
                     form.setGroupHandle(groupHandle);
                     pmgr.saveGroup(targetGroup);
                     PlanetFactory.getPlanet().flush();
@@ -258,21 +265,23 @@
         } catch (RollerException re) {
             ActionErrors errors = new ActionErrors();
             errors.add(null, new ActionError(
-                "planetSubscriptions.error.duringSave", re.getRootCauseMessage()));
+                    "planetSubscriptions.error.duringSave", re.getRootCauseMessage()));
             saveErrors(request, errors);
         } catch (Exception e) {
             ActionErrors errors = new ActionErrors();
             errors.add(null, new ActionError(
-                "planetSubscriptions.error.duringSave", e.getMessage()));
+                    "planetSubscriptions.error.duringSave", e.getMessage()));
             saveErrors(request, errors);
             logger.error("Unexpected error saving subscription", e);
         }
         return forward;
     }
     
+    
     /** Validate posted subscription, fill in blanks via Technorati */
     private ActionErrors validate(
             PlanetManager pmgr, PlanetSubscriptionFormEx form) {
+        
         String technoratiTitle = null;
         String technoratiFeedUrl = null;
         int inboundlinks = -1;
@@ -284,7 +293,7 @@
                 PropertyData proxyHostProp = props.getProperty("proxyHost");
                 PropertyData proxyPortProp = props.getProperty("proxyPort");
                 if (proxyHostProp != null && proxyPortProp != null) {
-                    technorati = new Technorati(proxyHostProp.getValue(), Integer.parseInt(proxyPortProp.getValue())); 
+                    technorati = new Technorati(proxyHostProp.getValue(), Integer.parseInt(proxyPortProp.getValue()));
                 } else {
                     technorati = new Technorati();
                 }
@@ -323,6 +332,7 @@
         return errors;
     }
     
+    
     /** Page model, includes subscriptions in "external" group */
     public class SubscriptionsPageModel extends BasePageModel {
         private List subscriptions = null;
@@ -359,5 +369,5 @@
             return subscriptions;
         }
     }
+    
 }
-