From: <chr...@fe...> - 2007-09-17 15:00:55
|
Author: chrisg23 Date: 2007-09-17 17:00:39 +0200 (Mon, 17 Sep 2007) New Revision: 1643 Modified: aplaws/trunk/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java Log: Sourceforge patch 1783195 - IMPORTANT BUGFIX - if you use fixed length lifecycles with expiry notifications then you are probably affected by this - notifications are not created and sent if you have relied on the default end date set by the lifecycle, only if you explicitly entered a date on the publish form. To fix the timebomb of items that are due to expire without notification, there is a command line program in package uk.gov.westsussex.wsgfl.jobs called CreateMissingNotificationPhases. Package is in ccm-wsx-wsgfl-custom module in contrib area of the repository. To use this, it is best to copy the job class and the accompanying pdl file query-missing-notification-phases to your own custom application, or else install ccm-wsx-wsgfl-custom but strip away everything except those 2 files and the initialiser - removing all bits of the initialiser except the data init. Do not add ccm-wsx-wsgfl-custom to your instance as it is, at it overrides some files in the default Aplaw! s installation Modified: aplaws/trunk/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java =================================================================== --- aplaws/trunk/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java 2007-09-17 14:05:26 UTC (rev 1642) +++ aplaws/trunk/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java 2007-09-17 15:00:39 UTC (rev 1643) @@ -452,25 +452,36 @@ // Apply the new lifecycle. ContentItem pending = item.publish(cycleDef, startDate); + final Lifecycle lifecycle = pending.getLifecycle(); // XXX domlay Whoa. This must be broken for multiphase // lifecycles. if (endDate != null) { - final Lifecycle lifecycle = pending.getLifecycle(); - + // update individual phases final PhaseCollection phases = lifecycle.getPhases(); while (phases.next()) { final Phase phase = phases.getPhase(); java.util.Date thisEnd = phase.getEndDate(); + java.util.Date thisStart = phase.getStartDate(); + if (thisStart.compareTo(endDate) > 0) { + phase.setStartDate(endDate); + phase.save(); + } if (thisEnd == null || thisEnd.compareTo(endDate) > 0) { phase.setEndDate(endDate); phase.save(); } } + } + + // endOfCycle may be the original date according to lifecycle phase definitions, or endDate if that was before + // natural end of lifecycle + java.util.Date endOfCycle = lifecycle.getEndDate(); + if (endOfCycle != null) { // if advance notification is requested (!= 0) // add another phase at the start of which the user is notified @@ -487,15 +498,15 @@ if (notificationHours != null) { notificationPeriod += notificationHours.intValue(); } - + if (notificationPeriod > 0) { notificationDate = - computeNotificationDate(endDate, notificationPeriod); - + computeNotificationDate(endOfCycle, notificationPeriod); + s_log.debug("adding custom phase"); Phase expirationImminentPhase = lifecycle.addCustomPhase("expirationImminent", new Long(notificationDate.getTime()), - new Long(endDate.getTime())); + new Long(endOfCycle.getTime())); expirationImminentPhase. setListenerClassName("com.arsdigita.cms.lifecycle.NotifyLifecycleListener"); expirationImminentPhase.save(); @@ -510,7 +521,7 @@ item.save(); final Workflow workflow = m_workflow.getWorkflow(state); - try { + try { finish(workflow, item, Web.getContext().getUser()); } catch (TaskException te) { throw new FormProcessException(te); @@ -524,7 +535,7 @@ } } } - + static void finish(Workflow workflow, ContentItem item, User user) throws TaskException { if (workflow != null) { final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE); |