001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.server.protocols.ldap; 028 029 030 031import org.forgerock.opendj.io.ASN1Writer; 032 033import org.forgerock.i18n.slf4j.LocalizedLogger; 034import static org.opends.server.protocols.ldap.LDAPConstants.*; 035import static org.opends.server.util.ServerConstants.*; 036 037import java.io.IOException; 038 039 040/** 041 * This class defines the structures and methods for an LDAP abandon request 042 * protocol op, which is used to indicate that the server should stop processing 043 * a previously requested operation. 044 */ 045public class AbandonRequestProtocolOp 046 extends ProtocolOp 047{ 048 private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); 049 050 /** The message ID of the operation to abandon. */ 051 private int idToAbandon; 052 053 054 055 /** 056 * Creates a new abandon request protocol op to abandon the specified 057 * operation. 058 * 059 * @param idToAbandon The message ID of the operation to abandon. 060 */ 061 public AbandonRequestProtocolOp(int idToAbandon) 062 { 063 this.idToAbandon = idToAbandon; 064 } 065 066 067 068 /** 069 * Retrieves the message ID of the operation to abandon. 070 * 071 * @return The message ID of the operation to abandon. 072 */ 073 public int getIDToAbandon() 074 { 075 return idToAbandon; 076 } 077 078 079 080 /** 081 * Retrieves the BER type for this protocol op. 082 * 083 * @return The BER type for this protocol op. 084 */ 085 public byte getType() 086 { 087 return OP_TYPE_ABANDON_REQUEST; 088 } 089 090 091 092 /** 093 * Retrieves the name for this protocol op type. 094 * 095 * @return The name for this protocol op type. 096 */ 097 public String getProtocolOpName() 098 { 099 return "Abandon Request"; 100 } 101 102 /** 103 * Writes this protocol op to an ASN.1 output stream. 104 * 105 * @param stream The ASN.1 output stream to write to. 106 * @throws IOException If a problem occurs while writing to the stream. 107 */ 108 public void write(ASN1Writer stream) throws IOException 109 { 110 stream.writeInteger(OP_TYPE_ABANDON_REQUEST, idToAbandon); 111 } 112 113 114 /** 115 * Appends a string representation of this LDAP protocol op to the provided 116 * buffer. 117 * 118 * @param buffer The buffer to which the string should be appended. 119 */ 120 public void toString(StringBuilder buffer) 121 { 122 buffer.append("AbandonRequest(idToAbandon="); 123 buffer.append(idToAbandon); 124 buffer.append(")"); 125 } 126 127 128 129 /** 130 * Appends a multi-line string representation of this LDAP protocol op to the 131 * provided buffer. 132 * 133 * @param buffer The buffer to which the information should be appended. 134 * @param indent The number of spaces from the margin that the lines should 135 * be indented. 136 */ 137 public void toString(StringBuilder buffer, int indent) 138 { 139 StringBuilder indentBuf = new StringBuilder(indent); 140 for (int i=0 ; i < indent; i++) 141 { 142 indentBuf.append(' '); 143 } 144 145 buffer.append(indentBuf); 146 buffer.append("Abandon Request"); 147 buffer.append(EOL); 148 149 buffer.append(indentBuf); 150 buffer.append(" ID to Abandon: "); 151 buffer.append(idToAbandon); 152 buffer.append(EOL); 153 } 154} 155