001    /**
002     * Copyright 2005-2012 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.api.service;
017    
018    import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
019    import org.kuali.rice.kcb.api.message.MessageDTO;
020    import org.kuali.rice.kcb.api.exception.MessageDeliveryException;
021    import org.kuali.rice.kcb.api.exception.MessageDismissalException;
022    
023    /**
024     * The KCB MessagingService provides an API to deliver messages
025     * to arbitrary multiple endpoints. 
026     * 
027     * @author Kuali Rice Team (rice.collab@kuali.org)
028     */
029    public interface MessagingService {
030        /**
031         * Delivers a message
032         * 
033         * @param message message to deliver
034         * @return identifier for the message
035         * @throws MessageDeliveryException if unable to deliver message.
036         * @throws RiceIllegalArgumentException if the message is null.
037         */
038        public Long deliver(MessageDTO message) throws MessageDeliveryException, RiceIllegalArgumentException;
039        /**
040         * Removes a specific message and all deliveries
041         * 
042         * @param messageId id of the message to remove
043         * @param user the user under which the action was taken
044         * @param cause the cause or action taken to remove the message
045         * @throws MessageDismissalException if no message for the given messageId is found.
046         * @throws RiceIllegalArgumentException if user, cause is null.
047         */
048        public void remove(long messageId, String user, String cause) throws MessageDismissalException, RiceIllegalArgumentException;
049        
050        /**
051         * Removes a specific message and all deliveries.  Does not throw an exception if no message with the origin
052         * id is found.
053         * 
054         * @param originId origin id of the message to remove
055         * @param user the user under which the action was taken
056         * @param cause the cause or action taken to remove the message
057         * @return Long the message id of the message removed, if any
058         * @throws MessageDismissalException if no message for the given messageId is found.
059         * @throws RiceIllegalArgumentException if originId is null
060         */
061        public Long removeByOriginId(String originId, String user, String cause) throws MessageDismissalException, RiceIllegalArgumentException;
062    }