You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@continuum.apache.org by Brett Porter <br...@apache.org> on 2006/09/15 01:23:47 UTC
Re: svn commit: r443424 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ScheduleAction.java resources/localization/Continuum.properties webapp/editSchedule.jsp
This suffers the same limitations that were originally found on the
same patch for archiva. Are you sure this is the latest?
On 15/09/2006, at 3:36 AM, carlos@apache.org wrote:
> Author: carlos
> Date: Thu Sep 14 10:36:45 2006
> New Revision: 443424
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=443424
> Log:
> [CONTINUUM-847] Add a friendly cron editor for editSchedule
> Submitted by: Maria Odea Ching
>
> Modified:
> maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/
> maven/continuum/web/action/ScheduleAction.java
> maven/continuum/trunk/continuum-webapp/src/main/resources/
> localization/Continuum.properties
> maven/continuum/trunk/continuum-webapp/src/main/webapp/
> editSchedule.jsp
>
> Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/
> apache/maven/continuum/web/action/ScheduleAction.java
> URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-
> webapp/src/main/java/org/apache/maven/continuum/web/action/
> ScheduleAction.java?view=diff&rev=443424&r1=443423&r2=443424
> ======================================================================
> ========
> --- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/
> maven/continuum/web/action/ScheduleAction.java (original)
> +++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/
> maven/continuum/web/action/ScheduleAction.java Thu Sep 14 10:36:45
> 2006
> @@ -32,8 +32,6 @@
>
> private boolean active = true;
>
> - private String cronExpression;
> -
> private int delay;
>
> private String description;
> @@ -48,6 +46,20 @@
>
> private int maxJobExecutionTime;
>
> + private String second = "0";
> +
> + private String minute = "0";
> +
> + private String hour = "*";
> +
> + private String dayOfMonth = "*";
> +
> + private String month = "*";
> +
> + private String dayOfWeek = "?";
> +
> + private String year;
> +
> public String summary()
> throws ContinuumException
> {
> @@ -64,7 +76,24 @@
> {
> schedule = getContinuum().getSchedule( id );
> active = schedule.isActive();
> - cronExpression = schedule.getCronExpression();
> +
> + String[] cronEx = schedule.getCronExpression
> ().split( " " );
> + int i = 0;
> + while ( i < cronEx.length )
> + {
> + switch( i )
> + {
> + case 0 : second = cronEx[i]; break;
> + case 1 : minute = cronEx[i]; break;
> + case 2 : hour = cronEx[i]; break;
> + case 3 : dayOfMonth = cronEx[i]; break;
> + case 4 : month = cronEx[i]; break;
> + case 5 : dayOfWeek = cronEx[i]; break;
> + case 6 : year = cronEx[i]; break;
> + }
> + i++;
> + }
> +
> description = schedule.getDescription();
> name = schedule.getName();
> delay = schedule.getDelay();
> @@ -113,7 +142,7 @@
> private Schedule setFields( Schedule schedule )
> {
> schedule.setActive( active );
> - schedule.setCronExpression( cronExpression );
> + schedule.setCronExpression( getCronExpression() );
> schedule.setDelay( delay );
> schedule.setDescription( description );
> schedule.setName( name );
> @@ -171,16 +200,6 @@
> this.active = active;
> }
>
> - public String getCronExpression()
> - {
> - return cronExpression;
> - }
> -
> - public void setCronExpression( String cronExpression )
> - {
> - this.cronExpression = cronExpression;
> - }
> -
> public int getDelay()
> {
> return delay;
> @@ -239,5 +258,81 @@
> public void setMaxJobExecutionTime( int maxJobExecutionTime )
> {
> this.maxJobExecutionTime = maxJobExecutionTime;
> + }
> +
> + public String getSecond()
> + {
> + return second;
> + }
> +
> + public void setSecond( String second )
> + {
> + this.second = second;
> + }
> +
> + public String getMinute()
> + {
> + return minute;
> + }
> +
> + public void setMinute( String minute )
> + {
> + this.minute = minute;
> + }
> +
> + public String getHour()
> + {
> + return hour;
> + }
> +
> + public void setHour( String hour )
> + {
> + this.hour = hour;
> + }
> +
> + public String getDayOfMonth()
> + {
> + return dayOfMonth;
> + }
> +
> + public void setDayOfMonth( String dayOfMonth )
> + {
> + this.dayOfMonth = dayOfMonth;
> + }
> +
> + public String getYear()
> + {
> + return year;
> + }
> +
> + public void setYear( String year )
> + {
> + this.year = year;
> + }
> +
> + public String getMonth()
> + {
> + return month;
> + }
> +
> + public void setMonth( String month )
> + {
> + this.month = month;
> + }
> +
> + public String getDayOfWeek()
> + {
> + return dayOfWeek;
> + }
> +
> + public void setDayOfWeek( String dayOfWeek )
> + {
> + this.dayOfWeek = dayOfWeek;
> + }
> +
> + private String getCronExpression()
> + {
> + return ( second + " " + minute + " " + hour + " " +
> dayOfMonth + " " +
> + month + " " + dayOfWeek + " " + year ).trim();
> }
> }
>
> Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/
> localization/Continuum.properties
> URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-
> webapp/src/main/resources/localization/Continuum.properties?
> view=diff&rev=443424&r1=443423&r2=443424
> ======================================================================
> ========
> --- maven/continuum/trunk/continuum-webapp/src/main/resources/
> localization/Continuum.properties (original)
> +++ maven/continuum/trunk/continuum-webapp/src/main/resources/
> localization/Continuum.properties Thu Sep 14 10:36:45 2006
> @@ -355,6 +355,13 @@
> schedule.quietPeriod.message = Enter a quiet period period for
> this schedule
> schedule.enabled.label = Enabled
> schedule.enabled.message = Enable/Disable the schedule
> +schedule.second.label = Second
> +schedule.minute.label = Minute
> +schedule.hour.label = Hour
> +schedule.dayOfMonth.label = Day of Month
> +schedule.month.label = Month
> +schedule.dayOfWeek.label = Day of Week
> +schedule.year.label = Year [optional]
>
> #
> ----------------------------------------------------------------------
> # Page: SurefireReport
>
> Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/
> editSchedule.jsp
> URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-
> webapp/src/main/webapp/editSchedule.jsp?
> view=diff&rev=443424&r1=443423&r2=443424
> ======================================================================
> ========
> --- maven/continuum/trunk/continuum-webapp/src/main/webapp/
> editSchedule.jsp (original)
> +++ maven/continuum/trunk/continuum-webapp/src/main/webapp/
> editSchedule.jsp Thu Sep 14 10:36:45 2006
> @@ -13,17 +13,31 @@
> <div class="axial">
> <ww:form action="saveSchedule" method="post">
> <ww:hidden name="id"/>
> - <table>
> - <tbody>
> + <table>
> <ww:textfield label="%{getText
> ('schedule.name.label')}" name="name" required="true">
> <ww:param name="desc"><p><ww:text
> name="schedule.name.message"/></p></ww:param>
> </ww:textfield>
> <ww:textfield label="%{getText
> ('schedule.description.label')}" name="description" required="true">
> <ww:param name="desc"><p><ww:text
> name="schedule.description.message"/></p></ww:param>
> </ww:textfield>
> - <ww:textfield label="%{getText
> ('schedule.cronExpression.label')}" name="cronExpression"
> required="true">
> - <ww:param name="desc"><p><ww:text
> name="schedule.cronExpression.message"/></p></ww:param>
> - </ww:textfield>
> +
> + <tr>
> + <th><ww:label theme="simple" value="%{getText
> ('schedule.cronExpression.label')}:" required="true"/></th>
> + <td>
> + <table>
> + <ww:textfield label="%{getText
> ('schedule.second.label')}" name="second" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.minute.label')}" name="minute" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.hour.label')}" name="hour" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.dayOfMonth.label')}" name="dayOfMonth" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.month.label')}" name="month" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.dayOfWeek.label')}" name="dayOfWeek" size="2"/>
> + <ww:textfield label="%{getText
> ('schedule.year.label')}" name="year" size="4">
> + <ww:param name="desc"><p><ww:text
> name="schedule.cronExpression.message"/></p></ww:param>
> + </ww:textfield>
> + </table>
> + </td>
> + </tr>
> +
> <ww:textfield label="%{getText
> ('schedule.maxJobExecutionTime.label')}" name="maxJobExecutionTime"
> required="true">
> <ww:param name="desc"><p><ww:text
> name="schedule.maxJobExecutionTime.message"/></p></ww:param>
> </ww:textfield>
> @@ -33,8 +47,8 @@
> <ww:checkbox label="%{getText
> ('schedule.enabled.label')}" name="active" value="active"
> fieldValue="true">
> <ww:param name="desc"><p><ww:text
> name="schedule.enabled.message"/></p></ww:param>
> </ww:checkbox>
> - </tbody>
> - </table>
> + </table>
> +
> <div class="functnbar3">
> <c1:submitcancel value="%{getText('save')}" cancel="%
> {getText('cancel')}"/>
> </div>
> @@ -45,4 +59,4 @@
>
> </body>
> </ww:i18n>
> -</html>
> \ No newline at end of file
> +</html>
>
Re: svn commit: r443424 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ScheduleAction.java resources/localization/Continuum.properties webapp/editSchedule.jsp
Posted by Brett Porter <br...@apache.org>.
Right you are. I was thinking in a completely different context, but
this will freak if the optional ones (which is only the last two) are
omitted. They'll need to be bounds checked.
Sorry about that.
- Brett
On 15/09/2006, at 8:33 PM, Kenney Westerhof wrote:
>
>
> Carlos Sanchez wrote:
>> Fixed the loop and reopened issue
>> On 9/14/06, Brett Porter <br...@apache.org> wrote:
>>> I was referring to the table elements in the JSP, but I'll also note
>>> that the while loop and switch below are unnecessary.
>>>
>>> second = cronEx[0];
>>> minute = cronEx[1];
>>>
>>> etc.
>>>
>
> Not entirely - if you consider the last fields of the expression
> optional then this is the cleanest
> solution. Otherwise you'd have to write an if statement for each
> assignment.
>
> I assume that right now the cronEx arrays' length is checked to
> prevent IndexOutOfBoundsExceptions?
>
> -- Kenney
>
>>> - Brett
>>>
>>> On 15/09/2006, at 9:23 AM, Brett Porter wrote:
>>>
>>> > This suffers the same limitations that were originally found on
>>> the
>>> > same patch for archiva. Are you sure this is the latest?
>>> >
>>> > On 15/09/2006, at 3:36 AM, carlos@apache.org wrote:
>>> >
>>> >> +
>>> >> + String[] cronEx = schedule.getCronExpression
>>> >> ().split( " " );
>>> >> + int i = 0;
>>> >> + while ( i < cronEx.length )
>>> >> + {
>>> >> + switch( i )
>>> >> + {
>>> >> + case 0 : second = cronEx[i]; break;
>>> >> + case 1 : minute = cronEx[i]; break;
>>> >> + case 2 : hour = cronEx[i]; break;
>>> >> + case 3 : dayOfMonth = cronEx[i]; break;
>>> >> + case 4 : month = cronEx[i]; break;
>>> >> + case 5 : dayOfWeek = cronEx[i]; break;
>>> >> + case 6 : year = cronEx[i]; break;
>>> >> + }
>>> >> + i++;
>>> >> + }
>>> >> +
>>> >>
>>>
Re: svn commit: r443424 - in
/maven/continuum/trunk/continuum-webapp/src/main:
java/org/apache/maven/continuum/web/action/ScheduleAction.java
resources/localization/Continuum.properties webapp/editSchedule.jsp
Posted by Kenney Westerhof <ke...@apache.org>.
Carlos Sanchez wrote:
> Fixed the loop and reopened issue
>
> On 9/14/06, Brett Porter <br...@apache.org> wrote:
>> I was referring to the table elements in the JSP, but I'll also note
>> that the while loop and switch below are unnecessary.
>>
>> second = cronEx[0];
>> minute = cronEx[1];
>>
>> etc.
>>
Not entirely - if you consider the last fields of the expression optional then this is the cleanest
solution. Otherwise you'd have to write an if statement for each assignment.
I assume that right now the cronEx arrays' length is checked to prevent IndexOutOfBoundsExceptions?
-- Kenney
>> - Brett
>>
>> On 15/09/2006, at 9:23 AM, Brett Porter wrote:
>>
>> > This suffers the same limitations that were originally found on the
>> > same patch for archiva. Are you sure this is the latest?
>> >
>> > On 15/09/2006, at 3:36 AM, carlos@apache.org wrote:
>> >
>> >> +
>> >> + String[] cronEx = schedule.getCronExpression
>> >> ().split( " " );
>> >> + int i = 0;
>> >> + while ( i < cronEx.length )
>> >> + {
>> >> + switch( i )
>> >> + {
>> >> + case 0 : second = cronEx[i]; break;
>> >> + case 1 : minute = cronEx[i]; break;
>> >> + case 2 : hour = cronEx[i]; break;
>> >> + case 3 : dayOfMonth = cronEx[i]; break;
>> >> + case 4 : month = cronEx[i]; break;
>> >> + case 5 : dayOfWeek = cronEx[i]; break;
>> >> + case 6 : year = cronEx[i]; break;
>> >> + }
>> >> + i++;
>> >> + }
>> >> +
>> >>
>>
>
>
Re: svn commit: r443424 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ScheduleAction.java resources/localization/Continuum.properties webapp/editSchedule.jsp
Posted by Carlos Sanchez <ca...@apache.org>.
Fixed the loop and reopened issue
On 9/14/06, Brett Porter <br...@apache.org> wrote:
> I was referring to the table elements in the JSP, but I'll also note
> that the while loop and switch below are unnecessary.
>
> second = cronEx[0];
> minute = cronEx[1];
>
> etc.
>
> - Brett
>
> On 15/09/2006, at 9:23 AM, Brett Porter wrote:
>
> > This suffers the same limitations that were originally found on the
> > same patch for archiva. Are you sure this is the latest?
> >
> > On 15/09/2006, at 3:36 AM, carlos@apache.org wrote:
> >
> >> +
> >> + String[] cronEx = schedule.getCronExpression
> >> ().split( " " );
> >> + int i = 0;
> >> + while ( i < cronEx.length )
> >> + {
> >> + switch( i )
> >> + {
> >> + case 0 : second = cronEx[i]; break;
> >> + case 1 : minute = cronEx[i]; break;
> >> + case 2 : hour = cronEx[i]; break;
> >> + case 3 : dayOfMonth = cronEx[i]; break;
> >> + case 4 : month = cronEx[i]; break;
> >> + case 5 : dayOfWeek = cronEx[i]; break;
> >> + case 6 : year = cronEx[i]; break;
> >> + }
> >> + i++;
> >> + }
> >> +
> >>
>
--
I could give you my word as a Spaniard.
No good. I've known too many Spaniards.
-- The Princess Bride
Re: svn commit: r443424 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ScheduleAction.java resources/localization/Continuum.properties webapp/editSchedule.jsp
Posted by Brett Porter <br...@apache.org>.
I was referring to the table elements in the JSP, but I'll also note
that the while loop and switch below are unnecessary.
second = cronEx[0];
minute = cronEx[1];
etc.
- Brett
On 15/09/2006, at 9:23 AM, Brett Porter wrote:
> This suffers the same limitations that were originally found on the
> same patch for archiva. Are you sure this is the latest?
>
> On 15/09/2006, at 3:36 AM, carlos@apache.org wrote:
>
>> +
>> + String[] cronEx = schedule.getCronExpression
>> ().split( " " );
>> + int i = 0;
>> + while ( i < cronEx.length )
>> + {
>> + switch( i )
>> + {
>> + case 0 : second = cronEx[i]; break;
>> + case 1 : minute = cronEx[i]; break;
>> + case 2 : hour = cronEx[i]; break;
>> + case 3 : dayOfMonth = cronEx[i]; break;
>> + case 4 : month = cronEx[i]; break;
>> + case 5 : dayOfWeek = cronEx[i]; break;
>> + case 6 : year = cronEx[i]; break;
>> + }
>> + i++;
>> + }
>> +
>>