001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2015-2016 ForgeRock AS. 016 */ 017package org.opends.server.replication.protocol; 018 019/** 020 * This exception should be raised by the un-serialization code of a PDU 021 * (typically the constructor code with a byte[] parameter), when the detected 022 * PDU type (deduced from the first received byte of the message) is a PDU used 023 * in an older version of the replication protocol than the current one, and we 024 * do not support translation from this old version PDU to his matching PDU in 025 * the current protocol version (if it exists). Thus, the code catching this 026 * exception may decide special treatment, depending on the situation. For 027 * instance it may decide to trash the PDU and keep the connection opened, or to 028 * trash the PDU and close the connection... 029 */ 030public class NotSupportedOldVersionPDUException extends Exception 031{ 032 /** Suppress compile warning. */ 033 static final long serialVersionUID = 1739875L; 034 /** Explicit message. */ 035 private String msg; 036 /** Protocol version of the pdu. */ 037 private short protocolVersion = -1; 038 /** Type of the pdu. */ 039 private byte pduType = -1; 040 041 /** 042 * Exception constructor. 043 * @param pduStr PDU description. 044 * @param protocolVersion PDU protocol version. 045 * @param pduType PDU number. 046 */ 047 public NotSupportedOldVersionPDUException(String pduStr, 048 short protocolVersion, byte pduType) 049 { 050 super(); 051 msg = "Received unsupported " + pduStr + " PDU (" + pduType + 052 ") from protocol version " + protocolVersion; 053 this.protocolVersion = protocolVersion; 054 this.pduType = pduType; 055 } 056 057 /** 058 * Get the PDU message. 059 * @return The PDU message. 060 */ 061 @Override 062 public String getMessage() 063 { 064 return msg; 065 } 066 067 @Override 068 public String getLocalizedMessage() 069 { 070 return getMessage(); 071 } 072 073 @Override 074 public String toString() 075 { 076 return getMessage(); 077 } 078 079 /** 080 * Get the PDU protocol version. 081 * @return The PDU protocol version. 082 */ 083 public short getProtocolVersion() 084 { 085 return protocolVersion; 086 } 087 088 /** 089 * Get the PDU type. 090 * @return The PDU type. 091 */ 092 public byte getPduType() 093 { 094 return pduType; 095 } 096}