001 /* 002 * Copyright 2007-2008 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kcb.deliverer.impl; 017 018 import java.util.HashMap; 019 import java.util.LinkedHashMap; 020 import java.util.Map; 021 022 import org.kuali.rice.kcb.bo.MessageDelivery; 023 import org.kuali.rice.kcb.deliverer.MessageDeliverer; 024 import org.kuali.rice.kcb.exception.ErrorList; 025 import org.kuali.rice.kcb.exception.MessageDeliveryException; 026 import org.kuali.rice.kcb.exception.MessageDismissalException; 027 028 /** 029 * A mock message deliverer that does nothing 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 * 033 */ 034 public class MockMessageDeliverer implements MessageDeliverer { 035 /** 036 * Map of deliveries 037 */ 038 private final Map<Long, MessageDelivery> deliveries = new HashMap<Long, MessageDelivery>(); 039 040 /** 041 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#deliver(org.kuali.rice.kcb.bo.MessageDelivery) 042 */ 043 public void deliver(MessageDelivery messageDelivery) throws MessageDeliveryException { 044 deliveries.put(messageDelivery.getId(), messageDelivery); 045 } 046 047 /** 048 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#dismiss(org.kuali.rice.kcb.bo.MessageDelivery, java.lang.String, java.lang.String) 049 */ 050 public void dismiss(MessageDelivery messageDelivery, String user, String cause) throws MessageDismissalException { 051 deliveries.remove(messageDelivery.getId()); 052 053 } 054 055 /** 056 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#getDescription() 057 */ 058 public String getDescription() { 059 return getName(); 060 } 061 062 /** 063 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#getName() 064 */ 065 public String getName() { 066 return "Mock"; 067 } 068 069 /** 070 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#getPreferenceKeys() 071 */ 072 public LinkedHashMap<String, String> getPreferenceKeys() { 073 // none for now 074 return new LinkedHashMap<String, String>(); 075 } 076 077 /** 078 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#getTitle() 079 */ 080 public String getTitle() { 081 return getName(); 082 } 083 084 /** 085 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap) 086 */ 087 public void validatePreferenceValues(HashMap prefs) throws ErrorList { 088 // no validation for now 089 } 090 }