roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1616999 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/ui/struts2/admin/ java/org/apache/roller/weblogger/ui/struts2/common/ resources/ webapp/WEB-INF/ webapp/WEB-INF/jsps/admin/
Date Sat, 09 Aug 2014 17:43:04 GMT
Author: gmazza
Date: Sat Aug  9 17:43:03 2014
New Revision: 1616999

URL: http://svn.apache.org/r1616999
Log:
CommonPingTargets and PingTargetsBase merged into PingTargets

Added:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetBean.java
      - copied, changed from r1616933, roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetFormBean.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargets.java
      - copied, changed from r1616998, roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/CommonPingTargets.java
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/admin/PingTargets.jsp
      - copied unchanged from r1616933, roller/trunk/app/src/main/webapp/WEB-INF/jsps/admin/CommonPingTargets.jsp
Removed:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/CommonPingTargets.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/
    roller/trunk/app/src/main/webapp/WEB-INF/jsps/admin/CommonPingTargets.jsp
Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetAdd.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetEdit.java
    roller/trunk/app/src/main/resources/struts.xml
    roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetAdd.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetAdd.java?rev=1616999&r1=1616998&r2=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetAdd.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetAdd.java
Sat Aug  9 17:43:03 2014
@@ -27,7 +27,6 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
 import org.apache.roller.weblogger.pojos.GlobalPermission;
 import org.apache.roller.weblogger.pojos.PingTarget;
-import org.apache.roller.weblogger.ui.struts2.common.PingTargetFormBean;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 
@@ -38,7 +37,7 @@ public class PingTargetAdd extends UIAct
     private static Log log = LogFactory.getLog(PingTargetAdd.class);
 
     // a bean for managing submitted data
-    private PingTargetFormBean bean = new PingTargetFormBean();
+    private PingTargetBean bean = new PingTargetBean();
 
     public PingTargetAdd() {
         this.desiredMenu = "admin";
@@ -54,8 +53,8 @@ public class PingTargetAdd extends UIAct
     }
 
     public String save() {
-        PingTarget pingTarget = new PingTarget(null, getBean().getName(),
-                getBean().getPingUrl(), false);
+        PingTarget pingTarget = new PingTarget(null, bean.getName(),
+                bean.getPingUrl(), false);
 
         myValidate(pingTarget);
 
@@ -101,11 +100,11 @@ public class PingTargetAdd extends UIAct
         }
     }
 
