001/* 
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.  
018 */
019package org.apache.wiki.workflow;
020
021import org.apache.wiki.api.exceptions.WikiException;
022
023import java.io.Serializable;
024import java.security.Principal;
025import java.util.Map;
026
027/**
028 * Decision subclass used for notifications that includes only one available Outcome: {@link Outcome#DECISION_ACKNOWLEDGE}. The Decision is
029 * not reassignable, and the default Outcome is {@link Outcome#DECISION_ACKNOWLEDGE}.
030 * 
031 * @since 2.5
032 */
033public final class SimpleNotification extends Decision {
034
035    private static final long serialVersionUID = -3392947495169819527L;
036
037    /**
038     * Constructs a new SimpleNotification object with a supplied message key, associated Workflow, and named actor who must acknowledge
039     * the message. The notification is placed in the Principal's list of queued Decisions. Because the only available Outcome is
040     * {@link Outcome#DECISION_ACKNOWLEDGE}, the actor can only acknowledge the message.
041     * 
042     * @param workflowId the parent workflow id to set
043     * @param workflowContext the parent workflow context to set
044     * @param messageKey the message key
045     * @param actor the Principal who will acknowledge the message
046     */
047    public SimpleNotification( final int workflowId, final Map< String, Serializable > workflowContext, final String messageKey, final Principal actor ) {
048        super( workflowId, workflowContext, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE );
049    }
050    
051    /**
052     * Convenience method that simply calls {@link #decide(Outcome)} with the value {@link Outcome#DECISION_ACKNOWLEDGE}.
053     *
054     * @throws WikiException never
055     */
056    public void acknowledge() throws WikiException {
057        this.decide( Outcome.DECISION_ACKNOWLEDGE  );
058    }
059
060    /**
061     * Notifications cannot be re-assigned, so this method always returns <code>false</code>.
062     *
063     * @return <code>false</code> always.
064     */
065    public boolean isReassignable() {
066        return false;
067    }
068
069}