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