-    public PingTargetFormBean getBean() {
+    public PingTargetBean getBean() {
         return bean;
     }
 
-    public void setBean(PingTargetFormBean bean) {
+    public void setBean(PingTargetBean bean) {
         this.bean = bean;
     }
 }

Copied: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetBean.java
(from r1616933, roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetFormBean.java)
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetBean.java?p2=roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetBean.java&p1=roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetFormBean.java&r1=1616933&r2=1616999&rev=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/common/PingTargetFormBean.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetBean.java
Sat Aug  9 17:43:03 2014
@@ -16,7 +16,7 @@
  * directory of this distribution.
  */
 
-package org.apache.roller.weblogger.ui.struts2.common;
+package org.apache.roller.weblogger.ui.struts2.admin;
 
 import org.apache.roller.weblogger.pojos.PingTarget;
 
@@ -24,7 +24,7 @@ import org.apache.roller.weblogger.pojos
 /**
  * Form bean used by ping target actions.
  */
-public class PingTargetFormBean {
+public class PingTargetBean {
     
     private String id = null;
     private String name = null;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetEdit.java?rev=1616999&r1=1616998&r2=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetEdit.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargetEdit.java
Sat Aug  9 17:43:03 2014
@@ -25,7 +25,6 @@ import org.apache.roller.weblogger.Weblo
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
 import org.apache.roller.weblogger.pojos.PingTarget;
-import org.apache.roller.weblogger.ui.struts2.common.PingTargetFormBean;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 /**
@@ -39,7 +38,7 @@ public class PingTargetEdit extends UIAc
     private PingTarget pingTarget = null;
 
     // a bean for managing submitted data
-    private PingTargetFormBean bean = new PingTargetFormBean();
+    private PingTargetBean bean = new PingTargetBean();
 
     public PingTargetEdit() {
         this.desiredMenu = "admin";
@@ -57,7 +56,7 @@ public class PingTargetEdit extends UIAc
             try {
                 pingTarget = pingTargetMgr.getPingTarget(getBean().getId());
             } catch (WebloggerException ex) {
-                log.error("Error looking up ping target - "+getBean().getId());
+                log.error("Error looking up ping target - " + getBean().getId());
             }
             if(pingTarget == null) {
                 addError("pingTarget.notFound", getBean().getId());
@@ -137,11 +136,11 @@ public class PingTargetEdit extends UIAc
         }
     }
 
-    public PingTargetFormBean getBean() {
+    public PingTargetBean getBean() {
         return bean;
     }
 
-    public void setBean(PingTargetFormBean bean) {
+    public void setBean(PingTargetBean bean) {
         this.bean = bean;
     }
 

Copied: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargets.java
(from r1616998, roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/CommonPingTargets.java)
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargets.java?p2=roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargets.java&p1=roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/CommonPingTargets.java&r1=1616998&r2=1616999&rev=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/CommonPingTargets.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/PingTargets.java
Sat Aug  9 17:43:03 2014
@@ -20,45 +20,43 @@ package org.apache.roller.weblogger.ui.s
 
 import java.util.Collections;
 import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
-import org.apache.roller.weblogger.pojos.GlobalPermission;
-import org.apache.roller.weblogger.ui.struts2.common.PingTargetsBase;
-
+import org.apache.roller.weblogger.pojos.PingTarget;
+import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 /**
  * Admin action for managing global ping targets.
  */
-public class CommonPingTargets extends PingTargetsBase {
-    
-    private static Log log = LogFactory.getLog(CommonPingTargets.class);
+public class PingTargets extends UIAction {
     
+    private static Log log = LogFactory.getLog(PingTargets.class);
     
-    public CommonPingTargets() {
+    public PingTargets() {
         this.actionName = "commonPingTargets";
         this.desiredMenu = "admin";
         this.pageTitle = "commonPingTargets.commonPingTargets";
     }
-    
-    
-    public List<String> requiredGlobalPermissionActions() {
-        return Collections.singletonList(GlobalPermission.ADMIN);
-    }
-    
+
+    // list of available ping targets
+    private List<PingTarget> pingTargets = Collections.emptyList();
+
+    // ping target we are working on, if any
+    private PingTarget pingTarget = null;
+
+    // id of the ping target to work on
+    private String pingTargetId = null;
+
     // no weblog required
     public boolean isWeblogRequired() {
         return false;
     }
-    
-    
-    protected Log getLogger() {
-        return log;
-    }
-    
-    
+
     public void loadPingTargets() {
         try {
             PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
@@ -68,8 +66,31 @@ public class CommonPingTargets extends P
             addError("commonPingTargets.error.loading");
         }
     }
-    
-    
+
+    // prepare method needs to set ping targets list
+    public void myPrepare() {
+
+        // load list of ping targets
+        loadPingTargets();
+
+        // load specified ping target if possible
+        if(!StringUtils.isEmpty(getPingTargetId())) {
+            try {
+                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
+                setPingTarget(pingTargetMgr.getPingTarget(getPingTargetId()));
+            } catch (WebloggerException ex) {
+                log.error("Error looking up ping target - " + getPingTargetId(), ex);
+            }
+        }
+    }
+
+    /**
+     * Display the ping targets.
+     */
+    public String execute() {
+        return LIST;
+    }
+
     /**
      * Set a ping target auto enabled to true.
      */
@@ -83,7 +104,7 @@ public class CommonPingTargets extends P
                 pingTargetMgr.savePingTarget(getPingTarget());
                 WebloggerFactory.getWeblogger().flush();
             } catch (Exception ex) {
-                getLogger().error("Error saving ping target", ex);
+                log.error("Error saving ping target", ex);
                 addError("commonPingTargets.error.saving");
             }
         } else {
@@ -107,7 +128,7 @@ public class CommonPingTargets extends P
                 pingTargetMgr.savePingTarget(getPingTarget());
                 WebloggerFactory.getWeblogger().flush();
             } catch (Exception ex) {
-                getLogger().error("Error saving ping target", ex);
+                log.error("Error saving ping target", ex);
                 addError("commonPingTargets.error.saving");
             }
         } else {
@@ -116,5 +137,73 @@ public class CommonPingTargets extends P
         
         return LIST;
     }
-    
+
+    /**
+     * Delete a ping target (load delete confirmation view).
+     */
+    public String deleteConfirm() {
+
+        if(getPingTarget() != null) {
+            setPageTitle("pingTarget.confirmRemoveTitle");
+
+            return "confirm";
+        } else {
+            addError("pingTarget.notFound",getPingTargetId());
+        }
+
+        return LIST;
+    }
+
+
+    /**
+     * Delete a ping target.
+     */
+    public String delete() {
+
+        if(getPingTarget() != null) {
+
+            try {
+                PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
+                pingTargetMgr.removePingTarget(getPingTarget());
+                WebloggerFactory.getWeblogger().flush();
+
+                // remove deleted target from list
+                getPingTargets().remove(getPingTarget());
+
+                addMessage("pingTarget.successfullyDeleted", getPingTarget().getName());
+
+            } catch (WebloggerException ex) {
+                log.error("Error deleting ping target - " + getPingTargetId(), ex);
+                addError("pingTarget.errorDeleting", getPingTargetId());
+            }
+        } else {
+            addError("pingTarget.notFound", getPingTargetId());
+        }
+
+        return LIST;
+    }
+
+    public List<PingTarget> getPingTargets() {
+        return pingTargets;
+    }
+
+    public void setPingTargets(List<PingTarget> pingTargets) {
+        this.pingTargets = pingTargets;
+    }
+
+    public PingTarget getPingTarget() {
+        return pingTarget;
+    }
+
+    public void setPingTarget(PingTarget pingTarget) {
+        this.pingTarget = pingTarget;
+    }
+
+    public String getPingTargetId() {
+        return pingTargetId;
+    }
+
+    public void setPingTargetId(String pingTargetId) {
+        this.pingTargetId = pingTargetId;
+    }
 }

Modified: roller/trunk/app/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/struts.xml?rev=1616999&r1=1616998&r2=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/struts.xml (original)
+++ roller/trunk/app/src/main/resources/struts.xml Sat Aug  9 17:43:03 2014
@@ -188,8 +188,8 @@
         </action>
         
         <action name="commonPingTargets!*" method="{1}"
-                class="org.apache.roller.weblogger.ui.struts2.admin.CommonPingTargets">
-            <result name="list" type="tiles">.CommonPingTargets</result>
+                class="org.apache.roller.weblogger.ui.struts2.admin.PingTargets">
+            <result name="list" type="tiles">.PingTargets</result>
             <result name="confirm" type="tiles">.PingTargetConfirm</result>
         </action>
         

Modified: roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml?rev=1616999&r1=1616998&r2=1616999&view=diff
==============================================================================
--- roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml (original)
+++ roller/trunk/app/src/main/webapp/WEB-INF/tiles.xml Sat Aug  9 17:43:03 2014
@@ -183,8 +183,8 @@
         <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-checkboxlistFix.jsp"
/>
     </definition>
     
-    <definition name=".CommonPingTargets" extends=".tiles-tabbedpage" >
-        <put-attribute name="content" value="/WEB-INF/jsps/admin/CommonPingTargets.jsp"
/>
+    <definition name=".PingTargets" extends=".tiles-tabbedpage" >
+        <put-attribute name="content" value="/WEB-INF/jsps/admin/PingTargets.jsp" />
     </definition>
     
     <definition name=".PingTargetConfirm" extends=".tiles-tabbedpage" >



Mime
View raw message