01: /**
02: * $RCSfile$
03: * $Revision: 1565 $
04: * $Date: 2005-06-28 19:46:49 -0300 (Tue, 28 Jun 2005) $
05: *
06: * Copyright (C) 2004 Jive Software. All rights reserved.
07: *
08: * This software is published under the terms of the GNU Public License (GPL),
09: * a copy of which is included in this distribution.
10: */package org.jivesoftware.openfire.interceptor;
11:
12: import java.io.PrintStream;
13: import java.io.PrintWriter;
14:
15: /**
16: * Thrown by a PacketInterceptor when a packet is prevented from being processed. If the packet was
17: * received then it will not be processed and a not_allowed error will be sent back to the sender
18: * of the packet. If the packet was going to be sent then the sending will be aborted.
19: *
20: * @see PacketInterceptor
21: * @author Gaston Dombiak
22: */
23: public class PacketRejectedException extends Exception {
24: private static final long serialVersionUID = 1L;
25:
26: private Throwable nestedThrowable = null;
27:
28: /**
29: * Text to include in a message that will be sent to the sender of the packet that got
30: * rejected. If no text is specified then no message will be sent to the user.
31: */
32: private String rejectionMessage;
33:
34: public PacketRejectedException() {
35: super ();
36: }
37:
38: public PacketRejectedException(String msg) {
39: super (msg);
40: }
41:
42: public PacketRejectedException(Throwable nestedThrowable) {
43: this .nestedThrowable = nestedThrowable;
44: }
45:
46: public PacketRejectedException(String msg, Throwable nestedThrowable) {
47: super (msg);
48: this .nestedThrowable = nestedThrowable;
49: }
50:
51: public void printStackTrace() {
52: super .printStackTrace();
53: if (nestedThrowable != null) {
54: nestedThrowable.printStackTrace();
55: }
56: }
57:
58: public void printStackTrace(PrintStream ps) {
59: super .printStackTrace(ps);
60: if (nestedThrowable != null) {
61: nestedThrowable.printStackTrace(ps);
62: }
63: }
64:
65: public void printStackTrace(PrintWriter pw) {
66: super .printStackTrace(pw);
67: if (nestedThrowable != null) {
68: nestedThrowable.printStackTrace(pw);
69: }
70: }
71:
72: /**
73: * Retuns the text to include in a message that will be sent to the sender of the packet
74: * that got rejected or <tt>null</tt> if none was defined. If no text was specified then
75: * no message will be sent to the sender of the rejected packet.
76: *
77: * @return the text to include in a message that will be sent to the sender of the packet
78: * that got rejected or <tt>null</tt> if none was defined.
79: */
80: public String getRejectionMessage() {
81: return rejectionMessage;
82: }
83:
84: /**
85: * Sets the text to include in a message that will be sent to the sender of the packet
86: * that got rejected or <tt>null</tt> if no message will be sent to the sender of the
87: * rejected packet. Bt default, no message will be sent.
88: *
89: * @param rejectionMessage the text to include in the notification message for the rejection.
90: */
91: public void setRejectionMessage(String rejectionMessage) {
92: this.rejectionMessage = rejectionMessage;
93: }
94: }
|