001    /*
002     * Copyright 2007-2013 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2008-2013 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk.controls;
022    
023    
024    
025    import com.unboundid.ldap.sdk.Control;
026    import com.unboundid.ldap.sdk.LDAPException;
027    import com.unboundid.ldap.sdk.ResultCode;
028    import com.unboundid.util.NotMutable;
029    import com.unboundid.util.ThreadSafety;
030    import com.unboundid.util.ThreadSafetyLevel;
031    
032    import static com.unboundid.ldap.sdk.controls.ControlMessages.*;
033    
034    
035    
036    /**
037     * This class provides an implementation of the ManageDsaIT control as described
038     * in <A HREF="http://www.ietf.org/rfc/rfc3296.txt">RFC 3296</A>.  This control
039     * may be used to request that the directory server treat all entries as if they
040     * were regular entries.
041     * <BR><BR>
042     * One of the most common uses of the ManageDsaIT control is to request that the
043     * directory server to treat an entry containing the "{@code referral}" object
044     * class as a regular entry rather than a smart referral.  Normally, when the
045     * server encounters an entry with the {@code referral} object class, it sends
046     * a referral with the URLs contained in the {@code ref} attribute of that
047     * entry.  However, if the ManageDsaIT control is included then the operation
048     * will attempt to operate on the referral definition itself rather than sending
049     * that referral to the client.
050     * <BR><BR>
051     * <H2>Example</H2>
052     * The following example demonstrates the use of the ManageDsaIT control to
053     * delete an entry that may or may not be a referral:
054     * <PRE>
055     *   DeleteRequest deleteRequest =
056     *     new DeleteRequest("uid=john.doe,ou=People,dc=example,dc=com");
057     *   deleteRequest.addControl(new ManageDsaITRequestControl());
058     *   LDAPResult deleteResult = connection.delete(deleteRequest);
059     * </PRE>
060     */
061    @NotMutable()
062    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
063    public final class ManageDsaITRequestControl
064           extends Control
065    {
066      /**
067       * The OID (2.16.840.1.113730.3.4.2) for the ManageDsaIT request control.
068       */
069      public static final String MANAGE_DSA_IT_REQUEST_OID =
070           "2.16.840.1.113730.3.4.2";
071    
072    
073    
074      /**
075       * The serial version UID for this serializable class.
076       */
077      private static final long serialVersionUID = -4540943247829123783L;
078    
079    
080    
081      /**
082       * Creates a new ManageDsaIT request control.  The control will not be marked
083       * critical.
084       */
085      public ManageDsaITRequestControl()
086      {
087        super(MANAGE_DSA_IT_REQUEST_OID, false, null);
088      }
089    
090    
091    
092      /**
093       * Creates a new ManageDsaIT request control.
094       *
095       * @param  isCritical  Indicates whether the control should be marked
096       *                     critical.
097       */
098      public ManageDsaITRequestControl(final boolean isCritical)
099      {
100        super(MANAGE_DSA_IT_REQUEST_OID, isCritical, null);
101      }
102    
103    
104    
105      /**
106       * Creates a new ManageDsaIT request control which is decoded from the
107       * provided generic control.
108       *
109       * @param  control  The generic control to be decoded as a ManageDsaIT request
110       *                  control.
111       *
112       * @throws  LDAPException  If the provided control cannot be decoded as a
113       *                         ManageDsaIT request control.
114       */
115      public ManageDsaITRequestControl(final Control control)
116             throws LDAPException
117      {
118        super(control);
119    
120        if (control.hasValue())
121        {
122          throw new LDAPException(ResultCode.DECODING_ERROR,
123                                  ERR_MANAGE_DSA_IT_HAS_VALUE.get());
124        }
125      }
126    
127    
128    
129      /**
130       * {@inheritDoc}
131       */
132      @Override()
133      public String getControlName()
134      {
135        return INFO_CONTROL_NAME_MANAGE_DSAIT_REQUEST.get();
136      }
137    
138    
139    
140      /**
141       * {@inheritDoc}
142       */
143      @Override()
144      public void toString(final StringBuilder buffer)
145      {
146        buffer.append("ManageDsaITRequestControl(isCritical=");
147        buffer.append(isCritical());
148        buffer.append(')');
149      }
150    }