continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r360066 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ continuum-webapp/src...
Date Fri, 30 Dec 2005 10:55:12 GMT
Author: evenisse
Date: Fri Dec 30 02:54:57 2005
New Revision: 360066

URL: http://svn.apache.org/viewcvs?rev=360066&view=rev
Log:
Add mail notifier modification screens

Added:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
  (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
  (with props)
Removed:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/NotifierEditAction.java
Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddNotifierAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteNotifierAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
    maven/continuum/trunk/continuum-webapp/src/main/webapp/notifierMail.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/projectView.jsp

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Fri Dec 30 02:54:57 2005
@@ -148,6 +148,12 @@
     void updateNotifier( int projectId, int notifierId, Map configuration )
         throws ContinuumException;
 
+    void updateNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException;
+
+    void addNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException;
+
     void addNotifier( int projectId, String notifierType, Map configuration )
         throws ContinuumException;
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Fri Dec 30 02:54:57 2005
@@ -817,6 +817,21 @@
         return notifier;
     }
 
+    public void updateNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException
+    {
+        Project project = getProjectWithAllDetails( projectId );
+
+        ProjectNotifier notif = getNotifier( projectId, notifier.getId() );
+
+        // I remove notifier then add it instead of update it due to a ClassCastException
in jpox
+        project.removeNotifier( notif );
+
+        updateProject( project );
+
+        addNotifier( projectId, notifier );
+    }
+
     public void updateNotifier( int projectId, int notifierId, Map configuration )
         throws ContinuumException
     {
@@ -863,6 +878,32 @@
         return notifierProperties;
     }
 
