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 2006/05/15 20:56:35 UTC
svn commit: r406715 - in /incubator/roller/trunk: metadata/database/
src/org/apache/roller/business/hibernate/ src/org/apache/roller/config/
src/org/apache/roller/pojos/
src/org/apache/roller/presentation/weblog/actions/
src/org/apache/roller/presentat...
Author: agilliland
Date: Mon May 15 11:56:33 2006
New Revision: 406715
URL: http://svn.apache.org/viewcvs?rev=406715&view=rev
Log:
adding ability for Roller admins to control default auto ping status for common ping targets.
- added new column "autoEnabled" to pingtarget table
- added new attribute "autoEnabled" to PingTargetData pojo
- added UI elements for controlling auto enabled status for ping targets
- updated weblog creation process with new code that adds auto pings for auto enabled ping targets
Added:
incubator/roller/trunk/metadata/database/230-to-240-migration.vm
Modified:
incubator/roller/trunk/metadata/database/control.vm
incubator/roller/trunk/metadata/database/createdb.vm
incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
incubator/roller/trunk/src/org/apache/roller/config/PingConfig.java
incubator/roller/trunk/src/org/apache/roller/pojos/PingTargetData.java
incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/BasePingTargetsAction.java
incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/CustomPingTargetsAction.java
incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/CommonPingTargetsAction.java
incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
incubator/roller/trunk/web/website/CommonPingTargets.jsp
Added: incubator/roller/trunk/metadata/database/230-to-240-migration.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/metadata/database/230-to-240-migration.vm?rev=406715&view=auto
==============================================================================
--- incubator/roller/trunk/metadata/database/230-to-240-migration.vm (added)
+++ incubator/roller/trunk/metadata/database/230-to-240-migration.vm Mon May 15 11:56:33 2006
@@ -0,0 +1,11 @@
+#**
+230-to-240-migration.vm: Velocity template that generates vendor-specific database scripts
+
+DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
+**#
+
+-- Roller 2.4 schema changes
+
+#addColumnNotNull("pingtarget" "autoenabled" $BOOLEAN_SQL_TYPE $BOOLEAN_FALSE)
+
+
Modified: incubator/roller/trunk/metadata/database/control.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/metadata/database/control.vm?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/metadata/database/control.vm (original)
+++ incubator/roller/trunk/metadata/database/control.vm Mon May 15 11:56:33 2006
@@ -5,7 +5,7 @@
Follow the installation guide for instructions on setting up your database.
#** Define templates to be generated **#
-#set( $templates = ["createdb", "200-to-210-migration", "210-to-230-migration"])
+#set( $templates = ["createdb", "200-to-210-migration", "210-to-230-migration", "230-to-240-migration"])
#** Define special macro needed for alter table with not-null restriction **#
#macro(addColumnNotNull $table $column $type $default)
Modified: incubator/roller/trunk/metadata/database/createdb.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/metadata/database/createdb.vm?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/metadata/database/createdb.vm (original)
+++ incubator/roller/trunk/metadata/database/createdb.vm Mon May 15 11:56:33 2006
@@ -239,7 +239,8 @@
pingurl varchar(255) not null,
websiteid varchar(48),
conditioncode integer default 0 not null,
- lastsuccess $TIMESTAMP_SQL_TYPE
+ lastsuccess $TIMESTAMP_SQL_TYPE,
+ autoenabled $BOOLEAN_SQL_TYPE_FALSE not null
);
create index pt_websiteid_idx on pingtarget( websiteid );
Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java Mon May 15 11:56:33 2006
@@ -26,7 +26,6 @@
import java.util.List;
import java.util.Map;
import org.hibernate.Criteria;
-import org.hibernate.Query;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;
@@ -330,7 +329,21 @@
}
}
}
-
+
+ // add any auto enabled ping targets
+ PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
+ AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
+
+ Iterator pingTargets = pingTargetMgr.getCommonPingTargets().iterator();
+ PingTargetData pingTarget = null;
+ while(pingTargets.hasNext()) {
+ pingTarget = (PingTargetData) pingTargets.next();
+
+ if(pingTarget.isAutoEnabled()) {
+ AutoPingData autoPing = new AutoPingData(null, pingTarget, newWeblog);
+ autoPingMgr.saveAutoPing(autoPing);
+ }
+ }
}
Modified: incubator/roller/trunk/src/org/apache/roller/config/PingConfig.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/config/PingConfig.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/config/PingConfig.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/config/PingConfig.java Mon May 15 11:56:33 2006
@@ -204,7 +204,7 @@
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);
+ PingTargetData pingTarget = new PingTargetData(null, name, url, null, false);
pingTargetMgr.savePingTarget(pingTarget);
}
else
Modified: incubator/roller/trunk/src/org/apache/roller/pojos/PingTargetData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/pojos/PingTargetData.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/PingTargetData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/PingTargetData.java Mon May 15 11:56:33 2006
@@ -47,6 +47,7 @@
private WebsiteData website = null;
private int conditionCode = -1;
private Timestamp lastSuccess = null;
+ private boolean autoEnabled = false;
/**
@@ -64,13 +65,14 @@
* @param pingUrl the URL to which to send the ping
* @param website the website (on this server) for which this is a custom ping target (may be null)
*/
- public PingTargetData(String id, String name, String pingUrl, WebsiteData website) {
+ public PingTargetData(String id, String name, String pingUrl, WebsiteData website, boolean autoEnable) {
this.id = id;
this.name = name;
this.pingUrl = pingUrl;
this.website = website;
this.conditionCode = CONDITION_OK;
this.lastSuccess = null;
+ this.autoEnabled = autoEnable;
}
@@ -86,6 +88,7 @@
website = other.getWebsite();
conditionCode = other.getConditionCode();
lastSuccess = other.getLastSuccess();
+ autoEnabled = other.isAutoEnabled();
}
@@ -232,6 +235,30 @@
*/
public void setLastSuccess(Timestamp lastSuccess) {
this.lastSuccess = lastSuccess;
+ }
+
+
+ /**
+ * Is this ping target enabled by default for new weblogs?
+ *
+ * @return true if ping target is auto enabled. false otherwise.
+ * @ejb:persistent-field
+ * @hibernate.property column="autoenabled" not-null="true"
+ */
+ public boolean isAutoEnabled() {
+ return autoEnabled;
+ }
+
+
+ /**
+ * Set the auto enabled status for this ping target. This field only
+ * applies for common ping targets.
+ *
+ * @param autoEnabled true if the ping target should be auto enabled.
+ * @ejb:persistent-field
+ */
+ public void setAutoEnabled(boolean autoEnabled) {
+ this.autoEnabled = autoEnabled;
}
Modified: incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/BasePingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/BasePingTargetsAction.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/BasePingTargetsAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/BasePingTargetsAction.java Mon May 15 11:56:33 2006
@@ -327,7 +327,7 @@
* @return the ping target specified by the id in the request
* @throws RollerException
*/
- private PingTargetData select(RollerRequest rreq) throws RollerException
+ protected PingTargetData select(RollerRequest rreq) throws RollerException
{
String pingTargetId = rreq.getRequest().getParameter(RollerRequest.PINGTARGETID_KEY);
PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
Modified: incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/CustomPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/CustomPingTargetsAction.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/CustomPingTargetsAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/weblog/actions/CustomPingTargetsAction.java Mon May 15 11:56:33 2006
@@ -102,7 +102,7 @@
throws RollerException
{
return new PingTargetData(null, pingTargetForm.getName(),
- pingTargetForm.getPingUrl(), rreq.getWebsite());
+ pingTargetForm.getPingUrl(), rreq.getWebsite(), false);
}
Modified: incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/CommonPingTargetsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/CommonPingTargetsAction.java?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/CommonPingTargetsAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/presentation/website/actions/CommonPingTargetsAction.java Mon May 15 11:56:33 2006
@@ -19,6 +19,9 @@
package org.apache.roller.presentation.website.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;
@@ -31,6 +34,9 @@
import org.apache.roller.presentation.RollerSession;
import org.apache.roller.presentation.forms.PingTargetForm;
import org.apache.roller.presentation.weblog.actions.BasePingTargetsAction;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
/**
* Administer common ping targets.
@@ -64,6 +70,60 @@
}
/*
+ * 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()))
+ {
+ return mapping.findForward("access-denied");
+ }
+ pingTarget.setAutoEnabled(true);
+ RollerFactory.getRoller().flush();
+
+ return view(mapping, form, req, res);
+ }
+ catch (Exception e)
+ {
+ mLogger.error("ERROR in action", e);
+ throw new ServletException(e);
+ }
+ }
+
+ /*
+ * Set a pint target auto enabled to false.
+ */
+ 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()))
+ {
+ return mapping.findForward("access-denied");
+ }
+ pingTarget.setAutoEnabled(false);
+ RollerFactory.getRoller().flush();
+
+ return view(mapping, form, req, res);
+ }
+ 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.
*/
@@ -80,7 +140,7 @@
throws RollerException
{
return new PingTargetData(null, pingTargetForm.getName(),
- pingTargetForm.getPingUrl(), null);
+ pingTargetForm.getPingUrl(), null, pingTargetForm.isAutoEnabled());
}
Modified: incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Mon May 15 11:56:33 2006
@@ -866,6 +866,7 @@
pingTarget.name=Name
pingTarget.pingUrl=Ping URL
+pingTarget.autoEnabled=Auto Ping?
pingTarget.addNew=Add New
pingTarget.save=Save
pingTarget.edit=Edit
Modified: incubator/roller/trunk/web/website/CommonPingTargets.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/website/CommonPingTargets.jsp?rev=406715&r1=406714&r2=406715&view=diff
==============================================================================
--- incubator/roller/trunk/web/website/CommonPingTargets.jsp (original)
+++ incubator/roller/trunk/web/website/CommonPingTargets.jsp Mon May 15 11:56:33 2006
@@ -29,7 +29,8 @@
<%-- Headings --%>
<tr class="rollertable">
<th class="rollertable" width="20%%"><fmt:message key="pingTarget.name" /></th>
- <th class="rollertable" width="70%"><fmt:message key="pingTarget.pingUrl" /></th>
+ <th class="rollertable" width="65%"><fmt:message key="pingTarget.pingUrl" /></th>
+ <th class="rollertable" width="5%"><fmt:message key="pingTarget.autoEnabled" /></th>
<th class="rollertable" width="5%"><fmt:message key="pingTarget.edit" /></th>
<th class="rollertable" width="5%"><fmt:message key="pingTarget.remove" /></th>
</tr>
@@ -45,7 +46,33 @@
<td class="rollertable">
<str:truncateNicely lower="70" upper="75" ><c:out value="${pingTarget.pingUrl}" /></str:truncateNicely>
</td>
-
+
+ <!-- TODO: Use icons here -->
+ <td class="rollertable" align="center" >
+ <c:choose>
+ <c:when test="${pingTarget.autoEnabled}">
+ <roller:link page="/admin/commonPingTargets.do">
+ <roller:linkparam
+ id="<%= RollerRequest.PINGTARGETID_KEY %>"
+ name="pingTarget" property="id" />
+ <roller:linkparam
+ id="method" value="disableSelected" />
+ <fmt:message key="pingTarget.disable"/>
+ </roller:link>
+ </c:when>
+ <c:otherwise >
+ <roller:link page="/admin/commonPingTargets.do">
+ <roller:linkparam
+ id="<%= RollerRequest.PINGTARGETID_KEY %>"
+ name="pingTarget" property="id" />
+ <roller:linkparam
+ id="method" value="enableSelected" />
+ <fmt:message key="pingTarget.enable"/>
+ </roller:link>
+ </c:otherwise>
+ </c:choose>
+ </td>
+
<td class="rollertable" align="center">
<roller:link page="/admin/commonPingTargets.do">
<roller:linkparam