//# 0 errors, 105 messages
//#
/*
    //#markapprovedwhenauthenticatedlistener.java:1:1: class: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener
    //#markapprovedwhenauthenticatedlistener.java:1:1: method: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.event.response;

import net.sourceforge.pebble.domain.Response;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.util.SecurityUtils;

/**
 * Sets the status of new comments and TrackBacks to approved, if the user
 * leaving the response is authenticated and authorised for the blog.
 *
 * @author Simon Brown
 */
public class MarkApprovedWhenAuthenticatedListener extends BlogEntryResponseListenerSupport {
    //#markapprovedwhenauthenticatedlistener.java:44: method: void net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener()
    //#input(void net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener()): this
    //#markapprovedwhenauthenticatedlistener.java:44: end of method: void net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener()

  /**
   * Called when a comment or TrackBack has been added.
   *
   * @param response a Response
   */
  protected void blogEntryResponseAdded(Response response) {
    Blog blog = response.getBlogEntry().getBlog();
    //#markapprovedwhenauthenticatedlistener.java:52: method: void net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.blogEntryResponseAdded(Response)
    //#markapprovedwhenauthenticatedlistener.java:52: Warning: suspicious precondition
    //#    the precondition for response.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    suspicious precondition index: [5]
    //#    Attribs:  Soft
    //#input(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#1).__Tag
    //#input(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#2).__Tag
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.areEventsEnabled()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.isApproved()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.isRejected()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.setApproved()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Response]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.setApproved()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.APPROVED
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.REJECTED
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Descendant_Table[net/sourceforge/pebble/domain/State]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.areEventsEnabled()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.isApproved()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.isRejected()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.setApproved()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): response
    //#input(void blogEntryResponseAdded(Response)): response.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.blog
    //#input(void blogEntryResponseAdded(Response)): response.state.__Tag
    //#output(void blogEntryResponseAdded(Response)): response.state
    //#pre[4] (void blogEntryResponseAdded(Response)): response != null
    //#pre[6] (void blogEntryResponseAdded(Response)): response.blogEntry != null
    //#pre[7] (void blogEntryResponseAdded(Response)): response.blogEntry.__Tag == net/sourceforge/pebble/domain/BlogEntry
    //#pre[8] (void blogEntryResponseAdded(Response)): init'ed(response.blogEntry.blog)
    //#pre[5] (void blogEntryResponseAdded(Response)): (soft) response.__Tag in {net/sourceforge/pebble/domain/Comment, net/sourceforge/pebble/domain/Response, net/sourceforge/pebble/domain/TrackBack}
    //#post(void blogEntryResponseAdded(Response)): response.state == One-of{old response.state, &net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#1)}
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:getBlogEntry
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:setState
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:areEventsEnabled
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.util.EventObject
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.api.event.PebbleEvent
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.domain.BlogEntry:addEvent
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:getState
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:isApproved
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:isRejected
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.domain.Response:setState
    //#test_vector(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(...)@53: {0}, {1}
    if (SecurityUtils.isUserAuthorisedForBlog(blog)) {
    //#markapprovedwhenauthenticatedlistener.java:53: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
      response.setApproved();
    }
  }
    //#markapprovedwhenauthenticatedlistener.java:56: end of method: void net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.blogEntryResponseAdded(Response)

}
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener]
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseAdded(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseApproved(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseRejected(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseRemoved(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentApproved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentRejected(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentRemoved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackAdded(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackApproved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackRejected(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackRemoved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/api/event/comment/CommentListener.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener]
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/api/event/trackback/TrackBackListener.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener]
    //#output(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener]
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/api/event/comment/CommentListener.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/api/event/trackback/TrackBackListener.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.__Descendant_Table[net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseAdded(Lnet/sourceforge/pebble/domain/Response;)V == &blogEntryResponseAdded
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseApproved(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseApproved
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseRejected(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseRejected
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.blogEntryResponseRemoved(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseRemoved
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentAdded
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentApproved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentApproved
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentRejected(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentRejected
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.commentRemoved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentRemoved
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackAdded(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackAdded
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackApproved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackApproved
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackRejected(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackRejected
    //#post(net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init): __Dispatch_Table.trackBackRemoved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackRemoved
    //#markapprovedwhenauthenticatedlistener.java:: end of method: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener.net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener__static_init
    //#markapprovedwhenauthenticatedlistener.java:: end of class: net.sourceforge.pebble.event.response.MarkApprovedWhenAuthenticatedListener
