Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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.
 
 package org.kuali.rice.ken.service.impl;
 
 
 import java.util.List;
Auto removes expired message deliveries.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
     private GenericDao businessObjectDao;
Constructs a NotificationMessageDeliveryDispatchServiceImpl instance.

Parameters:
businessObjectDao
txManager
executor
messageDeliveryRegistryService
 
 	    ExecutorService executorNotificationMessageDeliveryService messageDeliveryService) {
         super(txManagerexecutor);
         this. = messageDeliveryService;
         this. = businessObjectDao;
     }

    
 
     @Override
     }

    
 
     @Override
     protected Collection<StringprocessWorkItems(Collection<NotificationMessageDeliverymessageDeliveries) {
         NotificationMessageDelivery firstMessageDelivery = messageDeliveries.iterator().next();
 
         KEWActionListMessageDeliverer deliverer = new KEWActionListMessageDeliverer();
         Collection<Stringsuccesses = new ArrayList<String>();
         for (NotificationMessageDelivery deliverymessageDeliveries) {
             successes.addAll(autoRemove(delivererdelivery));
         }
         return successes;
     }

    
Auto-removes a single message delivery

Parameters:
messageDeliverer the message deliverer
messageDelivery the message delivery to auto-remove
Returns:
collection of strings indicating successful auto-removals
 
     protected Collection<StringautoRemove(NotificationMessageDeliverer messageDelivererNotificationMessageDelivery messageDelivery) {
         List<Stringsuccesses = new ArrayList<String>(1);
 
         // we have our message deliverer, so tell it to auto remove the message
         try {
             messageDeliverer.autoRemoveMessageDelivery(messageDelivery);
             .debug("Auto-removal of message delivery '" + messageDelivery.getId() + "' for notification '" + messageDelivery.getNotification().getId() + "' was successful.");
             successes.add("Auto-removal of message delivery '" + messageDelivery.getId() + "' for notification '" + messageDelivery.getNotification().getId() + "' was successful.");
         } catch (NotificationAutoRemoveException nmde) {
             .error("Error auto-removing message " + messageDelivery);
             throw new RuntimeException(nmde);
         }
         
         // unlock item
        // now update the status of the delivery message instance to AUTO_REMOVED and persist
        markAutoRemoved(messageDelivery);
        return successes;
    }

    
Marks a MessageDelivery as having been auto-removed, and unlocks it

Parameters:
messageDelivery the messageDelivery instance to mark
    protected void markAutoRemoved(NotificationMessageDelivery messageDelivery) {
        // mark as unlocked
        messageDelivery.setLockedDateValue(null);
        .save(messageDelivery);
    }

    
    @Override
    protected void unlockWorkItem(NotificationMessageDelivery delivery) {
    }

    
This implementation looks up all UNDELIVERED/DELIVERED message deliveries with an autoRemoveDateTime <= current date time and then iterates over each to call the appropriate functions to do the "auto-removal" by "canceling" each associated notification workflow document.

See also:
org.kuali.rice.ken.service.NotificationMessageDeliveryDispatchService#processAutoRemovalOfDeliveredNotificationMessageDeliveries()
        .debug("[" + new Timestamp(System.currentTimeMillis()).toString() + "] STARTING NOTIFICATION AUTO-REMOVAL PROCESSING");
        ProcessingResult result = run();
        
        .debug("[" + new Timestamp(System.currentTimeMillis()).toString() + "] FINISHED NOTIFICATION AUTO-REMOVAL PROCESSING - Successes = " + result.getSuccesses().size() + ", Failures = " + result.getFailures().size());
        return result;
    }
New to GrepCode? Check out our FAQ X