Coverage Report - net.sourceforge.pebble.event.AuditListener
 
Classes in this File Line Coverage Branch Coverage Complexity
AuditListener
100%
40/40
N/A
1
 
 1  
 /*
 2  
  * Copyright (c) 2003-2011, Simon Brown
 3  
  * All rights reserved.
 4  
  *
 5  
  * Redistribution and use in source and binary forms, with or without
 6  
  * modification, are permitted provided that the following conditions are met:
 7  
  *
 8  
  *   - Redistributions of source code must retain the above copyright
 9  
  *     notice, this list of conditions and the following disclaimer.
 10  
  *
 11  
  *   - Redistributions in binary form must reproduce the above copyright
 12  
  *     notice, this list of conditions and the following disclaimer in
 13  
  *     the documentation and/or other materials provided with the
 14  
  *     distribution.
 15  
  *
 16  
  *   - Neither the name of Pebble nor the names of its contributors may
 17  
  *     be used to endorse or promote products derived from this software
 18  
  *     without specific prior written permission.
 19  
  *
 20  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 21  
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22  
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23  
  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 24  
  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 25  
  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 26  
  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 27  
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 28  
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 29  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 30  
  * POSSIBILITY OF SUCH DAMAGE.
 31  
  */
 32  
 package net.sourceforge.pebble.event;
 33  
 
 34  
 import net.sourceforge.pebble.api.event.blogentry.BlogEntryListener;
 35  
 import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent;
 36  
 import net.sourceforge.pebble.api.event.comment.CommentListener;
 37  
 import net.sourceforge.pebble.api.event.comment.CommentEvent;
 38  
 import net.sourceforge.pebble.api.event.trackback.TrackBackListener;
 39  
 import net.sourceforge.pebble.api.event.trackback.TrackBackEvent;
 40  
 import net.sourceforge.pebble.audit.AuditTrail;
 41  
 import net.sourceforge.pebble.domain.BlogEntry;
 42  
 import net.sourceforge.pebble.domain.Comment;
 43  
 import net.sourceforge.pebble.domain.TrackBack;
 44  
 
 45  
 /**
 46  
  * @author Simon Brown
 47  
  */
 48  8160
 public class AuditListener implements BlogEntryListener, CommentListener, TrackBackListener {
 49  
 
 50  
   /**
 51  
    * Called when a blog entry has been added.
 52  
    *
 53  
    * @param event a BlogEntryEvent instance
 54  
    */
 55  
   public void blogEntryAdded(BlogEntryEvent event) {
 56  592
     BlogEntry blogEntry = event.getBlogEntry();
 57  592
     AuditTrail.log("Blog entry \"" + blogEntry.getTitle() + "\" (" + blogEntry.getGuid() + ") added");
 58  592
   }
 59  
 
 60  
   /**
 61  
    * Called when a blog entry has been removed.
 62  
    *
 63  
    * @param event a BlogEntryEvent instance
 64  
    */
 65  
   public void blogEntryRemoved(BlogEntryEvent event) {
 66  36
     BlogEntry blogEntry = event.getBlogEntry();
 67  36
     AuditTrail.log("Blog entry \"" + blogEntry.getTitle() + "\" (" + blogEntry.getGuid() + ") removed");
 68  36
   }
 69  
 
 70  
   /**
 71  
    * Called when a blog entry has been changed.
 72  
    *
 73  
    * @param event a BlogEntryEvent instance
 74  
    */
 75  
   public void blogEntryChanged(BlogEntryEvent event) {
 76  24
     BlogEntry blogEntry = event.getBlogEntry();
 77  24
     AuditTrail.log("Blog entry \"" + blogEntry.getTitle() + "\" (" + blogEntry.getGuid() + ") changed");
 78  24
   }
 79  
 
 80  
   /**
 81  
    * Called when a blog entry has been published.
 82  
    *
 83  
    * @param event a BlogEntryEvent instance
 84  
    */
 85  
   public void blogEntryPublished(BlogEntryEvent event) {
 86  28
     BlogEntry blogEntry = event.getBlogEntry();
 87  28
     AuditTrail.log("Blog entry \"" + blogEntry.getTitle() + "\" (" + blogEntry.getGuid() + ") published");
 88  28
   }
 89  
 
 90  
   /**
 91  
    * Called when a blog entry has been unpublished.
 92  
    *
 93  
    * @param event a BlogEntryEvent instance
 94  
    */
 95  
   public void blogEntryUnpublished(BlogEntryEvent event) {
 96  8
     BlogEntry blogEntry = event.getBlogEntry();
 97  8
     AuditTrail.log("Blog entry \"" + blogEntry.getTitle() + "\" (" + blogEntry.getGuid() + ") unpublished");
 98  8
   }
 99  
 
 100  
   /**
 101  
    * Called when a comment has been added.
 102  
    *
 103  
    * @param event a CommentEvent instance
 104  
    */
 105  
   public void commentAdded(CommentEvent event) {
 106  156
     Comment comment = event.getComment();
 107  156
     AuditTrail.log("Comment \"" + comment.getTitle() + "\" from " + comment.getAuthor() + " (" + comment.getGuid() + ") added");
 108  156
   }
 109  
 
 110  
   /**
 111  
    * Called when a comment has been removed.
 112  
    *
 113  
    * @param event a CommentEvent instance
 114  
    */
 115  
   public void commentRemoved(CommentEvent event) {
 116  32
     Comment comment = event.getComment();
 117  32
     AuditTrail.log("Comment \"" + comment.getTitle() + "\" from " + comment.getAuthor() + " (" + comment.getGuid() + ") removed");
 118  32
   }
 119  
 
 120  
   /**
 121  
    * Called when a comment has been approved.
 122  
    *
 123  
    * @param event a CommentEvent instance
 124  
    */
 125  
   public void commentApproved(CommentEvent event) {
 126  92
     Comment comment = event.getComment();
 127  92
     AuditTrail.log("Comment \"" + comment.getTitle() + "\" from " + comment.getAuthor() + " (" + comment.getGuid() + ") approved");
 128  92
   }
 129  
 
 130  
   /**
 131  
    * Called when a comment has been rejected.
 132  
    *
 133  
    * @param event a CommentEvent instance
 134  
    */
 135  
   public void commentRejected(CommentEvent event) {
 136  4
     Comment comment = event.getComment();
 137  4
     AuditTrail.log("Comment \"" + comment.getTitle() + "\" from " + comment.getAuthor() + " (" + comment.getGuid() + ") rejected");
 138  4
   }
 139  
 
 140  
   /**
 141  
    * Called when a TrackBack has been added.
 142  
    *
 143  
    * @param event a TrackBackEvent instance
 144  
    */
 145  
   public void trackBackAdded(TrackBackEvent event) {
 146  28
     TrackBack trackback = event.getTrackBack();
 147  28
     AuditTrail.log("TrackBack \"" + trackback.getTitle() + "\" from " + trackback.getBlogName() + " (" + trackback.getGuid() + ") added");
 148  28
   }
 149  
 
 150  
   /**
 151  
    * Called when a TrackBack has been removed.
 152  
    *
 153  
    * @param event a TrackBackEvent instance
 154  
    */
 155  
   public void trackBackRemoved(TrackBackEvent event) {
 156  16
     TrackBack trackback = event.getTrackBack();
 157  16
     AuditTrail.log("TrackBack \"" + trackback.getTitle() + "\" from " + trackback.getBlogName() + " (" + trackback.getGuid() + ") removed");
 158  16
   }
 159  
 
 160  
   /**
 161  
    * Called when a TrackBack has been approved.
 162  
    *
 163  
    * @param event a TrackBackEvent instance
 164  
    */
 165  
   public void trackBackApproved(TrackBackEvent event) {
 166  4
     TrackBack trackback = event.getTrackBack();
 167  4
     AuditTrail.log("TrackBack \"" + trackback.getTitle() + "\" from " + trackback.getBlogName() + " (" + trackback.getGuid() + ") approved");
 168  4
   }
 169  
 
 170  
   /**
 171  
    * Called when a TrackBack has been rejected.
 172  
    *
 173  
    * @param event a TrackBackEvent instance
 174  
    */
 175  
   public void trackBackRejected(TrackBackEvent event) {
 176  4
     TrackBack trackback = event.getTrackBack();
 177  4
     AuditTrail.log("TrackBack \"" + trackback.getTitle() + "\" from " + trackback.getBlogName() + " (" + trackback.getGuid() + ") rejected");
 178  4
   }
 179  
 }