Author: knguyen
Date: Tue Sep 11 12:52:36 2007
New Revision: 18420

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18420&repname=
=3Djahia
Log:
JAHIA-2208: give the user, the choice to choose if the next publication per=
iod should occur yesterday (for period that overlaps on two days), now or o=
nly at the next full period.

Added:
    branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/enable_immediatepublication.jsp
Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources.p=
roperties
    branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_e=
n.properties
    branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_f=
r.properties
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/timebasedp=
ublishing/TimeBasedPublishingEngine.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/DayInWeekBean.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/RangeRetentionRule.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/rangerule.jsp

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResou=
rces.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/conf/java/JahiaEnginesResources.properties&rev=3D18420&rep=
name=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources.p=
roperties (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources.p=
roperties Tue Sep 11 12:52:36 2007
@@ -1145,6 +1145,9 @@
 org.jahia.engines.timebasedpublishing.days.sun =3D sun
 org.jahia.engines.timebasedpublishing.from =3D from
 org.jahia.engines.timebasedpublishing.until =3D until
+org.jahia.engines.timebasedpublishing.firstOccurence =3D first occurence
+org.jahia.engines.timebasedpublishing.allowedToStartImmediately =3D allowe=
d to start immediately
+org.jahia.engines.timebasedpublishing.onlyAtNextFullPeriod =3D only at nex=
t full publish period
 org.jahia.engines.title.label =3D Title
 org.jahia.engines.title.AddContainer =3D Add content object
 org.jahia.engines.title.ContainerListProperties =3D Property of content ob=
ject list

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResou=
rces_en.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/conf/java/JahiaEnginesResources_en.properties&rev=3D18420&=
repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_e=
n.properties (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_e=
n.properties Tue Sep 11 12:52:36 2007
@@ -1145,6 +1145,9 @@
 org.jahia.engines.timebasedpublishing.days.sun =3D sun
 org.jahia.engines.timebasedpublishing.from =3D from
 org.jahia.engines.timebasedpublishing.until =3D until
+org.jahia.engines.timebasedpublishing.firstOccurence =3D first occurence
+org.jahia.engines.timebasedpublishing.allowedToStartImmediately =3D allowe=
d to start immediately
+org.jahia.engines.timebasedpublishing.onlyAtNextFullPeriod =3D only at nex=
t full publish period
 org.jahia.engines.title.label =3D Title
 org.jahia.engines.title.AddContainer =3D Add content object
 org.jahia.engines.title.ContainerListProperties =3D Property of content ob=
ject list

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResou=
rces_fr.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/conf/java/JahiaEnginesResources_fr.properties&rev=3D18420&=
repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_f=
r.properties (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/conf/java/JahiaEnginesResources_f=
r.properties Tue Sep 11 12:52:36 2007
@@ -894,6 +894,9 @@
 org.jahia.engines.timebasedpublishing.days.sun =3D dim
 org.jahia.engines.timebasedpublishing.from =3D de
 org.jahia.engines.timebasedpublishing.until =3D jusqu'=C3=A0
+org.jahia.engines.timebasedpublishing.firstOccurence =3D premi=C3=A8re occ=
urence
+org.jahia.engines.timebasedpublishing.allowedToStartImmediately =3D peut c=
ommencer imm=C3=A9diatement
+org.jahia.engines.timebasedpublishing.onlyAtNextFullPeriod =3D d=C3=A9bute=
 seulement =C3=A0 la prochaine p=C3=A9riode compl=C3=A8te
 org.jahia.engines.title.AddContainer =3D Ajouter un objet de contenu
 org.jahia.engines.title.ContainerListProperties =3D Propri=C3=A9t=C3=A9s d=
e la liste d'objets de contenu
 org.jahia.engines.title.DeleteContainer =3D Supprimer l'objet de contenu

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/time=
basedpublishing/TimeBasedPublishingEngine.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/engines/timebasedpublishing/TimeBasedPublis=
hingEngine.java&rev=3D18420&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/timebasedp=
ublishing/TimeBasedPublishingEngine.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/timebasedp=
ublishing/TimeBasedPublishingEngine.java Tue Sep 11 12:52:36 2007
@@ -18,6 +18,7 @@
 package org.jahia.engines.timebasedpublishing;
 =

 import org.jahia.content.ObjectKey;
+import org.jahia.content.ContentObject;
 import org.jahia.engines.JahiaEngine;
 import org.jahia.engines.validation.EngineValidationHelper;
 import org.jahia.engines.validation.ValidationError;
@@ -202,6 +203,19 @@
 =

         long timeOffSet =3D 0;
         String oldRecurrenceType =3D jParams.getParameter("oldRuleType");
+
+        Boolean oldEnableImmediatePublication =3D (Boolean)subEngineMap.ge=
t(ENGINE_NAME + ".enableImmediatePublication");
+        if ( oldEnableImmediatePublication =3D=3D null ){
+            oldEnableImmediatePublication =3D Boolean.TRUE;
+        }
+        String enableImmediatePublicationStr =3D jParams.getParameter("ena=
bleImmediatePublication");
+        boolean enableImmediatePublication =3D true;
+        if ( enableImmediatePublicationStr !=3D null ){
+            enableImmediatePublication =3D "true".equals(enableImmediatePu=
blicationStr);
+            subEngineMap.put(ENGINE_NAME + ".enableImmediatePublication",
+                    new Boolean(enableImmediatePublication));
+        }
+
         if ( RetentionRule.RULE_START_AND_END_DATE.equals(oldRecurrenceTyp=
e) ){
             CalendarHandler calHandler =3D null;
             calHandler =3D (CalendarHandler) subEngineMap.get(ENGINE_NAME =
+ ".fromDateCalHandler");
@@ -236,7 +250,7 @@
             if ( l =3D=3D null ){
                 l =3D new Long(0);
             }
-            timeOffSet -=3D 2*l.longValue();
+            timeOffSet -=3D l.longValue();
 =

             // update daily recurrence parameters
             String value =3D jParams.getParameter("fromHours");
@@ -263,7 +277,7 @@
             if ( l =3D=3D null ){
                 l =3D new Long(0);
             }
-            timeOffSet -=3D 2*l.longValue();
+            timeOffSet -=3D l.longValue();
 =

             // update weekly recurrence parameters
             Iterator it =3D rule.getDaysInWeek().iterator();
@@ -282,35 +296,121 @@
         }
 =

         // compute next publish and next unpublish date
-        updateNextPublishAndExpireDate(rule,objectKey,timeOffSet);
+        updateNextPublishAndExpireDate(rule,objectKey,timeOffSet,enableImm=
ediatePublication,
+                oldEnableImmediatePublication.booleanValue() !=3D enableIm=
mediatePublication);
 =

     }
 =

-    private void updateNextPublishAndExpireDate(RangeRetentionRule rule,Ob=
jectKey objectKey, long timeOffSet)
+    private void updateNextPublishAndExpireDate(RangeRetentionRule rule,Ob=
jectKey objectKey, long timeOffSet,
+                                                boolean enableImmediatePub=
lication,
+                                                boolean enableImmediatePub=
licationHasChange)
     throws JahiaException {
         final RangeRetentionRule oldRule =3D (RangeRetentionRule) oldRules=
.get(objectKey.toString());
-        if ( isSame(oldRule,rule) ){
+        if ( isSame(oldRule,rule) && !enableImmediatePublicationHasChange =
){
             return;
         }
-        Calendar cal =3D Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+        Calendar cal =3D Calendar.getInstance(TimeZone.getDefault());
+        int serverDefaultOffSet =3D cal.getTimeZone().getRawOffset();
+        int serverDsts =3D cal.getTimeZone().getDSTSavings();
+        int timeOffSetInt =3D 0;
+        if ( timeOffSet !=3D 0 ){
+            Long l =3D new Long((timeOffSet+serverDefaultOffSet+serverDsts=
)/(60*60*1000));
+            timeOffSetInt =3D -l.intValue();
+        }
         if ( RetentionRule.RULE_DAILY.equals(rule.getRuleType()) ){
+            int fromTime =3D rule.getDailyFromHours() * 60 + rule.getDaily=
FromMinutes();
+            int toTime =3D rule.getDailyToHours() * 60 + rule.getDailyToMi=
nutes();
+            int currentTime =3D cal.get(Calendar.HOUR_OF_DAY) + timeOffSet=
Int;
+            if ( currentTime < 0 ){
+                currentTime =3D 24-currentTime;
+            }
+            currentTime =3D currentTime * 60  + cal.get(Calendar.MINUTE);
+            boolean inPeriod =3D (fromTime<toTime && fromTime<=3DcurrentTi=
me && currentTime<=3DtoTime)
+                    || (fromTime>toTime && (currentTime>=3DfromTime || cur=
rentTime<=3DtoTime) );
             cal.set(Calendar.SECOND,0);
             cal.set(Calendar.MILLISECOND,0);
             cal.set(Calendar.HOUR_OF_DAY,rule.getDailyFromHours());
             cal.set(Calendar.MINUTE,rule.getDailyFromMinutes());
+            if ( rule.getDailyFromHours() =3D=3D rule.getDailyToHours() ){
+                if ( rule.getDailyToMinutes()<rule.getDailyFromMinutes() ){
+                    if ( inPeriod ){
+                        if ( enableImmediatePublication ){
+                            cal.setTimeInMillis(cal.getTimeInMillis()-8640=
0000);
+                        } else if ( fromTime<=3DcurrentTime ) {
+                            cal.setTimeInMillis(cal.getTimeInMillis()+8640=
0000);
+                        }
+                    }
+                } else {
+                    if ( inPeriod ){
+                        if ( !enableImmediatePublication ){
+                            cal.setTimeInMillis(cal.getTimeInMillis()+8640=
0000);
+                        }
+                    }
+                }
+            } else if ( rule.getDailyFromHours() > rule.getDailyToHours() =
){
+                if ( inPeriod ){
+                    if ( enableImmediatePublication ){
+                        cal.setTimeInMillis(cal.getTimeInMillis()-86400000=
);
+                    } else if ( fromTime<=3DcurrentTime ) {
+                        cal.setTimeInMillis(cal.getTimeInMillis()+86400000=
);
+                    }
+                }
+            } else {
+                if ( inPeriod ){
+                    if ( !enableImmediatePublication ){
+                        cal.setTimeInMillis(cal.getTimeInMillis()+86400000=
);
+                    }
+                }
+            }
             rule.setValidFromDate(new Long(cal.getTimeInMillis()+timeOffSe=
t));
+            cal =3D Calendar.getInstance(TimeZone.getDefault());
+            cal.set(Calendar.SECOND,0);
+            cal.set(Calendar.MILLISECOND,0);
             cal.set(Calendar.HOUR_OF_DAY,rule.getDailyToHours());
             cal.set(Calendar.MINUTE,rule.getDailyToMinutes());
             if ( rule.getDailyFromHours() =3D=3D rule.getDailyToHours() ){
                 if ( rule.getDailyToMinutes()<rule.getDailyFromMinutes() ){
-                    cal.setTimeInMillis(cal.getTimeInMillis()+86400000);
+                    if ( inPeriod ){
+                        if ( !enableImmediatePublication ){
+                            if (fromTime<=3DcurrentTime){
+                                cal.setTimeInMillis(cal.getTimeInMillis()+=
86400000*2);
+                            } else {
+                                cal.setTimeInMillis(cal.getTimeInMillis()+=
86400000);
+                            }
+                        }
+                    } else {
+                        cal.setTimeInMillis(cal.getTimeInMillis()+86400000=
);
+                    }
+                } else {
+                    if ( inPeriod ){
+                        if ( !enableImmediatePublication ){
+                            cal.setTimeInMillis(cal.getTimeInMillis()+8640=
0000);
+                        }
+                    }
                 }
             } else if ( rule.getDailyFromHours() > rule.getDailyToHours() =
){
-                cal.setTimeInMillis(cal.getTimeInMillis()+86400000);
+                if ( inPeriod ){
+                    if ( !enableImmediatePublication ){
+                        if (fromTime<=3DcurrentTime){
+                            cal.setTimeInMillis(cal.getTimeInMillis()+8640=
0000*2);
+                        } else {
+                            cal.setTimeInMillis(cal.getTimeInMillis()+8640=
0000);
+                        }
+                    }
+                } else {
+                    cal.setTimeInMillis(cal.getTimeInMillis()+86400000);
+                }
+            } else {
+                if ( inPeriod ){
+                    if ( !enableImmediatePublication ){
+                        cal.setTimeInMillis(cal.getTimeInMillis()+86400000=
);
+                    }
+                }
             }
             rule.setValidToDate(new Long(cal.getTimeInMillis()+timeOffSet)=
);
         } else if ( RetentionRule.RULE_XDAYINWEEK.equals(rule.getRuleType(=
)) ){
-            DayInWeekBean.computeRuleNextEventDate(rule,cal.getTimeInMilli=
s(),cal,timeOffSet,false);                        =

+            DayInWeekBean.computeRuleNextEventDate(rule,0,cal,timeOffSet,
+                    enableImmediatePublication);
         }
     }
 =

@@ -323,6 +423,19 @@
 =

         final RangeRetentionRule oldRule =3D (RangeRetentionRule) oldRules=
.get(objectKey.toString());
 =

+        try {
+            Boolean enableImmediatePublication =3D (Boolean)subEngineMap.g=
et(ENGINE_NAME + ".enableImmediatePublication");
+            ContentObject contentObject =3D ContentObject.getContentObject=
Instance(objectKey);
+            String val =3D contentObject
+                    .getProperty(TimeBasedPublishingEngine.ENGINE_NAME+".e=
nableImmediatePublication");
+            boolean oldValue =3D ("true".equals(val) || val=3D=3Dnull);
+            if ( enableImmediatePublication.booleanValue() !=3D oldValue ){
+                contentObject.setProperty(TimeBasedPublishingEngine.ENGINE=
_NAME+".enableImmediatePublication",
+                        enableImmediatePublication.toString());
+            }
+        } catch ( Throwable t ){
+        }
+
         if (currentRuleDef !=3D null) {
             final RangeRetentionRule rule =3D (RangeRetentionRule) subEngi=
neMap.get(ENGINE_NAME + ".currentRule");
             logger.debug("old: " + oldRule);
@@ -376,6 +489,15 @@
             subEngineMap.put(ENGINE_NAME + ".toDateCalHandler", getCalHand=
ler(rule, "toDate", jParams));
 =

             subEngineMap.put(ENGINE_NAME + ".ruleDefs", tbpServ.getRetenti=
onRuleDefs());
+
+            try {
+                ContentObject contentObject =3D ContentObject.getContentOb=
jectInstance(objectKey);
+                String val =3D contentObject
+                        .getProperty(TimeBasedPublishingEngine.ENGINE_NAME=
+".enableImmediatePublication");
+                boolean enableImmediatePublication =3D ("true".equals(val)=
 || val=3D=3Dnull);
+                subEngineMap.put(ENGINE_NAME + ".enableImmediatePublicatio=
n", new Boolean(enableImmediatePublication));
+            } catch ( Throwable t ){
+            }
         }
         return subEngineMap;
     }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/tim=
ebasedpublishing/DayInWeekBean.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/timebasedpublishing/DayInWeekBean.=
java&rev=3D18420&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/DayInWeekBean.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/DayInWeekBean.java Tue Sep 11 12:52:36 2007
@@ -182,92 +182,151 @@
     }
 =

     public static void computeRuleNextEventDate(RangeRetentionRule newRule,
-                                                long startDate, Calendar c=
al, long timeOffSet, boolean skipToday){
+                                                long startDate, Calendar c=
al, long timeOffSet,
+                                                boolean enableImmediatePub=
lication){
         DayInWeekBean dayBean =3D null;
         long nextPublishTime =3D 0;
         long nextExpireTime =3D 0;
         Iterator it =3D newRule.getDaysInWeek().iterator();
-        List nextPublishDates =3D new ArrayList();
-        List nextExpireDates =3D new ArrayList();
+        SortedSet nextPublishDates =3D new TreeSet();
+        SortedSet nextExpireDates =3D new TreeSet();
         while ( it.hasNext() ){
             dayBean =3D (DayInWeekBean)it.next();
             if ( dayBean.isSelected() ){
-                computeNextEventsTime(cal,dayBean,nextPublishDates,nextExp=
ireDates,timeOffSet,skipToday);
+                computeNextEventsTime(cal,dayBean,nextPublishDates,nextExp=
ireDates,timeOffSet);
             }
         }
-        // get the next nearest expire date
+        // get the next nearest publish date
         Date date =3D null;
-        long now =3D 0;
-        Calendar tmpCal =3D (Calendar)cal.clone();
-        it =3D nextExpireDates.iterator();
+        it =3D nextPublishDates.iterator();
+        if ( !enableImmediatePublication ){
+            List inversedDateList =3D new ArrayList();
+            while ( it.hasNext() ){
+                inversedDateList.add(0,it.next());
+            }
+            it =3D inversedDateList.iterator();
+        }
+        long now =3D cal.getTimeInMillis()+timeOffSet;
         if ( it.hasNext() ){
-            now =3D cal.getTimeInMillis();
             while ( it.hasNext() ){
                 date =3D (Date)it.next();
-                tmpCal.setTimeInMillis(date.getTime());
-                if ( date.getTime()< nextExpireTime || nextExpireTime=3D=
=3D0 ){
-                    nextExpireTime =3D date.getTime();
+                if (date.getTime()>startDate ){
+                    if ( nextPublishTime =3D=3D 0 ){
+                        nextPublishTime =3D date.getTime();
+                    } else if ( enableImmediatePublication && date.getTime=
()<now && date.getTime()>nextPublishTime ){
+                        nextPublishTime =3D date.getTime();
+                    } else if ( !enableImmediatePublication && date.getTim=
e()>now && date.getTime()<nextPublishTime ){
+                        nextPublishTime =3D date.getTime();
+                    }
                 }
             }
-            newRule.setValidToDate(new Long(nextExpireTime));
+            newRule.setValidFromDate(new Long(nextPublishTime));
         } else {
-            newRule.setValidToDate(new Long(0));
+            newRule.setValidFromDate(new Long(0));
         }
-        // get the next nearest publish date
-        it =3D nextPublishDates.iterator();
-        if ( it.hasNext() ){
-            now =3D cal.getTimeInMillis();
+
+        // get the next nearest expire date
+        it =3D nextExpireDates.iterator();
+        if ( nextPublishTime >0 && it.hasNext() ){
             while ( it.hasNext() ){
                 date =3D (Date)it.next();
-                tmpCal.setTimeInMillis(date.getTime());
-                if (date.getTime()< nextPublishTime || nextPublishTime=3D=
=3D0 ){
-                    nextPublishTime =3D date.getTime();
+                if ( date.getTime()>nextPublishTime ){
+                    nextExpireTime =3D date.getTime();
+                    break;
                 }
             }
-            newRule.setValidFromDate(new Long(nextPublishTime));
+            newRule.setValidToDate(new Long(nextExpireTime));
         } else {
-            newRule.setValidFromDate(new Long(0));
+            newRule.setValidToDate(new Long(0));
         }
     }
 =

     private static void computeNextEventsTime(Calendar nowCalendar,
                                        DayInWeekBean dayBean,
-                                       List nextPublishDates,
-                                       List nextExpireDates,
-                                       long timeOffSet,
-                                       boolean skipToday){
+                                       Set nextPublishDates,
+                                       Set nextExpireDates,
+                                       long timeOffSet){
+
         if ( ((dayBean.getFromHours()+dayBean.getFromMinutes())=3D=3D0)
               && ((dayBean.getToHours()+dayBean.getToMinutes())=3D=3D0) ) {
             return;
         }
-        Calendar cal =3D (Calendar)nowCalendar.clone();
+
+        Calendar nowCal =3D (Calendar)nowCalendar.clone();
         int todayDayInWeek =3D nowCalendar.get(Calendar.DAY_OF_WEEK);
         int dayInWeek =3D DayInWeekBean.getJavaCalendarDayOfWeek(dayBean);
-        cal.set(Calendar.DAY_OF_WEEK,dayInWeek);
-        if ( dayInWeek<todayDayInWeek || (skipToday && dayInWeek=3D=3Dtoda=
yDayInWeek ) ){
-            cal.add(Calendar.WEEK_OF_MONTH,1); // add one week
-        }
-        cal.set(Calendar.HOUR_OF_DAY,dayBean.getFromHours());
-        cal.set(Calendar.MINUTE,dayBean.getFromMinutes());
-        cal.setTimeInMillis(cal.getTimeInMillis()+timeOffSet);
-        nextPublishDates.add(cal.getTime());
-
-        cal =3D (Calendar)nowCalendar.clone();
-        cal.set(Calendar.DAY_OF_WEEK,dayInWeek);
-        if ( dayInWeek<todayDayInWeek || (skipToday && dayInWeek=3D=3Dtoda=
yDayInWeek) ){
-            cal.add(Calendar.WEEK_OF_MONTH,1); // add one week
-        }
-        cal.set(Calendar.HOUR_OF_DAY,dayBean.getToHours());
-        cal.set(Calendar.MINUTE,dayBean.getToMinutes());
-        if ( dayBean.getFromHours() =3D=3D dayBean.getToHours() ){
-            if ( dayBean.getToMinutes()<dayBean.getFromMinutes() ){
-                cal.setTimeInMillis(cal.getTimeInMillis()+86400000);
+        nowCal.set(Calendar.DAY_OF_WEEK,dayInWeek);
+        if ( dayInWeek<=3DtodayDayInWeek ){
+            nowCal.add(Calendar.WEEK_OF_MONTH,1); // add one week
+        }
+        nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getFromHours());
+        nowCal.set(Calendar.MINUTE,dayBean.getFromMinutes());
+        nowCal.set(Calendar.SECOND,0);
+        nowCal.set(Calendar.MILLISECOND,0);
+        nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet);
+        nextPublishDates.add(nowCal.getTime());
+
+        nowCal =3D (Calendar)nowCalendar.clone();
+        nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getToHours());
+        nowCal.set(Calendar.MINUTE,dayBean.getToMinutes());
+        nowCal.set(Calendar.SECOND,0);
+        nowCal.set(Calendar.MILLISECOND,0);
+        nowCal.set(Calendar.DAY_OF_WEEK,dayInWeek);
+        if ( dayInWeek<=3DtodayDayInWeek ){
+            nowCal.add(Calendar.WEEK_OF_MONTH,1); // add one week
+        }
+        if ( (dayBean.getFromHours() =3D=3D dayBean.getToHours() &&
+             dayBean.getToMinutes()< dayBean.getFromMinutes())
+                || dayBean.getFromHours()>dayBean.getToHours() ){
+            nowCal.setTimeInMillis(nowCal.getTimeInMillis()+86400000);
+        }
+        nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet);
+        nextExpireDates.add(nowCal.getTime());
+
+
+        int fromTime =3D dayBean.getFromHours() * 60 + dayBean.getFromMinu=
tes();
+        int toTime =3D dayBean.getToHours() * 60 + dayBean.getToMinutes();
+
+        nowCal =3D (Calendar)nowCalendar.clone();
+        if ( todayDayInWeek =3D=3D dayInWeek ){
+            nowCal.set(Calendar.DAY_OF_WEEK,dayInWeek);
+            nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getFromHours());
+            nowCal.set(Calendar.MINUTE,dayBean.getFromMinutes());
+            nowCal.set(Calendar.SECOND,0);
+            nowCal.set(Calendar.MILLISECOND,0);
+            nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet);
+            nextPublishDates.add(nowCal.getTime());
+            nowCal =3D (Calendar)nowCalendar.clone();
+            nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getToHours());
+            nowCal.set(Calendar.MINUTE,dayBean.getToMinutes());
+            nowCal.set(Calendar.SECOND,0);
+            nowCal.set(Calendar.MILLISECOND,0);
+            if ( (dayBean.getFromHours() =3D=3D dayBean.getToHours() &&
+                 dayBean.getToMinutes()< dayBean.getFromMinutes())
+                    || dayBean.getFromHours()>dayBean.getToHours() ){
+                nowCal.setTimeInMillis(nowCal.getTimeInMillis()+86400000);
+            }
+            nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet);
+            nextExpireDates.add(nowCal.getTime());
+        } else if ( (todayDayInWeek - dayInWeek =3D=3D 1)
+                || (todayDayInWeek =3D=3D Calendar.SUNDAY && dayInWeek =3D=
=3D Calendar.SATURDAY) ){
+            if ( fromTime>toTime ){
+                // add yesterday
+                nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getFromHours());
+                nowCal.set(Calendar.MINUTE,dayBean.getFromMinutes());
+                nowCal.set(Calendar.SECOND,0);
+                nowCal.set(Calendar.MILLISECOND,0);
+                nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet=
-86400000);
+                nextPublishDates.add(nowCal.getTime());
+                nowCal =3D (Calendar)nowCalendar.clone();
+                nowCal.set(Calendar.HOUR_OF_DAY,dayBean.getToHours());
+                nowCal.set(Calendar.MINUTE,dayBean.getToMinutes());
+                nowCal.set(Calendar.SECOND,0);
+                nowCal.set(Calendar.MILLISECOND,0);
+                nowCal.setTimeInMillis(nowCal.getTimeInMillis()+timeOffSet=
);
+                nextExpireDates.add(nowCal.getTime());
             }
-        } else if ( dayBean.getFromHours() > dayBean.getToHours() ){
-            cal.setTimeInMillis(cal.getTimeInMillis()+86400000);
         }
