You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2007/01/25 22:36:25 UTC
svn commit: r500001 - in /maven/continuum/trunk/continuum-webapp/src/main:
java/org/apache/maven/continuum/web/action/component/ mdo/
webapp/WEB-INF/jsp/ webapp/WEB-INF/jsp/components/
Author: evenisse
Date: Thu Jan 25 13:36:25 2007
New Revision: 500001
URL: http://svn.apache.org/viewvc?view=rev&rev=500001
Log:
Add project notifiers in project group notifier page like it's done for build definitions
Modified:
maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
maven/continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo
maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp
maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp
Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java?view=diff&rev=500001&r1=500000&r2=500001
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java Thu Jan 25 13:36:25 2007
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package org.apache.maven.continuum.web.action.component;
@@ -22,11 +22,6 @@
* under the License.
*/
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.maven.continuum.ContinuumException;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -34,10 +29,16 @@
import org.apache.maven.continuum.web.action.ContinuumActionSupport;
import org.apache.maven.continuum.web.model.NotifierSummary;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
/**
- * Component Action that prepares and provides Project Group Notifier and
+ * Component Action that prepares and provides Project Group Notifier and
* Project Notifier summaries.
- *
+ *
* @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
* @version $Id$
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="notifierSummary"
@@ -46,19 +47,13 @@
extends ContinuumActionSupport
{
/**
- * Identifier for the {@link ProjectGroup} for which the Notifier summary
+ * Identifier for the {@link ProjectGroup} for which the Notifier summary
* needs to be prepared for.
*/
private int projectGroupId;
/**
- * Name of the {@link ProjectGroup} for which the Notifier summary needs
- * to be prepared for.
- */
- private String projectGroupName;
-
- /**
- * Identifier for the {@link Project} for which the Notifier summary needs
+ * Identifier for the {@link Project} for which the Notifier summary needs
* to be prepared for.
*/
private int projectId;
@@ -70,43 +65,104 @@
private List projectGroupNotifierSummaries = new ArrayList();
+ private List projectNotifierSummaries = new ArrayList();
+
/**
* Prepare Notifier summary for a {@link Project}.
+ *
* @return
*/
public String summarizeForProject()
{
getLogger().debug( "Obtaining summary for Project Id: " + projectId );
+
+ try
+ {
+ projectNotifierSummaries = summarizeForProject( projectId );
+ }
+ catch ( ContinuumException e )
+ {
+ getLogger().error( "Unable to prepare Notifier summaries for Project Id: " + projectId, e );
+ return ERROR;
+ }
+
return SUCCESS;
}
/**
+ * Prepare Notifier summary for a {@link Project}.
+ *
+ * @param projectId The project id.
+ * @return
+ */
+ private List summarizeForProject( int projectId )
+ throws ContinuumException
+ {
+ return gatherProjectNotifierSummaries( projectId );
+ }
+
+ /**
* Prepare Notifier summary for a {@link ProjectGroup}.
+ *
* @return
*/
public String summarizeForProjectGroup()
{
getLogger().debug( "Obtaining summary for ProjectGroup Id:" + projectGroupId );
+
try
{
- projectGroupNotifierSummaries = gatherGroupNotifierSummaries( projectGroupId );
+ projectGroupNotifierSummaries = gatherGroupNotifierSummaries();
+
+ Collection projects = getContinuum().getProjectsInGroup( projectGroupId );
+ if ( projects != null )
+ {
+ for ( Iterator i = projects.iterator(); i.hasNext(); )
+ {
+ Project p = (Project) i.next();
+ projectNotifierSummaries.addAll( summarizeForProject( p.getId() ) );
+ }
+ }
}
catch ( ContinuumException e )
{
getLogger().error( "Unable to prepare Notifier summaries for ProjectGroup Id: " + projectGroupId, e );
return ERROR;
}
+
return SUCCESS;
}
/**
+ * Prepares and returns a list of Notifier summaries for the specified Project Id.
+ *
+ * @param projectId The project id.
+ * @return List of {@link NotifierSummary} instance for the specified project.
+ * @throws ContinuumException if there was an error obtaining
+ * and preparing Notifier Summary list for the project
+ */
+ private List gatherProjectNotifierSummaries( int projectId )
+ throws ContinuumException
+ {
+ List summaryList = new ArrayList();
+ Project project = getContinuum().getProjectWithAllDetails( projectId );
+
+ for ( Iterator i = project.getNotifiers().iterator(); i.hasNext(); )
+ {
+ NotifierSummary ns = generateProjectNotifierSummary( (ProjectNotifier) i.next(), project );
+ summaryList.add( ns );
+ }
+
+ return summaryList;
+ }
+
+ /**
* Prepares and returns {@link ProjectGroup} summaries for the specified project group Id.
- *
- * @param projectGroupId
+ *
* @return
- * @throws ContinuumException if there was an error fetching the {@link ProjectGroup} for specified Id.
+ * @throws ContinuumException if there was an error fetching the {@link ProjectGroup} for specified Id.
*/
- private List gatherGroupNotifierSummaries( int projectGroupId )
+ private List gatherGroupNotifierSummaries()
throws ContinuumException
{
List summaryList = new ArrayList();
@@ -114,7 +170,7 @@
for ( Iterator i = projectGroup.getNotifiers().iterator(); i.hasNext(); )
{
- NotifierSummary ns = generateNotifierSummary( (ProjectNotifier) i.next() );
+ NotifierSummary ns = generateGroupNotifierSummary( (ProjectNotifier) i.next() );
summaryList.add( ns );
}
@@ -123,80 +179,115 @@
/**
* Prepares a {@link NotifierSummary} from a {@link ProjectNotifier} instance.
+ *
+ * @param notifier
+ * @return
+ */
+ private NotifierSummary generateProjectNotifierSummary( ProjectNotifier notifier, Project project )
+ {
+ return generateNotifierSummary( notifier, projectGroupId, project );
+ }
+
+ /**
+ * Prepares a {@link NotifierSummary} from a {@link ProjectNotifier} instance.
+ *
* @param notifier
* @return
*/
- private NotifierSummary generateNotifierSummary( ProjectNotifier notifier )
+ private NotifierSummary generateGroupNotifierSummary( ProjectNotifier notifier )
+ {
+ return generateNotifierSummary( notifier, projectGroupId, null );
+ }
+
+ /**
+ * Prepares a {@link NotifierSummary} from a {@link ProjectNotifier} instance.
+ *
+ * @param notifier
+ * @return
+ */
+ private NotifierSummary generateNotifierSummary( ProjectNotifier notifier, int projectGroupId, Project project )
{
NotifierSummary ns = new NotifierSummary();
ns.setId( notifier.getId() );
ns.setType( notifier.getType() );
- ns.setProjectGroupId( getProjectGroupId() );
+ ns.setProjectGroupId( projectGroupId );
+ if ( project != null )
+ {
+ ns.setProjectId( project.getId() );
+ ns.setProjectName( project.getName() );
+ }
if ( notifier.isFromProject() )
{
- ns.setFrom( "PROJECT" );
+ ns.setFromProject( true );
}
else
{
- ns.setFrom( "USER" );
+ ns.setFromProject( false );
}
// Source the recipient
Map configuration = notifier.getConfiguration();
-
+
String recipient = "unknown";
- if ( ( "mail".equals( notifier.getType() ) ) ||
- ( "msn".equals( notifier.getType() ) ) ||
- ( "jabber".equals( notifier.getType() ) ) )
+ if ( ( "mail".equals( notifier.getType() ) ) || ( "msn".equals( notifier.getType() ) ) ||
+ ( "jabber".equals( notifier.getType() ) ) )
{
recipient = (String) configuration.get( "address" );
}
-
+
if ( "irc".equals( notifier.getType() ) )
{
recipient = (String) configuration.get( "host" );
-
+
if ( configuration.get( "port" ) != null )
{
recipient = recipient + ":" + (String) configuration.get( "port" );
}
-
+
recipient = recipient + ":" + (String) configuration.get( "channel" );
}
-
+
if ( "wagon".equals( notifier.getType() ) )
{
recipient = (String) configuration.get( "url" );
}
-
+
ns.setRecipient( recipient );
-
+
// XXX: Hack - just for testing :)
StringBuffer sb = new StringBuffer();
if ( notifier.isSendOnError() )
+ {
sb.append( "Error" );
+ }
if ( notifier.isSendOnFailure() )
{
if ( sb.length() > 0 )
+ {
sb.append( '/' );
+ }
sb.append( "Failure" );
}
if ( notifier.isSendOnSuccess() )
{
if ( sb.length() > 0 )
+ {
sb.append( '/' );
+ }
sb.append( "Success" );
}
if ( notifier.isSendOnWarning() )
{
if ( sb.length() > 0 )
+ {
sb.append( '/' );
+ }
sb.append( "Warning" );
}
ns.setEvents( sb.toString() );
-
+
ns.setEnabled( notifier.isEnabled() );
return ns;
}
@@ -220,22 +311,6 @@
}
/**
- * @return the projectGroupName
- */
- public String getProjectGroupName()
- {
- return projectGroupName;
- }
-
- /**
- * @param projectGroupName the projectGroupName to set
- */
- public void setProjectGroupName( String projectGroupName )
- {
- this.projectGroupName = projectGroupName;
- }
-
- /**
* @return the projectId
*/
public int getProjectId()
@@ -268,7 +343,7 @@
}
/**
- * @return the groupBuildDefinitionSummaries
+ * @return the projectGroupNotifierSummaries
*/
public List getProjectGroupNotifierSummaries()
{
@@ -276,10 +351,26 @@
}
/**
- * @param groupBuildDefinitionSummaries the groupBuildDefinitionSummaries to set
+ * @param projectGroupNotifierSummaries the projectGroupNotifierSummaries to set
+ */
+ public void setProjectGroupNotifierSummaries( List projectGroupNotifierSummaries )
+ {
+ this.projectGroupNotifierSummaries = projectGroupNotifierSummaries;
+ }
+
+ /**
+ * @return the projectNotifierSummaries
+ */
+ public List getProjectNotifierSummaries()
+ {
+ return projectNotifierSummaries;
+ }
+
+ /**
+ * @param projectNotifierSummaries the projectNotifierSummaries to set
*/
- public void setProjectGroupNotifierSummaries( List groupBuildDefinitionSummaries )
+ public void setProjectNotifierSummaries( List projectNotifierSummaries )
{
- this.projectGroupNotifierSummaries = groupBuildDefinitionSummaries;
+ this.projectNotifierSummaries = projectNotifierSummaries;
}
}
Modified: maven/continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo?view=diff&rev=500001&r1=500000&r2=500001
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo Thu Jan 25 13:36:25 2007
@@ -345,21 +345,28 @@
<name>id</name>
<version>1.0.0</version>
<required>true</required>
- <description>id of the build definition</description>
+ <description>id of the notifier</description>
<type>int</type>
</field>
<field>
<name>projectId</name>
<version>1.0.0</version>
<required>false</required>
- <description>project id of the project containing the build definition</description>
+ <description>project id of the project containing the notifier</description>
<type>int</type>
</field>
<field>
+ <name>projectName</name>
+ <version>1.0.0</version>
+ <required>false</required>
+ <description>project name of the project containing the notifier</description>
+ <type>String</type>
+ </field>
+ <field>
<name>projectGroupId</name>
<version>1.0.0</version>
<required>false</required>
- <description>project group id of the project group with the build definition</description>
+ <description>project group id of the project group with the notifier</description>
<type>int</type>
</field>
<field>
@@ -370,11 +377,11 @@
<type>String</type>
</field>
<field>
- <name>from</name>
+ <name>fromProject</name>
<version>1.0.0</version>
<required>true</required>
<description>The origin of the notifier (pom or user).</description>
- <type>String</type>
+ <type>boolean</type>
</field>
<field>
<name>events</name>
Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp?view=diff&rev=500001&r1=500000&r2=500001
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp Thu Jan 25 13:36:25 2007
@@ -37,53 +37,43 @@
<ec:column property="type" title="projectView.notifier.type"/>
<ec:column property="recipient" title="projectView.notifier.recipient"/>
<ec:column property="events" title="projectView.notifier.events"/>
- <ec:column property="sender" title="projectView.notifier.from"/>
+ <!-- ec:column property="sender" title="projectView.notifier.sender"/ -->
<ec:column property="editActions" title=" " width="1%">
- <ww:if test="${pageScope.projectGroupNotifierSummary.from == 'PROJECT'}">
+ <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroup.name}">
+ <ww:url id="editUrl" action="editProjectGroupNotifier" namespace="/">
+ <ww:param name="projectGroupId">${pageScope.projectGroupNotifierSummary.projectGroupId}</ww:param>
+ <ww:param name="notifierId">${pageScope.projectGroupNotifierSummary.id}</ww:param>
+ <ww:param name="notifierType">${pageScope.projectGroupNotifierSummary.type}</ww:param>
+ </ww:url>
+ <ww:a href="%{editUrl}">
+ <img src="<ww:url value='/images/edit.gif'/>" alt="Edit" title="Edit" border="0">
+ </ww:a>
+ </pss:ifAuthorized>
+ <pss:elseAuthorized>
<img src="<ww:url value='/images/edit_disabled.gif'/>" alt="Edit" title="Edit" border="0">
- </ww:if>
- <ww:else>
- <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroupName}">
- <ww:url id="editUrl" action="editProjectGroupNotifier" namespace="/">
- <ww:param name="projectGroupId">${pageScope.projectGroupNotifierSummary.projectGroupId}</ww:param>
- <ww:param name="notifierId">${pageScope.projectGroupNotifierSummary.id}</ww:param>
- <ww:param name="notifierType">${pageScope.projectGroupNotifierSummary.type}</ww:param>
- </ww:url>
- <ww:a href="%{editUrl}">
- <img src="<ww:url value='/images/edit.gif'/>" alt="Edit" title="Edit" border="0">
- </ww:a>
- </pss:ifAuthorized>
- <pss:elseAuthorized>
- <img src="<ww:url value='/images/edit_disabled.gif'/>" alt="Edit" title="Edit" border="0">
- </pss:elseAuthorized>
- </ww:else>
+ </pss:elseAuthorized>
</ec:column>
<ec:column property="deleteActions" title=" " width="1%">
- <ww:if test="${pageScope.projectGroupNotifierSummary.from == 'PROJECT'}">
- <img src="<ww:url value='/images/delete_disabled.gif'/>" alt="Edit" title="Edit" border="0">
- </ww:if>
- <ww:else>
- <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroupName}">
- <ww:url id="removeUrl" action="deleteProjectGroupNotifier!default.action" namespace="/">
- <ww:param name="projectGroupId">${pageScope.projectGroupNotifierSummary.projectGroupId}</ww:param>
- <ww:param name="notifierId">${pageScope.projectGroupNotifierSummary.id}</ww:param>
- <ww:param name="notifierType">${pageScope.projectGroupNotifierSummary.type}</ww:param>
- <ww:param name="confirmed" value="false"/>
- </ww:url>
- <ww:a href="%{removeUrl}">
- <img src="<ww:url value='/images/delete.gif'/>" alt="Delete" title="Delete" border="0">
- </ww:a>
- </pss:ifAuthorized>
- <pss:elseAuthorized>
- <img src="<ww:url value='/images/delete_disabled.gif'/>" alt="Delete" title="Delete" border="0">
- </pss:elseAuthorized>
- </ww:else>
+ <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroup.name}">
+ <ww:url id="removeUrl" action="deleteProjectGroupNotifier!default.action" namespace="/">
+ <ww:param name="projectGroupId">${pageScope.projectGroupNotifierSummary.projectGroupId}</ww:param>
+ <ww:param name="notifierId">${pageScope.projectGroupNotifierSummary.id}</ww:param>
+ <ww:param name="notifierType">${pageScope.projectGroupNotifierSummary.type}</ww:param>
+ <ww:param name="confirmed" value="false"/>
+ </ww:url>
+ <ww:a href="%{removeUrl}">
+ <img src="<ww:url value='/images/delete.gif'/>" alt="Delete" title="Delete" border="0">
+ </ww:a>
+ </pss:ifAuthorized>
+ <pss:elseAuthorized>
+ <img src="<ww:url value='/images/delete_disabled.gif'/>" alt="Delete" title="Delete" border="0">
+ </pss:elseAuthorized>
</ec:column>
</ec:row>
</ec:table>
</ww:if>
- <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroupName}">
+ <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroup.name}">
<div class="functnbar3">
<ww:url id="addUrl" action="addProjectGroupNotifier" namespace="/" includeContext="false" includeParams="none" />
<ww:form action="%{addUrl}" method="post">
@@ -103,11 +93,52 @@
filterable="false"
sortable="false">
<ec:row>
+ <ec:column property="projectName" title="PROJECT NAME">
+ <ww:url id="projectUrl" action="projectView" namespace="/" includeParams="none">
+ <ww:param name="projectId" value="${pageScope.projectNotifierSummary.projectId}"/>
+ </ww:url>
+ <ww:a href="%{projectUrl}">${pageScope.projectNotifierSummary.projectName}</ww:a>
+ </ec:column>
<ec:column property="type" title="projectView.notifier.type"/>
<ec:column property="recipient" title="projectView.notifier.recipient"/>
<ec:column property="events" title="projectView.notifier.events"/>
- <ec:column property="sender" title="projectView.notifier.from"/>
- <ec:column property="state" value="Enabled/Disabled" />
+ <!-- ec:column property="sender" title="projectView.notifier.sender"/ -->
+ <ec:column property="editActions" title=" " width="1%">
+ <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroup.name}">
+ <c:if test="${!pageScope.projectNotifierSummary.fromProject}">
+ <ww:url id="editUrl" action="editProjectNotifier" namespace="/" includeContext="false" includeParams="none">
+ <ww:param name="projectGroupId">${pageScope.projectNotifierSummary.projectGroupId}</ww:param>
+ <ww:param name="projectId">${pageScope.projectNotifierSummary.projectId}</ww:param>
+ <ww:param name="notifierId">${pageScope.projectNotifierSummary.id}</ww:param>
+ <ww:param name="notifierType">${pageScope.projectNotifierSummary.type}</ww:param>
+ </ww:url>
+ <ww:a href="%{editUrl}">
+ <img src="<ww:url value='/images/edit.gif'/>" alt="Edit" title="Edit" border="0">
+ </ww:a>
+ </c:if>
+ </pss:ifAuthorized>
+ <pss:elseAuthorized>
+ <img src="<ww:url value='/images/edit_disabled.gif'/>" alt="Edit" title="Edit" border="0">
+ </pss:elseAuthorized>
+ </ec:column>
+ <ec:column property="deleteActions" title=" " width="1%">
+ <pss:ifAuthorized permission="continuum-modify-group" resource="${projectGroup.name}">
+ <c:if test="${!pageScope.projectNotifierSummary.fromProject}">
+ <ww:url id="removeUrl" action="deleteProjectNotifier" namespace="/">
+ <ww:param name="projectGroupId">${pageScope.projectNotifierSummary.projectGroupId}</ww:param>
+ <ww:param name="projectId">${pageScope.projectNotifierSummary.projectId}</ww:param>
+ <ww:param name="notifierId">${pageScope.projectNotifierSummary.id}</ww:param>
+ <ww:param name="confirmed" value="false"/>
+ </ww:url>
+ <ww:a href="%{removeUrl}">
+ <img src="<ww:url value='/images/delete.gif'/>" alt="Delete" title="Delete" border="0">
+ </ww:a>
+ </c:if>
+ </pss:ifAuthorized>
+ <pss:elseAuthorized>
+ <img src="<ww:url value='/images/delete_disabled.gif'/>" alt="Delete" title="Delete" border="0">
+ </pss:elseAuthorized>
+ </ec:column>
</ec:row>
</ec:table>
</ww:if>
Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp?view=diff&rev=500001&r1=500000&r2=500001
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupNotifier.jsp Thu Jan 25 13:36:25 2007
@@ -36,7 +36,6 @@
<ww:action name="projectGroupNotifierSummary" executeResult="true" namespace="component">
<ww:param name="projectGroupId" value="%{projectGroupId}"/>
- <ww:param name="projectGroupName" value="%{projectGroup.name}"/>
</ww:action>
</div>
</body>