You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ga...@apache.org on 2006/07/22 20:33:14 UTC
svn commit: r424615 [1/2] - in
/incubator/roller/branches/roller_3.0/src/org/apache/roller: config/ pojos/
ui/admin/struts/actions/ ui/authoring/struts/actions/ ui/core/pings/ util/
Author: gangolli
Date: Sat Jul 22 11:33:13 2006
New Revision: 424615
URL: http://svn.apache.org/viewvc?rev=424615&view=rev
Log:
Reformat several files of my original authorship according to newer Roller code style. Reformatting and import optimization only.
Modified:
incubator/roller/branches/roller_3.0/src/org/apache/roller/config/PingConfig.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/AutoPingData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingCategoryRestrictionData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingQueueEntryData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingTargetData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/CommonPingTargetsAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/BasePingTargetsAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CustomPingTargetsAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/PingSetupAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/pings/PingQueueProcessor.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/pings/PingQueueTask.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/pings/WeblogUpdatePinger.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/util/PropertyExpander.java
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/config/PingConfig.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/config/PingConfig.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/config/PingConfig.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/config/PingConfig.java Sat Jul 22 11:33:13 2006
@@ -38,14 +38,12 @@
*
* @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
*/
-public class PingConfig
-{
+public class PingConfig {
private static final Log logger = LogFactory.getLog(PingConfig.class);
// Inhibit construction
- private PingConfig()
- {
+ private PingConfig() {
}
// Config property for maximim ping attempts.
@@ -98,10 +96,8 @@
*
* @return the configured (or default) maximum number of ping attempts
*/
- public static int getMaxPingAttempts()
- {
- return getIntegerProperty(MAX_PING_ATTEMPTS_PROP, MAX_PING_ATTEMPTS_DEFAULT,
- MAX_PING_ATTEMPTS_MIN, MAX_PING_ATTEMPTS_MAX);
+ public static int getMaxPingAttempts() {
+ return getIntegerProperty(MAX_PING_ATTEMPTS_PROP, MAX_PING_ATTEMPTS_DEFAULT, MAX_PING_ATTEMPTS_MIN, MAX_PING_ATTEMPTS_MAX);
}
/**
@@ -109,10 +105,8 @@
*
* @return the configured (or default) queue processing interval in minutes.
*/
- public static int getQueueProcessingIntervalMins()
- {
- return getIntegerProperty(QUEUE_PROCESSING_INTERVAL_PROP, QUEUE_PROCESSING_INTERVAL_DEFAULT,
- QUEUE_PROCESSING_INTERVAL_MIN, QUEUE_PROCESSING_INTERVAL_MAX);
+ public static int getQueueProcessingIntervalMins() {
+ return getIntegerProperty(QUEUE_PROCESSING_INTERVAL_PROP, QUEUE_PROCESSING_INTERVAL_DEFAULT, QUEUE_PROCESSING_INTERVAL_MIN, QUEUE_PROCESSING_INTERVAL_MAX);
}
@@ -122,8 +116,7 @@
*
* @return the configured (or default) value of the logs only setting.
*/
- public static boolean getLogPingsOnly()
- {
+ public static boolean getLogPingsOnly() {
return getBooleanProperty(PINGS_LOG_ONLY_PROP, PINGS_LOG_ONLY_DEFAULT);
}
@@ -133,8 +126,7 @@
*
* @return the configured (or default) value of the "disallow custom targets" setting.
*/
- public static boolean getDisallowCustomTargets()
- {
+ public static boolean getDisallowCustomTargets() {
return getBooleanProperty(PINGS_DISALLOW_CUSTOM_TARGETS_PROP, PINGS_DISALLOW_CUSTOM_TARGETS_DEFAULT);
}
@@ -145,8 +137,7 @@
*
* @return the configured (or default) value of the enable ping usage setting.
*/
- public static boolean getDisablePingUsage()
- {
+ public static boolean getDisablePingUsage() {
return getBooleanProperty(PINGS_DISABLE_PING_USAGE_PROP, PINGS_DISABLE_PING_USAGE_DEFAULT);
}
@@ -157,8 +148,7 @@
*
* @return the configured (or default) value of the suspend ping processing setting.
*/
- public static boolean getSuspendPingProcessing()
- {
+ public static boolean getSuspendPingProcessing() {
return RollerRuntimeConfig.getBooleanProperty(PINGS_SUSPEND_PING_PROCESSING_PROP);
}
@@ -175,42 +165,38 @@
*
* @see org.apache.roller.presentation.RollerContext#contextInitialized(javax.servlet.ServletContextEvent)
*/
- public static void initializeCommonTargets() throws RollerException
- {
+ public static void initializeCommonTargets() throws RollerException {
String configuredVal = RollerConfig.getProperty(PINGS_INITIAL_COMMON_TARGETS_PROP);
- if (configuredVal == null || configuredVal.trim().length() == 0)
- {
- if (logger.isDebugEnabled()) logger.debug("No (or empty) value of " + PINGS_INITIAL_COMMON_TARGETS_PROP + " present in the configuration. Skipping initialization of commmon targets.");
+ if (configuredVal == null || configuredVal.trim().length() == 0) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No (or empty) value of " + PINGS_INITIAL_COMMON_TARGETS_PROP + " present in the configuration. Skipping initialization of commmon targets.");
+ }
return;
}
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
- if (!pingTargetMgr.getCommonPingTargets().isEmpty())
- {
- if (logger.isDebugEnabled()) logger.debug("Some common ping targets are present in the database already. Skipping initialization.");
+ if (!pingTargetMgr.getCommonPingTargets().isEmpty()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Some common ping targets are present in the database already. Skipping initialization.");
+ }
return;
}
String[] configuredTargets = configuredVal.trim().split(",");
- for (int i = 0; i < configuredTargets.length; i++)
- {
+ for (int i = 0; i < configuredTargets.length; i++) {
// Trim space around the target spec
String thisTarget = configuredTargets[i].trim();
// skip empty ones
if (thisTarget.length() == 0) continue;
// parse the ith target and store it
Matcher m = PING_TARGET_SPEC.matcher(configuredTargets[i].trim());
- if (m.matches() && m.groupCount() == 2)
- {
+ if (m.matches() && m.groupCount() == 2) {
String name = m.group(1);
String url = m.group(2);
logger.info("Creating common ping target '" + name + "' from configuration properties.");
PingTargetData pingTarget = new PingTargetData(null, name, url, null, false);
pingTargetMgr.savePingTarget(pingTarget);
- }
- else
- {
- logger.error("Unable to parse configured initial ping target '" + configuredTargets[i] +
- "'. Skipping this target. Check your setting of the property " + PINGS_INITIAL_COMMON_TARGETS_PROP);
+ } else {
+ logger.error("Unable to parse configured initial ping target '" + configuredTargets[i] + "'. Skipping this target. Check your setting of the property " + PINGS_INITIAL_COMMON_TARGETS_PROP);
}
}
}
@@ -228,28 +214,24 @@
* @return the value as an integer; the default value if no configured value is present or if the configured value
* is out of the specified range.
*/
- private static int getIntegerProperty(String propName, int defaultValue, int min, int max)
- {
+ private static int getIntegerProperty(String propName, int defaultValue, int min, int max) {
String configuredVal = RollerConfig.getProperty(propName);
- if (configuredVal == null)
- {
- if (logger.isDebugEnabled()) logger.debug("PingConfig property '" + propName + "' is not present in the configuration. Using default value: " + defaultValue);
+ if (configuredVal == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("PingConfig property '" + propName + "' is not present in the configuration. Using default value: " + defaultValue);
+ }
return defaultValue;
}
int val;
- try
- {
+ try {
val = Integer.parseInt(configuredVal);
- }
- catch (NumberFormatException ex)
- {
+ } catch (NumberFormatException ex) {
logger.error("ERROR: PingConfig property '" + propName + "' is not an integer value. Using default value: " + defaultValue);
return defaultValue;
}
- if (val < min || val > max)
- {
+ if (val < min || val > max) {
logger.error("ERROR: PingConfig property '" + propName + "' is outside the required range (" + min + ", " + max + "). Using default value: " + defaultValue);
return defaultValue;
}
@@ -264,12 +246,12 @@
* @param defaultValue the default value if the property is not present
* @return the configured value or the default if it the configured value is not present.
*/
- private static boolean getBooleanProperty(String propName, boolean defaultValue)
- {
+ private static boolean getBooleanProperty(String propName, boolean defaultValue) {
String configuredVal = RollerConfig.getProperty(propName);
- if (configuredVal == null)
- {
- if (logger.isDebugEnabled()) logger.debug("PingConfig property '" + propName + "' is not present in the configuration. Using default value: " + defaultValue);
+ if (configuredVal == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("PingConfig property '" + propName + "' is not present in the configuration. Using default value: " + defaultValue);
+ }
return defaultValue;
}
return Boolean.valueOf(configuredVal).booleanValue();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/AutoPingData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/AutoPingData.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/AutoPingData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/AutoPingData.java Sat Jul 22 11:33:13 2006
@@ -25,25 +25,23 @@
* ping target should be pinged when the corresponding website is changed. Pinging can be restricted to changes to
* specific categories on the website by instances of the {@link PingCategoryRestrictionData} object. In the absence of
* any category restrictions, the ping target is pinged whenever the corresponding website changes.
- *
+ *
* @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
* @ejb:bean name="AutoPingData"
* @hibernate.class lazy="false" table="autoping"
* @hibernate.cache usage="read-write"
*/
-public class AutoPingData extends PersistentObject implements Serializable
-{
+public class AutoPingData extends PersistentObject implements Serializable {
private String id = null;
private PingTargetData pingTarget = null;
private WebsiteData website = null;
public static final long serialVersionUID = -9105985454111986435L;
-
+
/**
* Default constructor. Leaves all fields null. Required for bean compliance.
*/
- public AutoPingData()
- {
+ public AutoPingData() {
}
/**
@@ -53,8 +51,7 @@
* @param pingtarget ping target that should be pinged
* @param website website to which this configuration applies
*/
- public AutoPingData(String id, PingTargetData pingtarget, WebsiteData website)
- {
+ public AutoPingData(String id, PingTargetData pingtarget, WebsiteData website) {
this.id = id;
this.website = website;
this.pingTarget = pingtarget;
@@ -63,10 +60,9 @@
/**
* Setter needed by RollerImpl.storePersistentObject()
*/
- public void setData(PersistentObject vo)
- {
- AutoPingData other = (AutoPingData)vo;
-
+ public void setData(PersistentObject vo) {
+ AutoPingData other = (AutoPingData) vo;
+
id = other.getId();
website = other.getWebsite();
pingTarget = other.getPingTarget();
@@ -79,8 +75,7 @@
* @ejb:persistent-field
* @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
*/
- public String getId()
- {
+ public String getId() {
return id;
}
@@ -90,8 +85,7 @@
* @param id
* @ejb:persistent-field
*/
- public void setId(String id)
- {
+ public void setId(String id) {
this.id = id;
}
@@ -103,8 +97,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="websiteid" cascade="none" not-null="false"
*/
- public WebsiteData getWebsite()
- {
+ public WebsiteData getWebsite() {
return website;
}
@@ -115,8 +108,7 @@
* @param website the website.
* @ejb:persistent-field
*/
- public void setWebsite(WebsiteData website)
- {
+ public void setWebsite(WebsiteData website) {
this.website = website;
}
@@ -127,8 +119,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="pingtargetid" cascade="none" not-null="false"
*/
- public PingTargetData getPingTarget()
- {
+ public PingTargetData getPingTarget() {
return pingTarget;
}
@@ -138,24 +129,27 @@
* @param pingtarget the target to be pinged.
* @ejb:persistent-field
*/
- public void setPingTarget(PingTargetData pingtarget)
- {
+ public void setPingTarget(PingTargetData pingtarget) {
this.pingTarget = pingtarget;
}
/**
* @see Object#equals(Object)
*/
- public boolean equals(Object o)
- {
+ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AutoPingData)) return false;
- final AutoPingData autoPingData = (AutoPingData)o;
+ final AutoPingData autoPingData = (AutoPingData) o;
if (id != null ? !id.equals(autoPingData.getId()) : autoPingData.getId() != null) return false;
- if (pingTarget != null ? !pingTarget.equals(autoPingData.getPingTarget()) : autoPingData.getPingTarget() != null) return false;
- if (website != null ? !website.equals(autoPingData.getWebsite()) : autoPingData.getWebsite() != null) return false;
+ if (pingTarget != null ? !pingTarget.equals(autoPingData.getPingTarget()) : autoPingData.getPingTarget() != null)
+ {
+ return false;
+ }
+ if (website != null ? !website.equals(autoPingData.getWebsite()) : autoPingData.getWebsite() != null) {
+ return false;
+ }
return true;
}
@@ -163,22 +157,17 @@
/**
* @see Object#hashCode()
*/
- public int hashCode()
- {
+ public int hashCode() {
return (id != null ? id.hashCode() : 0);
}
/**
* Generate a string form of the object appropriate for logging or debugging.
+ *
* @return a string form of the object appropriate for logging or debugging.
- * @see java.lang.Object#toString()
+ * @see Object#toString()
*/
- public String toString()
- {
- return "AutoPingData{" +
- "id='" + id + "'" +
- ", pingTarget=" + pingTarget +
- ", website= " + (website == null ? "null" : "{id='" + website.getId() +"'} ") +
- "}";
+ public String toString() {
+ return "AutoPingData{" + "id='" + id + "'" + ", pingTarget=" + pingTarget + ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") + "}";
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingCategoryRestrictionData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingCategoryRestrictionData.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingCategoryRestrictionData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingCategoryRestrictionData.java Sat Jul 22 11:33:13 2006
@@ -32,8 +32,7 @@
* @hibernate.class lazy="false" table="pingcategory"
* @hibernate.cache usage="read-write"
*/
-public class PingCategoryRestrictionData extends PersistentObject implements Serializable
-{
+public class PingCategoryRestrictionData extends PersistentObject implements Serializable {
private String id;
private AutoPingData autoPing;
private WeblogCategoryData weblogCategory;
@@ -43,8 +42,7 @@
/**
* Default constructor. Leaves all fields null. Required for bean compliance.
*/
- public PingCategoryRestrictionData()
- {
+ public PingCategoryRestrictionData() {
}
/**
@@ -54,8 +52,7 @@
* @param autoPing auto ping configuration being restricted
* @param weblogCategory weblog category to which this auto ping configuration is restricted
*/
- public PingCategoryRestrictionData(String id, AutoPingData autoPing, WeblogCategoryData weblogCategory)
- {
+ public PingCategoryRestrictionData(String id, AutoPingData autoPing, WeblogCategoryData weblogCategory) {
this.id = id;
this.autoPing = autoPing;
this.weblogCategory = weblogCategory;
@@ -64,9 +61,8 @@
/**
* Setter needed by RollerImpl.storePersistentObject()
*/
- public void setData(PersistentObject vo)
- {
- PingCategoryRestrictionData other = (PingCategoryRestrictionData)vo;
+ public void setData(PersistentObject vo) {
+ PingCategoryRestrictionData other = (PingCategoryRestrictionData) vo;
id = other.getId();
autoPing = other.getAutoping();
weblogCategory = other.getWeblogCategory();
@@ -79,8 +75,7 @@
* @ejb:persistent-field
* @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
*/
- public String getId()
- {
+ public String getId() {
return id;
}
@@ -90,8 +85,7 @@
* @param id
* @ejb:persistent-field
*/
- public void setId(String id)
- {
+ public void setId(String id) {
this.id = id;
}
@@ -102,8 +96,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="autopingid" cascade="none" not-null="true"
*/
- public AutoPingData getAutoping()
- {
+ public AutoPingData getAutoping() {
return autoPing;
}
@@ -113,8 +106,7 @@
* @param autoPing the auto ping configuration to which this category restriction applies.
* @ejb:persistent-field
*/
- public void setAutoping(AutoPingData autoPing)
- {
+ public void setAutoping(AutoPingData autoPing) {
this.autoPing = autoPing;
}
@@ -125,8 +117,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="weblogcategoryid" cascade="none" not-null="true"
*/
- public WeblogCategoryData getWeblogCategory()
- {
+ public WeblogCategoryData getWeblogCategory() {
return weblogCategory;
}
@@ -136,24 +127,31 @@
* @param weblogCategory the weblog category to which pings should be restricted.
* @ejb:persistent-field
*/
- public void setWeblogCategory(WeblogCategoryData weblogCategory)
- {
+ public void setWeblogCategory(WeblogCategoryData weblogCategory) {
this.weblogCategory = weblogCategory;
}
/**
* @see Object#equals(Object)
*/
- public boolean equals(Object o)
- {
+ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PingCategoryRestrictionData)) return false;
- final PingCategoryRestrictionData pingCategoryRestrictionData = (PingCategoryRestrictionData)o;
+ final PingCategoryRestrictionData pingCategoryRestrictionData = (PingCategoryRestrictionData) o;
- if (id != null ? !id.equals(pingCategoryRestrictionData.getId()) : pingCategoryRestrictionData.getId() != null) return false;
- if (autoPing != null ? !autoPing.equals(pingCategoryRestrictionData.getAutoping()) : pingCategoryRestrictionData.getAutoping() != null) return false;
- if (weblogCategory != null ? !weblogCategory.equals(pingCategoryRestrictionData.getWeblogCategory()) : pingCategoryRestrictionData.getWeblogCategory() != null) return false;
+ if (id != null ? !id.equals(pingCategoryRestrictionData.getId()) : pingCategoryRestrictionData.getId() != null)
+ {
+ return false;
+ }
+ if (autoPing != null ? !autoPing.equals(pingCategoryRestrictionData.getAutoping()) : pingCategoryRestrictionData.getAutoping() != null)
+ {
+ return false;
+ }
+ if (weblogCategory != null ? !weblogCategory.equals(pingCategoryRestrictionData.getWeblogCategory()) : pingCategoryRestrictionData.getWeblogCategory() != null)
+ {
+ return false;
+ }
return true;
}
@@ -161,8 +159,7 @@
/**
* @see Object#hashCode()
*/
- public int hashCode()
- {
+ public int hashCode() {
return (id != null ? id.hashCode() : 0);
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingQueueEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingQueueEntryData.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingQueueEntryData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingQueueEntryData.java Sat Jul 22 11:33:13 2006
@@ -18,8 +18,8 @@
package org.apache.roller.pojos;
-import java.sql.Timestamp;
import java.io.Serializable;
+import java.sql.Timestamp;
/**
* Ping queue entry. Each instance of this class represents an entry on the ping queue. The entry indicates when it was
@@ -31,8 +31,7 @@
* @hibernate.class lazy="false" table="pingqueueentry"
* @hibernate.cache usage="read-write"
*/
-public class PingQueueEntryData extends PersistentObject implements Serializable
-{
+public class PingQueueEntryData extends PersistentObject implements Serializable {
private String id = null;
private Timestamp entryTime = null;
private PingTargetData pingTarget = null;
@@ -44,8 +43,7 @@
/**
* Default constructor. Leaves all fields at Java-specified default values.
*/
- public PingQueueEntryData()
- {
+ public PingQueueEntryData() {
}
/**
@@ -57,8 +55,7 @@
* @param website website originating the ping
* @param attempts number of prior ping attempts
*/
- public PingQueueEntryData(String id, Timestamp entryTime, PingTargetData pingTarget, WebsiteData website, int attempts)
- {
+ public PingQueueEntryData(String id, Timestamp entryTime, PingTargetData pingTarget, WebsiteData website, int attempts) {
this.id = id;
this.entryTime = entryTime;
this.pingTarget = pingTarget;
@@ -69,10 +66,9 @@
/**
* @see PersistentObject#setData(PersistentObject)
*/
- public void setData(PersistentObject vo)
- {
+ public void setData(PersistentObject vo) {
PingQueueEntryData other = (PingQueueEntryData) vo;
-
+
id = other.getId();
entryTime = other.getEntryTime();
pingTarget = other.getPingTarget();
@@ -87,8 +83,7 @@
* @ejb:persistent-field
* @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
*/
- public String getId()
- {
+ public String getId() {
return id;
}
@@ -98,8 +93,7 @@
* @param id
* @ejb:persistent-field
*/
- public void setId(String id)
- {
+ public void setId(String id) {
this.id = id;
}
@@ -110,8 +104,7 @@
* @ejb:persistent-field
* @hibernate.property column="entrytime" non-null="true"
*/
- public Timestamp getEntryTime()
- {
+ public Timestamp getEntryTime() {
return entryTime;
}
@@ -121,8 +114,7 @@
* @param entryTime the time the entry was first added to the queue.
* @ejb:persistent-field
*/
- public void setEntryTime(Timestamp entryTime)
- {
+ public void setEntryTime(Timestamp entryTime) {
this.entryTime = entryTime;
}
@@ -133,8 +125,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="pingtargetid" cascade="none" not-null="true"
*/
- public PingTargetData getPingTarget()
- {
+ public PingTargetData getPingTarget() {
return pingTarget;
}
@@ -144,8 +135,7 @@
* @param pingTarget target to ping.
* @ejb:persistent-field
*/
- public void setPingTarget(PingTargetData pingTarget)
- {
+ public void setPingTarget(PingTargetData pingTarget) {
this.pingTarget = pingTarget;
}
@@ -156,8 +146,7 @@
* @ejb:persistent-field
* @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
*/
- public WebsiteData getWebsite()
- {
+ public WebsiteData getWebsite() {
return website;
}
@@ -167,8 +156,7 @@
* @param website the website originating the ping.
* @ejb:persistent-field
*/
- public void setWebsite(WebsiteData website)
- {
+ public void setWebsite(WebsiteData website) {
this.website = website;
}
@@ -179,8 +167,7 @@
* @ejb:persistent-field
* @hibernate.property column="attempts" non-null="true"
*/
- public int getAttempts()
- {
+ public int getAttempts() {
return attempts;
}
@@ -190,8 +177,7 @@
* @param attempts
* @ejb:persistent-field
*/
- public void setAttempts(int attempts)
- {
+ public void setAttempts(int attempts) {
this.attempts = attempts;
}
@@ -200,26 +186,33 @@
*
* @return the new value.
*/
- public int incrementAttempts()
- {
+ public int incrementAttempts() {
return ++attempts;
}
/**
* @see Object#equals(Object o)
*/
- public boolean equals(Object o)
- {
+ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PingQueueEntryData)) return false;
final PingQueueEntryData pingQueueEntryData = (PingQueueEntryData) o;
if (attempts != pingQueueEntryData.getAttempts()) return false;
- if (entryTime != null ? !entryTime.equals(pingQueueEntryData.getEntryTime()) : pingQueueEntryData.getEntryTime() != null) return false;
+ if (entryTime != null ? !entryTime.equals(pingQueueEntryData.getEntryTime()) : pingQueueEntryData.getEntryTime() != null)
+ {
+ return false;
+ }
if (id != null ? !id.equals(pingQueueEntryData.getId()) : pingQueueEntryData.getId() != null) return false;
- if (pingTarget != null ? !pingTarget.equals(pingQueueEntryData.getPingTarget()) : pingQueueEntryData.getPingTarget() != null) return false;
- if (website != null ? !website.equals(pingQueueEntryData.getWebsite()) : pingQueueEntryData.getWebsite() != null) return false;
+ if (pingTarget != null ? !pingTarget.equals(pingQueueEntryData.getPingTarget()) : pingQueueEntryData.getPingTarget() != null)
+ {
+ return false;
+ }
+ if (website != null ? !website.equals(pingQueueEntryData.getWebsite()) : pingQueueEntryData.getWebsite() != null)
+ {
+ return false;
+ }
return true;
}
@@ -227,24 +220,17 @@
/**
* @see Object#hashCode()
*/
- public int hashCode()
- {
+ public int hashCode() {
return (id != null ? id.hashCode() : 0);
}
/**
* Generate a string form of the object appropriate for logging or debugging.
+ *
* @return a string form of the object appropriate for logging or debugging.
- * @see java.lang.Object#toString()
+ * @see Object#toString()
*/
- public String toString()
- {
- return "PingQueueEntryData{" +
- "id='" + id + "'" +
- ", entryTime=" + entryTime +
- ", pingTarget=" + pingTarget +
- ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") +
- ", attempts=" + attempts +
- "}";
+ public String toString() {
+ return "PingQueueEntryData{" + "id='" + id + "'" + ", entryTime=" + entryTime + ", pingTarget=" + pingTarget + ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") + ", attempts=" + attempts + "}";
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingTargetData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingTargetData.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingTargetData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PingTargetData.java Sat Jul 22 11:33:13 2006
@@ -34,13 +34,13 @@
* @hibernate.cache usage="read-write"
*/
public class PingTargetData extends PersistentObject implements Serializable {
-
+
public static final long serialVersionUID = -6354583200913127874L;
-
+
public static final int CONDITION_OK = 0; // last use (after possible retrials) was successful
public static final int CONDITION_FAILING = 1; // last use failed after retrials
public static final int CONDITION_DISABLED = 2; // disabled by failure policy after failures - editing resets
-
+
private String id = null;
private String name = null;
private String pingUrl = null;
@@ -48,15 +48,15 @@
private int conditionCode = -1;
private Timestamp lastSuccess = null;
private boolean autoEnabled = false;
-
-
+
+
/**
* Default empty constructor.
*/
public PingTargetData() {
}
-
-
+
+
/**
* Constructor.
*
@@ -74,14 +74,14 @@
this.lastSuccess = null;
this.autoEnabled = autoEnable;
}
-
-
+
+
/**
* Setter needed by RollerImpl.storePersistentObject()
*/
public void setData(PersistentObject vo) {
PingTargetData other = (PingTargetData) vo;
-
+
id = other.getId();
name = other.getName();
pingUrl = other.getPingUrl();
@@ -90,8 +90,8 @@
lastSuccess = other.getLastSuccess();
autoEnabled = other.isAutoEnabled();
}
-
-
+
+
/**
* Get the unique id of this ping target.
*
@@ -103,8 +103,8 @@
public java.lang.String getId() {
return this.id;
}
-
-
+
+
/**
* Set the unique id of this ping target
*
@@ -114,8 +114,8 @@
public void setId(java.lang.String id) {
this.id = id;
}
-
-
+
+
/**
* get the name of this ping target. This is a name assigned by the administrator or a user (for custom) targets.
* It is deescriptive and is not necessarily unique.
@@ -127,8 +127,8 @@
public java.lang.String getName() {
return this.name;
}
-
-
+
+
/**
* Set the name of this ping target.
*
@@ -138,8 +138,8 @@
public void setName(java.lang.String name) {
this.name = name;
}
-
-
+
+
/**
* Get the URL to ping.
*
@@ -150,8 +150,8 @@
public String getPingUrl() {
return pingUrl;
}
-
-
+
+
/**
* Set the URL to ping.
*
@@ -161,8 +161,8 @@
public void setPingUrl(String pingUrl) {
this.pingUrl = pingUrl;
}
-
-
+
+
/**
* Get the website (on this server) for which this ping target is a custom target. This may be null, indicating
* that it is a common ping target, not a custom one.
@@ -175,8 +175,8 @@
public WebsiteData getWebsite() {
return website;
}
-
-
+
+
/**
* Set the website (on this server) for which this ping target is a custom target.
*
@@ -187,8 +187,8 @@
public void setWebsite(WebsiteData website) {
this.website = website;
}
-
-
+
+
/**
* Get the condition code value. This code, in combination with the last success timestamp, provides a status
* indicator on the ping target based on its usage by the ping queue processor. It can be used to implement a
@@ -202,8 +202,8 @@
public int getConditionCode() {
return conditionCode;
}
-
-
+
+
/**
* Set the condition code value.
*
@@ -213,8 +213,8 @@
public void setConditionCode(int conditionCode) {
this.conditionCode = conditionCode;
}
-
-
+
+
/**
* Get the timestamp of the last successful ping (UTC/GMT).
*
@@ -225,8 +225,8 @@
public Timestamp getLastSuccess() {
return lastSuccess;
}
-
-
+
+
/**
* Set the timestamp of the last successful ping.
*
@@ -236,8 +236,8 @@
public void setLastSuccess(Timestamp lastSuccess) {
this.lastSuccess = lastSuccess;
}
-
-
+
+
/**
* Is this ping target enabled by default for new weblogs?
*
@@ -249,7 +249,7 @@
return autoEnabled;
}
-
+
/**
* Set the auto enabled status for this ping target. This field only
* applies for common ping targets.
@@ -260,36 +260,43 @@
public void setAutoEnabled(boolean autoEnabled) {
this.autoEnabled = autoEnabled;
}
-
-
+
+
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return id.hashCode();
}
-
-
+
+
/**
* @see java.lang.Object#equals(Object o)
*/
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PingTargetData)) return false;
-
+
final PingTargetData pingTargetData = (PingTargetData) o;
-
+
if (conditionCode != pingTargetData.getConditionCode()) return false;
if (id != null ? !id.equals(pingTargetData.getId()) : pingTargetData.getId() != null) return false;
- if (lastSuccess != null ? !lastSuccess.equals(pingTargetData.getLastSuccess()) : pingTargetData.getLastSuccess() != null) return false;
+ if (lastSuccess != null ? !lastSuccess.equals(pingTargetData.getLastSuccess()) : pingTargetData.getLastSuccess() != null)
+ {
+ return false;
+ }
if (name != null ? !name.equals(pingTargetData.getName()) : pingTargetData.getName() != null) return false;
- if (pingUrl != null ? !pingUrl.equals(pingTargetData.getPingUrl()) : pingTargetData.getPingUrl() != null) return false;
- if (website != null ? !website.equals(pingTargetData.getWebsite()) : pingTargetData.getWebsite() != null) return false;
-
+ if (pingUrl != null ? !pingUrl.equals(pingTargetData.getPingUrl()) : pingTargetData.getPingUrl() != null) {
+ return false;
+ }
+ if (website != null ? !website.equals(pingTargetData.getWebsite()) : pingTargetData.getWebsite() != null) {
+ return false;
+ }
+
return true;
}
-
-
+
+
/**
* Generate a string form of the object appropriate for logging or debugging.
*
@@ -297,14 +304,7 @@
* @see java.lang.Object#toString()
*/
public String toString() {
- return "PingTargetData{" +
- "id='" + id + "'" +
- ", name='" + name + "'" +
- ", pingUrl='" + pingUrl + "'" +
- ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") +
- ", conditionCode=" + conditionCode +
- ", lastSuccess=" + lastSuccess +
- "}";
+ return "PingTargetData{" + "id='" + id + "'" + ", name='" + name + "'" + ", pingUrl='" + pingUrl + "'" + ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") + ", conditionCode=" + conditionCode + ", lastSuccess=" + lastSuccess + "}";
}
-
+
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/CommonPingTargetsAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/CommonPingTargetsAction.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/CommonPingTargetsAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/CommonPingTargetsAction.java Sat Jul 22 11:33:13 2006
@@ -18,11 +18,6 @@
package org.apache.roller.ui.admin.struts.actions;
-import java.util.List;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.RollerException;
@@ -30,14 +25,19 @@
import org.apache.roller.model.RollerFactory;
import org.apache.roller.pojos.PingTargetData;
import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.ui.authoring.struts.actions.BasePingTargetsAction;
+import org.apache.roller.ui.authoring.struts.forms.PingTargetForm;
import org.apache.roller.ui.core.RollerRequest;
import org.apache.roller.ui.core.RollerSession;
-import org.apache.roller.ui.authoring.struts.forms.PingTargetForm;
-import org.apache.roller.ui.authoring.struts.actions.BasePingTargetsAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
/**
* Administer common ping targets.
*
@@ -47,50 +47,40 @@
* @struts.action-forward name="pingTargetEdit.page" path=".CommonPingTargetEdit"
* @struts.action-forward name="pingTargetDeleteOK.page" path=".CommonPingTargetDeleteOK"
*/
-public class CommonPingTargetsAction extends BasePingTargetsAction
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(CommonPingTargetsAction.class);
+public class CommonPingTargetsAction extends BasePingTargetsAction {
+ private static Log mLogger = LogFactory.getFactory().getInstance(CommonPingTargetsAction.class);
protected Log getLogger() {
return mLogger;
}
- public String getPingTargetsTitle()
- {
- return "commonPingTargets.commonPingTargets";
- }
- public String getPingTargetEditTitle()
- {
- return "pingTarget.pingTarget";
- }
- public String getPingTargetDeleteOKTitle()
- {
- return "pingTarget.confirmRemoveTitle";
+ public String getPingTargetsTitle() {
+ return "commonPingTargets.commonPingTargets";
+ }
+
+ public String getPingTargetEditTitle() {
+ return "pingTarget.pingTarget";
}
-
+
+ public String getPingTargetDeleteOKTitle() {
+ return "pingTarget.confirmRemoveTitle";
+ }
+
/*
- * Set a ping target auto enabled to true.
- */
- public ActionForward enableSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ * Set a ping target auto enabled to true.
+ */
+ public ActionForward enableSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
PingTargetData pingTarget = select(rreq);
- try
- {
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward("access-denied");
}
pingTarget.setAutoEnabled(true);
RollerFactory.getRoller().flush();
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR in action", e);
throw new ServletException(e);
}
@@ -99,36 +89,28 @@
/*
* Set a pint target auto enabled to false.
*/
- public ActionForward disableSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward disableSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
PingTargetData pingTarget = select(rreq);
- try
- {
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward("access-denied");
}
pingTarget.setAutoEnabled(false);
RollerFactory.getRoller().flush();
-
+
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR in action", e);
throw new ServletException(e);
}
}
-
+
/*
- * Get the ping targets for the view. Here we return the common ping targets for the
- * entire site.
- */
- protected List getPingTargets(RollerRequest rreq) throws RollerException
- {
+ * Get the ping targets for the view. Here we return the common ping targets for the
+ * entire site.
+ */
+ protected List getPingTargets(RollerRequest rreq) throws RollerException {
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
return pingTargetMgr.getCommonPingTargets();
}
@@ -136,22 +118,16 @@
/*
* Create a new ping target (blank). Here we create a common ping target.
*/
- protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm)
- throws RollerException
- {
- return new PingTargetData(null, pingTargetForm.getName(),
- pingTargetForm.getPingUrl(), null, pingTargetForm.isAutoEnabled());
+ protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm) throws RollerException {
+ return new PingTargetData(null, pingTargetForm.getName(), pingTargetForm.getPingUrl(), null, pingTargetForm.isAutoEnabled());
}
/*
* Check if request carries admin rights.
*/
- protected boolean hasRequiredRights(
- RollerRequest rreq, WebsiteData website) throws RollerException
- {
- RollerSession rollerSession =
- RollerSession.getRollerSession(rreq.getRequest());
+ protected boolean hasRequiredRights(RollerRequest rreq, WebsiteData website) throws RollerException {
+ RollerSession rollerSession = RollerSession.getRollerSession(rreq.getRequest());
return rollerSession.isGlobalAdminUser();
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/BasePingTargetsAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/BasePingTargetsAction.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/BasePingTargetsAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/BasePingTargetsAction.java Sat Jul 22 11:33:13 2006
@@ -16,47 +16,43 @@
package org.apache.roller.ui.authoring.struts.actions;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.logging.Log;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.action.ActionMessages;
-import org.apache.struts.actions.DispatchAction;
import org.apache.roller.RollerException;
import org.apache.roller.model.PingTargetManager;
import org.apache.roller.model.RollerFactory;
-import org.apache.roller.pojos.WebsiteData;
import org.apache.roller.pojos.PingTargetData;
-import org.apache.roller.ui.core.BasePageModel;
+import org.apache.roller.pojos.WebsiteData;
import org.apache.roller.ui.authoring.struts.forms.PingTargetForm;
+import org.apache.roller.ui.core.BasePageModel;
import org.apache.roller.ui.core.RequestConstants;
import org.apache.roller.ui.core.RollerRequest;
+import org.apache.struts.action.*;
+import org.apache.struts.actions.DispatchAction;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
/**
- * Base class for both common and custom ping target operations. The methods
- * here apply to creating, editing and removing ping targets. Operations for
- * maintaining automatic ping configurations are handled by
+ * Base class for both common and custom ping target operations. The methods
+ * here apply to creating, editing and removing ping targets. Operations for
+ * maintaining automatic ping configurations are handled by
* {@link PingSetupAction}.
*/
-public abstract class BasePingTargetsAction extends DispatchAction
-{
+public abstract class BasePingTargetsAction extends DispatchAction {
// These are expected to be defined forwards by the concrete subclass actions.
protected static final String VIEW_PAGE = "pingTargets.page";
protected static final String PING_TARGET_EDIT_PAGE = "pingTargetEdit.page";
protected static final String PING_TARGET_DELETE_PAGE = "pingTargetDeleteOK.page";
protected static final String ACCESS_DENIED_PAGE = "access-denied";
-
+
public abstract String getPingTargetsTitle();
+
public abstract String getPingTargetEditTitle();
- public abstract String getPingTargetDeleteOKTitle();
+
+ public abstract String getPingTargetDeleteOKTitle();
public BasePingTargetsAction() {
@@ -64,6 +60,7 @@
/**
* Implements the default action (view) if the method is not specified.
+ *
* @param mapping
* @param actionForm
* @param request
@@ -72,12 +69,7 @@
* @throws Exception
* @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
- {
+ protected ActionForward unspecified(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
return view(mapping, actionForm, request, response);
}
@@ -91,28 +83,20 @@
* @return forward to the ping targets page
* @throws Exception
*/
- public ActionForward view(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ActionForward forward = mapping.findForward(VIEW_PAGE);
RollerRequest rreq = RollerRequest.getRollerRequest(req);
- try
- {
- BasePageModel pageModel =
- new BasePageModel(getPingTargetsTitle(), req, res, mapping);
- req.setAttribute("model",pageModel);
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ BasePageModel pageModel = new BasePageModel(getPingTargetsTitle(), req, res, mapping);
+ req.setAttribute("model", pageModel);
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward(ACCESS_DENIED_PAGE);
}
List pingTargets = getPingTargets(rreq);
req.setAttribute("pingTargets", pingTargets);
return forward;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
getLogger().error("ERROR in action", e);
throw new ServletException(e);
}
@@ -128,37 +112,24 @@
* @return the result of <code>view()</code> after the target is saved.
* @throws Exception
*/
- public ActionForward save(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
- PingTargetManager pingTargetMgr =
- RollerFactory.getRoller().getPingTargetManager();
+ PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
PingTargetForm pingTargetForm = (PingTargetForm) form;
- try
- {
- BasePageModel pageModel =
- new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
- req.setAttribute("model",pageModel);
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ BasePageModel pageModel = new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
+ req.setAttribute("model", pageModel);
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward(ACCESS_DENIED_PAGE);
}
PingTargetData pingTarget = null;
String pingTargetId = pingTargetForm.getId();
- if (pingTargetId != null && pingTargetId.length() > 0)
- {
- pingTarget = pingTargetMgr.getPingTarget(
- pingTargetForm.getId());
- if (pingTarget == null)
- throw new RollerException(
- "No such ping target id: " + pingTargetId);
+ if (pingTargetId != null && pingTargetId.length() > 0) {
+ pingTarget = pingTargetMgr.getPingTarget(pingTargetForm.getId());
+ if (pingTarget == null) throw new RollerException("No such ping target id: " + pingTargetId);
pingTargetForm.copyTo(pingTarget, req.getLocale());
- }
- else
- {
+ } else {
pingTarget = createPingTarget(rreq, pingTargetForm);
}
@@ -174,16 +145,13 @@
// Save it, commit and return refreshed view of target list.
pingTargetMgr.savePingTarget(pingTarget);
RollerFactory.getRoller().flush();
-
+
ActionMessages msgs = new ActionMessages();
- msgs.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("pingTarget.saved"));
- saveMessages(req, msgs);
-
+ msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("pingTarget.saved"));
+ saveMessages(req, msgs);
+
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
getLogger().error("ERROR in action", e);
throw new ServletException(e);
}
@@ -199,13 +167,9 @@
* @return the edit page (blank)
* @throws Exception
*/
- public ActionForward addNew(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
- BasePageModel pageModel =
- new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
- req.setAttribute("model",pageModel);
+ public ActionForward addNew(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
+ BasePageModel pageModel = new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
+ req.setAttribute("model", pageModel);
return mapping.findForward(PING_TARGET_EDIT_PAGE);
}
@@ -219,27 +183,19 @@
* @return the edit view with the form populated with the ping target specified by the id in the request.
* @throws Exception
*/
- public ActionForward editSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward editSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ActionForward forward = mapping.findForward(PING_TARGET_EDIT_PAGE);
RollerRequest rreq = RollerRequest.getRollerRequest(req);
- try
- {
- BasePageModel pageModel =
- new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
- req.setAttribute("model",pageModel);
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ BasePageModel pageModel = new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
+ req.setAttribute("model", pageModel);
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward(ACCESS_DENIED_PAGE);
}
PingTargetData pingTarget = select(rreq);
((PingTargetForm) form).copyFrom(pingTarget, req.getLocale());
return forward;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
getLogger().error("ERROR in action", e);
throw new ServletException(e);
}
@@ -255,27 +211,19 @@
* @return the delete confirmation view with the form populated with the ping target specified by the id in the request.
* @throws Exception
*/
- public ActionForward deleteSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward deleteSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ActionForward forward = mapping.findForward(PING_TARGET_DELETE_PAGE);
RollerRequest rreq = RollerRequest.getRollerRequest(req);
- try
- {
- BasePageModel pageModel = new BasePageModel(
- getPingTargetDeleteOKTitle(), req, res, mapping);
- req.setAttribute("model",pageModel);
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ BasePageModel pageModel = new BasePageModel(getPingTargetDeleteOKTitle(), req, res, mapping);
+ req.setAttribute("model", pageModel);
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward(ACCESS_DENIED_PAGE);
}
PingTargetData pingTarget = select(rreq);
((PingTargetForm) form).copyFrom(pingTarget, req.getLocale());
return forward;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
getLogger().error("ERROR in action", e);
throw new ServletException(e);
}
@@ -291,55 +239,46 @@
* @return the result of <code>view()</code> after the deletion
* @throws Exception
*/
- public ActionForward deleteConfirmed(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward deleteConfirmed(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
PingTargetForm pingTargetForm = (PingTargetForm) form;
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
- try
- {
- if (!hasRequiredRights(rreq, rreq.getWebsite()))
- {
+ try {
+ if (!hasRequiredRights(rreq, rreq.getWebsite())) {
return mapping.findForward(ACCESS_DENIED_PAGE);
}
String pingTargetId = pingTargetForm.getId();
- if (pingTargetId == null || pingTargetId.length() == 0)
- {
+ if (pingTargetId == null || pingTargetId.length() == 0) {
throw new RollerException("Missing ping target id.");
}
PingTargetData ping = pingTargetMgr.getPingTarget(pingTargetId);
pingTargetMgr.removePingTarget(ping);
RollerFactory.getRoller().flush();
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
getLogger().error("ERROR in action", e);
throw new ServletException(e);
}
}
// TODO: Consider unifying with other RollerRequest methods
+
/**
* Helper to select the ping target specified by the id in the request.
+ *
* @param rreq
* @return the ping target specified by the id in the request
* @throws RollerException
*/
- protected PingTargetData select(RollerRequest rreq) throws RollerException
- {
+ protected PingTargetData select(RollerRequest rreq) throws RollerException {
String pingTargetId = rreq.getRequest().getParameter(RequestConstants.PINGTARGET_ID);
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
- if (pingTargetId == null || pingTargetId.length() == 0)
- {
+ if (pingTargetId == null || pingTargetId.length() == 0) {
throw new RollerException("Missing ping target id: " + pingTargetId);
}
PingTargetData pingTarget = pingTargetMgr.getPingTarget(pingTargetId);
- if (pingTarget == null)
- {
+ if (pingTarget == null) {
throw new RollerException("No such ping target id: " + pingTargetId);
}
return pingTarget;
@@ -347,46 +286,37 @@
/**
* Private helper to validate a ping target.
- * @param rreq the request
+ *
+ * @param rreq the request
* @param pingTarget the ping target to validate
- * @return an <code>ActionMessages</code> object with
- * <code>ActionMessage</code> for each error encountered,
+ * @return an <code>ActionMessages</code> object with
+ * <code>ActionMessage</code> for each error encountered,
* empty if no errors were encountered.
* @throws RollerException
*/
- private ActionMessages validate(
- RollerRequest rreq, PingTargetData pingTarget) throws RollerException
- {
+ private ActionMessages validate(RollerRequest rreq, PingTargetData pingTarget) throws RollerException {
ActionMessages errors = new ActionMessages();
- PingTargetManager pingTargetMgr =
- RollerFactory.getRoller().getPingTargetManager();
- if (!pingTargetMgr.isNameUnique(pingTarget))
- {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("pingTarget.nameNotUnique"));
+ PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
+ if (!pingTargetMgr.isNameUnique(pingTarget)) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("pingTarget.nameNotUnique"));
}
- if (!pingTargetMgr.isUrlWellFormed(pingTarget))
- {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("pingTarget.malformedUrl"));
- } else if (!pingTargetMgr.isHostnameKnown(pingTarget))
- {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("pingTarget.unknownHost"));
+ if (!pingTargetMgr.isUrlWellFormed(pingTarget)) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("pingTarget.malformedUrl"));
+ } else if (!pingTargetMgr.isHostnameKnown(pingTarget)) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("pingTarget.unknownHost"));
}
return errors;
}
/**
- * Helper defined by the subclass to determine if user has adequate
- * rights for the action. This and the
- * {@link org.apache.roller.pojos.PingTargetData#canSave()} method determine the
+ * Helper defined by the subclass to determine if user has adequate
+ * rights for the action. This and the
+ * {@link org.apache.roller.pojos.PingTargetData#canSave()} method determine the
* access control for the action.
*/
- protected abstract boolean hasRequiredRights(
- RollerRequest rreq, WebsiteData website) throws RollerException;
+ protected abstract boolean hasRequiredRights(RollerRequest rreq, WebsiteData website) throws RollerException;
/**
* Get the logger from the concrete subclass
@@ -394,18 +324,15 @@
protected abstract Log getLogger();
/**
- * Get the ping targets for the view. This is implemented differently in
+ * Get the ping targets for the view. This is implemented differently in
* the concrete subclasses.
*/
- protected abstract List getPingTargets(RollerRequest rreq)
- throws RollerException;
+ protected abstract List getPingTargets(RollerRequest rreq) throws RollerException;
/**
- * Create a new ping target (blank). This is implemented differently in
+ * Create a new ping target (blank). This is implemented differently in
* the concrete subclasses.
*/
- protected abstract PingTargetData createPingTarget(
- RollerRequest rreq, PingTargetForm pingTargetForm)
- throws RollerException;
+ protected abstract PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm) throws RollerException;
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CustomPingTargetsAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CustomPingTargetsAction.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CustomPingTargetsAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/CustomPingTargetsAction.java Sat Jul 22 11:33:13 2006
@@ -18,17 +18,8 @@
package org.apache.roller.ui.authoring.struts.actions;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
import org.apache.roller.RollerException;
import org.apache.roller.config.PingConfig;
import org.apache.roller.model.PingTargetManager;
@@ -38,6 +29,14 @@
import org.apache.roller.ui.authoring.struts.forms.PingTargetForm;
import org.apache.roller.ui.core.RollerRequest;
import org.apache.roller.ui.core.RollerSession;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Collections;
+import java.util.List;
/**
@@ -49,25 +48,21 @@
* @struts.action-forward name="pingTargetEdit.page" path=".CustomPingTargetEdit"
* @struts.action-forward name="pingTargetDeleteOK.page" path=".CustomPingTargetDeleteOK"
*/
-public class CustomPingTargetsAction
- extends BasePingTargetsAction
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(CustomPingTargetsAction.class);
-
- public String getPingTargetsTitle()
- {
- return "customPingTargets.customPingTargets";
- }
- public String getPingTargetEditTitle()
- {
- return "pingTarget.pingTarget";
- }
- public String getPingTargetDeleteOKTitle()
- {
- return "pingTarget.confirmRemoveTitle";
+public class CustomPingTargetsAction extends BasePingTargetsAction {
+ private static Log mLogger = LogFactory.getFactory().getInstance(CustomPingTargetsAction.class);
+
+ public String getPingTargetsTitle() {
+ return "customPingTargets.customPingTargets";
}
-
+
+ public String getPingTargetEditTitle() {
+ return "pingTarget.pingTarget";
+ }
+
+ public String getPingTargetDeleteOKTitle() {
+ return "pingTarget.confirmRemoveTitle";
+ }
+
public CustomPingTargetsAction() {
super();
}
@@ -81,16 +76,14 @@
* 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
- {
+ protected List getPingTargets(RollerRequest rreq) throws RollerException {
HttpServletRequest req = rreq.getRequest();
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
Boolean allowCustomTargets = new Boolean(!PingConfig.getDisallowCustomTargets());
req.setAttribute("allowCustomTargets", allowCustomTargets);
- List customPingTargets = allowCustomTargets.booleanValue() ?
- pingTargetMgr.getCustomPingTargets(rreq.getWebsite()) : Collections.EMPTY_LIST;
+ List customPingTargets = allowCustomTargets.booleanValue() ? pingTargetMgr.getCustomPingTargets(rreq.getWebsite()) : Collections.EMPTY_LIST;
return customPingTargets;
}
@@ -98,32 +91,20 @@
/*
* 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
- {
- return new PingTargetData(null, pingTargetForm.getName(),
- pingTargetForm.getPingUrl(), rreq.getWebsite(), false);
+ protected PingTargetData createPingTarget(RollerRequest rreq, PingTargetForm pingTargetForm) throws RollerException {
+ return new PingTargetData(null, pingTargetForm.getName(), pingTargetForm.getPingUrl(), rreq.getWebsite(), false);
}
/*
* Check if the user has editing rights.
*/
- protected boolean hasRequiredRights(RollerRequest rreq, WebsiteData website)
- throws RollerException
- {
+ protected boolean hasRequiredRights(RollerRequest rreq, WebsiteData website) throws RollerException {
RollerSession rses = RollerSession.getRollerSession(rreq.getRequest());
- return (rses.isUserAuthorizedToAdmin(website)
- && !PingConfig.getDisallowCustomTargets());
+ return (rses.isUserAuthorizedToAdmin(website) && !PingConfig.getDisallowCustomTargets());
}
- public ActionForward cancel(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception
- {
+ public ActionForward cancel(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
return view(mapping, actionForm, request, response);
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/PingSetupAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/PingSetupAction.java?rev=424615&r1=424614&r2=424615&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/PingSetupAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/PingSetupAction.java Sat Jul 22 11:33:13 2006
@@ -18,28 +18,8 @@
package org.apache.roller.ui.authoring.struts.actions;
-import java.io.IOException;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.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.xmlrpc.XmlRpcException;
import org.apache.roller.RollerException;
import org.apache.roller.config.PingConfig;
import org.apache.roller.config.RollerRuntimeConfig;
@@ -54,6 +34,17 @@
import org.apache.roller.ui.core.RollerRequest;
import org.apache.roller.ui.core.RollerSession;
import org.apache.roller.ui.core.pings.WeblogUpdatePinger;
+import org.apache.struts.action.*;
+import org.apache.struts.actions.DispatchAction;
+import org.apache.xmlrpc.XmlRpcException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.*;
/**
@@ -64,13 +55,11 @@
* @struts.action-forward name="pingSetup.page" path=".Pings"
* @struts.action-forward name="pingResult.page" path=".PingResult"
*/
-public class PingSetupAction extends DispatchAction
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(PingSetupAction.class);
+public class PingSetupAction extends DispatchAction {
+ private static Log mLogger = LogFactory.getFactory().getInstance(PingSetupAction.class);
private static final String PING_SETUP_PAGE = "pingSetup.page";
-
+
// Changing this to take your back to the pings setup page instead of
// ping result page, no need for extra page.
private static final String PING_RESULT_PAGE = "pingSetup.page"; // "pingResult.page";
@@ -82,45 +71,33 @@
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
- protected ActionForward unspecified(ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception
- {
+ 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
- {
+ 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 = RollerFactory.getRoller().getPingTargetManager();
WebsiteData website = rreq.getWebsite();
- try
- {
- if (!isAuthorized(rreq, website))
- {
+ try {
+ if (!isAuthorized(rreq, website)) {
return mapping.findForward("access-denied");
}
- BasePageModel pageModel =
- new BasePageModel("pings.title", req, res, mapping);
- req.setAttribute("model",pageModel);
-
+ BasePageModel pageModel = new BasePageModel("pings.title", req, res, mapping);
+ req.setAttribute("model", pageModel);
+
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;
+ 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)
@@ -128,9 +105,7 @@
req.setAttribute("isEnabled", isEnabled);
return forward;
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR in action", e);
throw new ServletException(e);
}
@@ -140,9 +115,7 @@
* 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
- {
+ private Map buildIsEnabledMap(RollerRequest rreq, List commonPingTargets, List customPingTargets) throws RollerException {
AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
WebsiteData website = rreq.getWebsite();
@@ -150,27 +123,22 @@
Map isEnabled = new HashMap();
List autopings = autoPingMgr.getAutoPingsByWebsite(website);
// Add the enabled auto ping configs with TRUE
- for (Iterator i = autopings.iterator(); i.hasNext();)
- {
+ 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();)
- {
+ for (Iterator i = commonPingTargets.iterator(); i.hasNext();) {
PingTargetData pingTarget = (PingTargetData) i.next();
- if (isEnabled.get(pingTarget.getId()) == null)
- {
+ 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();)
- {
+ for (Iterator i = customPingTargets.iterator(); i.hasNext();) {
PingTargetData pingTarget = (PingTargetData) i.next();
- if (isEnabled.get(pingTarget.getId()) == null)
- {
+ if (isEnabled.get(pingTarget.getId()) == null) {
isEnabled.put(pingTarget.getId(), Boolean.FALSE);
}
}
@@ -180,17 +148,12 @@
/*
* Enable a ping target.
*/
- public ActionForward enableSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward enableSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
PingTargetData pingTarget = select(rreq);
- try
- {
- if (!isAuthorized(rreq, rreq.getWebsite()))
- {
+ try {
+ if (!isAuthorized(rreq, rreq.getWebsite())) {
return mapping.findForward("access-denied");
}
AutoPingData autoPing = new AutoPingData(null, pingTarget, rreq.getWebsite());
@@ -198,9 +161,7 @@
RollerFactory.getRoller().flush();
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR in action", e);
throw new ServletException(e);
}
@@ -209,26 +170,19 @@
/*
* Load delete confirmation view.
*/
- public ActionForward disableSelected(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
+ public ActionForward disableSelected(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
PingTargetData pingTarget = select(rreq);
- try
- {
- if (!isAuthorized(rreq, rreq.getWebsite()))
- {
+ try {
+ if (!isAuthorized(rreq, rreq.getWebsite())) {
return mapping.findForward("access-denied");
}
autoPingMgr.removeAutoPing(pingTarget, rreq.getWebsite());
RollerFactory.getRoller().flush();
-
+
return view(mapping, form, req, res);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR in action", e);
throw new ServletException(e);
}
@@ -237,79 +191,54 @@
/*
* Ping the selected target now.
*/
- public ActionForward pingSelectedNow(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
- try
- {
+ public ActionForward pingSelectedNow(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
+ try {
RollerRequest rreq = RollerRequest.getRollerRequest(req);
String absoluteUrl = RollerRuntimeConfig.getAbsoluteContextURL();
PingTargetData pingTarget = select(rreq);
WebsiteData website = rreq.getWebsite();
- try
- {
- if (!isAuthorized(rreq, website))
- {
+ try {
+ if (!isAuthorized(rreq, website)) {
return mapping.findForward("access-denied");
}
- if (PingConfig.getSuspendPingProcessing())
- {
+ 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())
- {
+ } else {
+ WeblogUpdatePinger.PingResult pingResult = WeblogUpdatePinger.sendPing(absoluteUrl, pingTarget, website);
+ if (pingResult.isError()) {
if (mLogger.isDebugEnabled()) mLogger.debug("Ping Result: " + pingResult);
ActionMessages errors = new ActionMessages();
- if (pingResult.getMessage() != null && pingResult.getMessage().trim().length() > 0)
- {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("ping.transmittedButError"));
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage(pingResult.getMessage()));
- }
- else
- {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("ping.transmissionFailed"));
+ if (pingResult.getMessage() != null && pingResult.getMessage().trim().length() > 0) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.transmittedButError"));
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(pingResult.getMessage()));
+ } else {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.transmissionFailed"));
}
saveErrors(req, errors);
- }
- else
- {
+ } else {
ActionMessages messages = new ActionMessages();
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.successful"));
saveMessages(req, messages);
}
}
- }
- catch (IOException ex)
- {
+ } 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)
- {
+ } 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 view(mapping, form , req, res);
- }
- catch (Exception ex)
- {
+ return view(mapping, form, req, res);
+ } catch (Exception ex) {
mLogger.error("ERROR in action", ex);
throw new ServletException(ex);
}
@@ -317,40 +246,30 @@
// TODO: Consider unifying with other RollerRequest methods
// Private helper to get ping target specified by request
- private PingTargetData select(RollerRequest rreq) throws RollerException
- {
+ private PingTargetData select(RollerRequest rreq) throws RollerException {
String pingTargetId = rreq.getRequest().getParameter(RequestConstants.PINGTARGET_ID);
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
- if (pingTargetId == null || pingTargetId.length() == 0)
- {
+ if (pingTargetId == null || pingTargetId.length() == 0) {
throw new RollerException("Missing ping target id: " + pingTargetId);
}
PingTargetData pingTarget = pingTargetMgr.getPingTarget(pingTargetId);
- if (pingTarget == null)
- {
+ 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)
- {
+ 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)
- {
+ } else if (ex instanceof SocketException) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("ping.networkConnectionFailed"));
}
}
- private boolean isAuthorized(RollerRequest rreq, WebsiteData website)
- throws RollerException
- {
+ private boolean isAuthorized(RollerRequest rreq, WebsiteData website) throws RollerException {
RollerSession rses = RollerSession.getRollerSession(rreq.getRequest());
- return rses.isUserAuthorizedToAdmin(website)
- && !PingConfig.getDisablePingUsage();
+ return rses.isUserAuthorizedToAdmin(website) && !PingConfig.getDisablePingUsage();
}
}