-        cal.setTimeInMillis(cal.getTimeInMillis()+timeOffSet);
-        nextExpireDates.add(cal.getTime());
     }
 =

     public boolean equals(Object obj) {

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/tim=
ebasedpublishing/RangeRetentionRule.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/timebasedpublishing/RangeRetention=
Rule.java&rev=3D18420&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/RangeRetentionRule.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/timebased=
publishing/RangeRetentionRule.java Tue Sep 11 12:52:36 2007
@@ -253,7 +253,6 @@
      *
      * @param context
      * @return the next fire time. 0 if no fire time
-     *
      * @throws Exception
      */
     public long scheduleNextJob(ProcessingContext context) throws Exceptio=
n {
@@ -280,7 +279,7 @@
             timeShift =3D 86400000;
             setValidToDate(new Long(cal.getTimeInMillis()+offSet+timeShift=
));
         } else if ( RetentionRule.RULE_XDAYINWEEK.equals(getRuleType()) ){
-            DayInWeekBean.computeRuleNextEventDate(this,cal.getTimeInMilli=
s(),cal,offSet,true);
+            DayInWeekBean.computeRuleNextEventDate(this,cal.getTimeInMilli=
s(),cal,offSet,false);
         }
         boolean canSchedule =3D  postScheduleNextJob();
         if ( !canSchedule ){

Added: branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timeb=
asedpublishing/enable_immediatepublication.jsp
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebasedpublishing/enable=
_immediatepublication.jsp&rev=3D18420&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/enable_immediatepublication.jsp (added)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/enable_immediatepublication.jsp Tue Sep 11 12:52:36 2007
@@ -0,0 +1,31 @@
+<%--
+Copyright 2002-2006 Jahia Ltd
+
+Licensed under the JAHIA SUSTAINABLE SOFTWARE LICENSE (JSSL), =

+Version 1.0 (the "License"), or (at your option) any later version; you ma=
y =

+not use this file except in compliance with the License. You should have =

+received a copy of the License along with this program; if not, you may ob=
tain =

+a copy of the License at =

+
+ http://www.jahia.org/license/
+
+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.
+--%>
+<%@ page language=3D"java"%>
+<%@ page import=3D"java.util.*" %>
+<%@ taglib uri=3D"JahiaLib" prefix=3D"jahia" %>
+<%
+  Boolean enableImmediatePublication =3D (Boolean)request.getAttribute("en=
ableImmediatePublication");
+  if ( enableImmediatePublication =3D=3D null ){
+    enableImmediatePublication =3D Boolean.TRUE;
+  }
+%>
+<input class=3D"input" type=3D"radio" name=3D"enableImmediatePublication" =
value=3D"true" <%if(enableImmediatePublication.booleanValue()){%>checked<%}=
%>>
+<jahia:engineResourceBundle resourceName=3D"org.jahia.engines.timebasedpub=
lishing.allowedToStartImmediately" defaultValue=3D"allowed to start immedia=
tely"/><br/>
+<input class=3D"input" type=3D"radio" name=3D"enableImmediatePublication" =
value=3D"false" <%if(!enableImmediatePublication.booleanValue()){%>checked<=
%}%>>
+<jahia:engineResourceBundle resourceName=3D"org.jahia.engines.timebasedpub=
lishing.onlyAtNextFullPeriod" defaultValue=3D"only at next full publish per=
iod"/>
+

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/ti=
mebasedpublishing/rangerule.jsp
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/webapp/jsp/jahia/engines/timebasedpublishing/rangerule.jsp=
&rev=3D18420&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/rangerule.jsp (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/engines/timebase=
dpublishing/rangerule.jsp Tue Sep 11 12:52:36 2007
@@ -32,6 +32,9 @@
             get(TimeBasedPublishingEngine.ENGINE_NAME + ".toDateCalHandler=
");
     final BaseRetentionRule currentRule =3D (BaseRetentionRule) subEngineM=
ap.
             get(TimeBasedPublishingEngine.ENGINE_NAME + ".currentRule");
+    Boolean enableImmediatePublication =3D (Boolean) subEngineMap.
+            get(TimeBasedPublishingEngine.ENGINE_NAME + ".enableImmediateP=
ublication");       =

+    request.setAttribute("enableImmediatePublication", enableImmediatePubl=
ication);
     if (currentRule !=3D null) {
         inherited =3D currentRule.getInherited().booleanValue();
     }
@@ -156,6 +159,15 @@
             request.setAttribute("minutes",String.valueOf(currentRule.getD=
ailyToMinutes()));
           %>
           <jsp:include page=3D"hours_input.jsp" flush=3D"true" />
+          <br/>
+          <br/>
+        </td>
+    </tr>
+    <tr class=3D"ruleSettings">
+        <td class=3D"t1"><jahia:engineResourceBundle
+                resourceName=3D"org.jahia.engines.timebasedpublishing.firs=
tOccurence" defaultValue=3D"first occurence"/></td>
+        <td class=3D"t22">
+          <jsp:include page=3D"enable_immediatepublication.jsp" flush=3D"t=
rue"/>
         </td>
     </tr>
     <% } else if (RetentionRule.RULE_XDAYINWEEK.equals(currentRule.getRule=
Type())) {%>
@@ -203,11 +215,19 @@
               request.setAttribute("hiddenCalendar", Boolean.TRUE);
           %>
           <jsp:include page=3D"calendar.jsp" flush=3D"true"/>
+          <br/>
           <%
             request.removeAttribute("hiddenCalendar");
           %>
         </td>
     </tr>
+    <tr class=3D"ruleSettings">
+        <td class=3D"t1"><jahia:engineResourceBundle
+                resourceName=3D"org.jahia.engines.timebasedpublishing.firs=
tOccurence" defaultValue=3D"first occurence"/></td>
+        <td class=3D"t22">
+          <jsp:include page=3D"enable_immediatepublication.jsp" flush=3D"t=
rue"/>
+        </td>
+    </tr>
     <% } %>
 </table>
 =


_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to