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 2009 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2015 ForgeRock AS. 016 */ 017package org.opends.server.controls; 018 019 020 021import static org.opends.messages.ProtocolMessages.*; 022import static org.opends.server.util.ServerConstants.*; 023 024import java.io.IOException; 025 026import org.forgerock.i18n.LocalizableMessage; 027import org.forgerock.opendj.io.ASN1Writer; 028import org.forgerock.opendj.ldap.ByteString; 029import org.opends.server.types.Control; 030import org.opends.server.types.DirectoryException; 031import org.forgerock.opendj.ldap.ResultCode; 032 033 034 035/** 036 * This class implements the subtree delete control defined in 037 * draft-armijo-ldap-treedelete. It makes it possible for clients to 038 * delete subtrees of entries. 039 */ 040public class SubtreeDeleteControl extends Control 041{ 042 /** 043 * ControlDecoder implementation to decode this control from a 044 * ByteString. 045 */ 046 private static final class Decoder implements 047 ControlDecoder<SubtreeDeleteControl> 048 { 049 /** {@inheritDoc} */ 050 public SubtreeDeleteControl decode(boolean isCritical, 051 ByteString value) throws DirectoryException 052 { 053 if (value != null) 054 { 055 LocalizableMessage message = 056 ERR_SUBTREE_DELETE_INVALID_CONTROL_VALUE.get(); 057 throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); 058 } 059 060 return new SubtreeDeleteControl(isCritical); 061 } 062 063 064 065 public String getOID() 066 { 067 return OID_SUBTREE_DELETE_CONTROL; 068 } 069 070 } 071 072 073 074 /** 075 * The Control Decoder that can be used to decode this control. 076 */ 077 public static final ControlDecoder<SubtreeDeleteControl> DECODER = 078 new Decoder(); 079 080 081 082 /** 083 * Creates a new subtree delete control. 084 * 085 * @param isCritical 086 * Indicates whether the control should be considered 087 * critical for the operation processing. 088 */ 089 public SubtreeDeleteControl(boolean isCritical) 090 { 091 super(OID_SUBTREE_DELETE_CONTROL, isCritical); 092 } 093 094 095 096 /** {@inheritDoc} */ 097 @Override 098 protected void writeValue(ASN1Writer writer) throws IOException 099 { 100 // Nothing to do. 101 } 102 103 104 105 /** {@inheritDoc} */ 106 @Override 107 public void toString(StringBuilder buffer) 108 { 109 buffer.append("SubtreeDeleteControl()"); 110 } 111 112}