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.core.Context;
022import org.apache.wiki.api.exceptions.WikiException;
023
024import java.io.Serializable;
025import java.security.Principal;
026import java.util.Map;
027
028/**
029 * Decision subclass used for notifications that includes only one available Outcome: {@link Outcome#DECISION_ACKNOWLEDGE}. The Decision is
030 * not reassignable, and the default Outcome is {@link Outcome#DECISION_ACKNOWLEDGE}.
031 * 
032 * @since 2.5
033 */
034public final class SimpleNotification extends Decision {
035
036    private static final long serialVersionUID = -3392947495169819527L;
037
038    /**
039     * Constructs a new SimpleNotification object with a supplied message key, associated Workflow, and named actor who must acknowledge
040     * the message. The notification is placed in the Principal's list of queued Decisions. Because the only available Outcome is
041     * {@link Outcome#DECISION_ACKNOWLEDGE}, the actor can only acknowledge the message.
042     * 
043     * @param workflowId the parent workflow id to set
044     * @param workflowContext the parent workflow context to set
045     * @param messageKey the message key
046     * @param actor the Principal who will acknowledge the message
047     */
048    public SimpleNotification( final int workflowId, final Map< String, Serializable > workflowContext, final String messageKey, final Principal actor ) {
049        super( workflowId, workflowContext, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE );
050    }
051    
052    /**
053     * Convenience method that simply calls {@link #decide(Outcome, Context)} with the value {@link Outcome#DECISION_ACKNOWLEDGE}.
054     *
055     * @throws WikiException never
056     */
057    public void acknowledge( final Context context ) throws WikiException {
058        this.decide( Outcome.DECISION_ACKNOWLEDGE, context  );
059    }
060
061    /**
062     * Notifications cannot be re-assigned, so this method always returns <code>false</code>.
063     *
064     * @return <code>false</code> always.
065     */
066    public boolean isReassignable() {
067        return false;
068    }
069
070}