+    public void addNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException
+    {
+        ProjectNotifier notif = new ProjectNotifier();
+
+        notif.setSendOnSuccess( notifier.isSendOnSuccess() );
+
+        notif.setSendOnFailure( notifier.isSendOnFailure() );
+
+        notif.setSendOnError( notifier.isSendOnError() );
+
+        notif.setSendOnWarning( notifier.isSendOnWarning() );
+
+        notif.setConfiguration( notifier.getConfiguration() );
+
+        notif.setType( notifier.getType() );
+
+        notifier.setFrom( ProjectNotifier.FROM_USER );
+
+        Project project = getProjectWithAllDetails( projectId );
+
+        project.addNotifier( notif );
+
+        updateProject( project );
+    }
+
     public void addNotifier( int projectId, String notifierType, Map configuration )
         throws ContinuumException
     {
@@ -894,13 +935,7 @@
 
         notifier.setConfiguration( notifierProperties );
 
-        notifier.setFrom( ProjectNotifier.FROM_USER );
-
-        Project project = getProjectWithAllDetails( projectId );
-
-        project.addNotifier( notifier );
-
-        updateProject( project );
+        addNotifier( projectId, notifier );
     }
 
     public void removeNotifier( int projectId, int notifierId )

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java?rev=360066&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
Fri Dec 30 02:54:57 2005
@@ -0,0 +1,199 @@
+package org.apache.maven.continuum.web.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+
+import com.opensymphony.xwork.ActionSupport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public abstract class AbstractNotifierEditAction
+    extends ActionSupport
+{
+    private Continuum continuum;
+
+    private ProjectNotifier notifier;
+
+    private int projectId;
+
+    private int notifierId;
+
+    private boolean sendOnSuccess;
+
+    private boolean sendOnFailure;
+    
+    private boolean sendOnError;
+
+    private boolean sendOnWarning;
+
+    public String execute()
+    {
+        try
+        {
+            boolean isNew = false;
+
+            notifier = getNotifier();
+
+            if ( notifier == null || notifierId == 0 )
+            {
+                notifier = new ProjectNotifier();
+
+                isNew = true;
+            }
+
+            notifier.setSendOnSuccess( sendOnSuccess );
+
+            notifier.setSendOnFailure( sendOnFailure );
+
+            notifier.setSendOnError( sendOnError );
+
+            notifier.setSendOnWarning( sendOnWarning );
+
+            setNotifierConfiguration( notifier );
+
+            if ( !isNew )
+            {
+                continuum.updateNotifier( projectId, notifier );
+            }
+            else
+            {
+                continuum.addNotifier( projectId, notifier );
+            }
+        }
+        catch ( ContinuumException e )
+        {
+            addActionMessage( "Can't update notifier (id=" + notifierId + ") for project
" + projectId + " : " + e.getMessage() );
+
+            e.printStackTrace();
+
+            return ERROR;
+        }
+
+        return SUCCESS;
+    }
+
+    public String doDefault()
+    {
+        try
+        {
+            notifier = getNotifier();
+
+            if ( notifier == null )
+            {
+                notifier = new ProjectNotifier();
+            }
+        }
+        catch ( ContinuumException e )
+        {
+            addActionMessage( "Can't get notifier informations (id=" + notifierId + ") for
project " + projectId + " : " + e.getMessage() );
+
+            e.printStackTrace();
+
+            return ERROR;
+        }
+
+        sendOnSuccess = notifier.isSendOnSuccess();
+
+        sendOnFailure = notifier.isSendOnFailure();
+
+        sendOnError =notifier.isSendOnError();
+
+        sendOnWarning = notifier.isSendOnWarning();
+
+        initConfiguration( notifier.getConfiguration() );
+
+        return INPUT;
+    }
+
+    protected abstract void initConfiguration( Map configuration );
+
+    protected abstract void setNotifierConfiguration( ProjectNotifier notifier );
+
+    private ProjectNotifier getNotifier()
+        throws ContinuumException
+    {
+        return continuum.getNotifier( projectId, notifierId );
+    }
+
+    public int getProjectId()
+    {
+        return projectId;
+    }
+
+    public void setProjectId( int projectId )
+    {
+        this.projectId = projectId;
+    }
+
+    public int getNotifierId()
+    {
+        return notifierId;
+    }
+
+    public void setNotifierId( int notifierId )
+    {
+        this.notifierId = notifierId;
+    }
+
+    public boolean isSendOnSuccess()
+    {
+        return sendOnSuccess;
+    }
+
+    public void setSendOnSuccess( boolean sendOnSuccess )
+    {
+        this.sendOnSuccess = sendOnSuccess;
+    }
+
+    public boolean isSendOnFailure()
+    {
+        return sendOnFailure;
+    }
+
+    public void setSendOnFailure( boolean sendOnFailure )
+    {
+        this.sendOnFailure = sendOnFailure;
+    }
+
+    public boolean isSendOnError()
+    {
+        return sendOnError;
+    }
+
+    public void setSendOnError( boolean sendOnError )
+    {
+        this.sendOnError = sendOnError;
+    }
+
+    public boolean isSendOnWarning()
+    {
+        return sendOnWarning;
+    }
+
+    public void setSendOnWarning( boolean sendOnWarning )
+    {
+        this.sendOnWarning = sendOnWarning;
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractNotifierEditAction.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddNotifierAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddNotifierAction.java?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddNotifierAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddNotifierAction.java
Fri Dec 30 02:54:57 2005
@@ -43,4 +43,14 @@
     {
         this.notifierType = notifierType;
     }
+
+    public int getProjectId()
+    {
+        return projectId;
+    }
+
+    public void setProjectId( int projectId )
+    {
+        this.projectId = projectId;
+    }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteNotifierAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteNotifierAction.java?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteNotifierAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/DeleteNotifierAction.java
Fri Dec 30 02:54:57 2005
@@ -40,9 +40,7 @@
     {
         try
         {
-            System.out.println( "DeleteNotifier" + projectId + " - " + notifierId);
             continuum.removeNotifier( projectId, notifierId );
-            System.out.println( "DeleteNotifier2");
         }
         catch ( ContinuumException e )
         {

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java?rev=360066&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
Fri Dec 30 02:54:57 2005
@@ -0,0 +1,56 @@
+package org.apache.maven.continuum.web.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class MailNotifierEditAction
+    extends AbstractNotifierEditAction
+{
+    private String address;
+
+    protected void initConfiguration( Map configuration )
+    {
+        address = (String) configuration.get( "address" );
+    }
+
+    protected void setNotifierConfiguration( ProjectNotifier notifier )
+    {
+        HashMap configuration = new HashMap();
+
+        configuration.put( "address", address );
+
+        notifier.setConfiguration( configuration );
+    }
+
+    public String getAddress()
+    {
+        return address;
+    }
+
+    public void setAddress( String address )
+    {
+        this.address = address;
+    }
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/MailNotifierEditAction.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/components.xml
Fri Dec 30 02:54:57 2005
@@ -172,6 +172,17 @@
       <implementation>org.apache.maven.continuum.web.action.AddNotifierAction</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
     </component>
+    <component>
+      <role>com.opensymphony.xwork.Action</role>
+      <role-hint>mailNotifierEdit</role-hint>
+      <implementation>org.apache.maven.continuum.web.action.MailNotifierEditAction</implementation>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.continuum.Continuum</role>
+        </requirement>
+      </requirements>
+    </component>
 
     <!--
      | Components

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Fri Dec 30 02:54:57 2005
@@ -214,4 +214,8 @@
 notifier.page.title = Continuum - Add/Edit {0} Notifier
 notifier.section.title = Add/Edit {0} Notifier
 notifier.type.label = Type
-
+notifier.mail.recipient.label = Mail Recipient Address
+notifier.event.sendOnSuccess = Send on Success
+notifier.event.sendOnFailure = Send on Failure
+notifier.event.sendOnError = Send on Error
+notifier.event.sendOnWarning = Send on Warning

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Fri Dec 30 02:54:57
2005
@@ -120,5 +120,11 @@
             <result name="msn_input">notifierMsn.jsp</result>
             <result name="jabber_input">notifierJabber.jsp</result>
         </action>
+
+        <action name="mailNotifierEdit"
+                class="mailNotifierEdit">
+            <result name="input">notifierMail.jsp</result>
+            <result name="success" type="chain">projectView</result>
+        </action>
     </package>
 </xwork>

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/notifierMail.jsp
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/webapp/notifierMail.jsp?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/notifierMail.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/notifierMail.jsp Fri Dec 30 02:54:57
2005
@@ -17,7 +17,16 @@
         </h3>
 
         <div class="axial">
-            Mail
+            <ww:form action="mailNotifierEdit.action" method="post">
+                <ww:hidden name="notifierId"/>
+                <ww:hidden name="projectId"/>
+                <ww:textfield label="%{getText('notifier.mail.recipient.label')}" name="address"/>
+                <ww:checkbox label="%{getText('notifier.event.sendOnSuccess')}" name="sendOnSuccess"
fieldValue="true"/>
+                <ww:checkbox label="%{getText('notifier.event.sendOnFailure')}" name="sendOnFailure"
fieldValue="true"/>
+                <ww:checkbox label="%{getText('notifier.event.sendOnError')}" name="sendOnError"
fieldValue="true"/>
+                <ww:checkbox label="%{getText('notifier.event.sendOnWarning')}" name="sendOnWarning"
fieldValue="true"/>
+                <ww:submit value="%{getText('save')}"/>
+            </ww:form>
         </div>
       </div>
     </body>

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/projectView.jsp
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/webapp/projectView.jsp?rev=360066&r1=360065&r2=360066&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/projectView.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/projectView.jsp Fri Dec 30 02:54:57
2005
@@ -87,7 +87,7 @@
             <ec:column property="from" title="projectView.notifier.from" cell="org.apache.maven.continuum.web.view.projectview.NotifierFromCell"/>
             <ec:column property="actions" title="&nbsp;">
                 <c:if test="${!pageScope.notifier.fromProject}">
-                    <a href="${pageContext.request.contextPath}/NotifierEdit!default.action?projectId=<ww:property
value="project.id"/>&notifierId=${pageScope.notifier.id}"><ww:text name="edit"/></a>
+                    <a href="${pageContext.request.contextPath}/${pageScope.notifier.type}NotifierEdit!default.action?projectId=<ww:property
value="project.id"/>&notifierId=${pageScope.notifier.id}"><ww:text name="edit"/></a>
                     &nbsp;
                     <a href="${pageContext.request.contextPath}/deleteNotifier!default.action?projectId=<ww:property
value="project.id"/>&notifierId=${pageScope.notifier.id}&notifierType=${pageScope.notifier.type}"><ww:text
name="delete"/></a>
                 </c:if>



Mime
View raw message