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