001 /*
002 * Copyright 2008-2015 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015 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.unboundidds.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.unboundidds.controls.ControlMessages.*;
033
034
035
036 /**
037 * <BLOCKQUOTE>
038 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID
039 * LDAP SDK for Java. It is not available for use in applications that
040 * include only the Standard Edition of the LDAP SDK, and is not supported for
041 * use in conjunction with non-UnboundID products.
042 * </BLOCKQUOTE>
043 * This class provides an implementation of an LDAP control that can be used to
044 * request that the Directory Server ignore the NO-USER-MODIFICATION flag for
045 * attribute types. It may be included in an add request to allow the client to
046 * include attributes which are not normally allowed to be externally specified
047 * (e.g., entryUUID, creatorsName, modifiersName, etc.). This control does not
048 * have a value, and there is no corresponding response control.
049 * <BR><BR>
050 * <H2>Example</H2>
051 * The following example demonstrates the process for attempting to perform an
052 * add operation including the ignore NO-USER-MODIFICATION control so that an
053 * entry can be added which already includes the creatorsName and
054 * createTimestamp attributes:
055 * <PRE>
056 * AddRequest addRequest = new AddRequest("dc=example,dc=com",
057 * new Attribute("objectClass", "top", "domain"),
058 * new Attribute("dc", "example"),
059 * new Attribute("creatorsName", "cn=Admin User DN"),
060 * new Attribute("createTimestamp", "20080101000000Z"));
061 * addRequest.addControl(new IgnoreNoUserModificationRequestControl());
062 *
063 * try
064 * {
065 * LDAPResult result = connection.add(addRequest);
066 * // The entry was added successfully.
067 * }
068 * catch (LDAPException le)
069 * {
070 * // The attempt to add the entry failed.
071 * }
072 * </PRE>
073 */
074 @NotMutable()
075 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
076 public final class IgnoreNoUserModificationRequestControl
077 extends Control
078 {
079 /**
080 * The OID (1.3.6.1.4.1.30221.2.5.5) for the ignore NO-USER-MODIFICATION
081 * request control.
082 */
083 public static final String IGNORE_NO_USER_MODIFICATION_REQUEST_OID =
084 "1.3.6.1.4.1.30221.2.5.5";
085
086
087
088 /**
089 * The serial version UID for this serializable class.
090 */
091 private static final long serialVersionUID = 2622432059171073555L;
092
093
094
095 /**
096 * Creates a new ignore NO-USER-MODIFICATION request control. It will be
097 * marked critical.
098 */
099 public IgnoreNoUserModificationRequestControl()
100 {
101 super(IGNORE_NO_USER_MODIFICATION_REQUEST_OID, true, null);
102 }
103
104
105
106 /**
107 * Creates a new ignore NO-USER-MODIFICATION request control which is decoded
108 * from the provided generic control.
109 *
110 * @param control The generic control to be decoded as an ignore
111 * NO-USER-MODIFICATION request control.
112 *
113 * @throws LDAPException If the provided control cannot be decoded as an
114 * ignore NO-USER-MODIFICATION request control.
115 */
116 public IgnoreNoUserModificationRequestControl(final Control control)
117 throws LDAPException
118 {
119 super(control);
120
121 if (control.hasValue())
122 {
123 throw new LDAPException(ResultCode.DECODING_ERROR,
124 ERR_IGNORENUM_REQUEST_HAS_VALUE.get());
125 }
126 }
127
128
129
130 /**
131 * {@inheritDoc}
132 */
133 @Override()
134 public String getControlName()
135 {
136 return INFO_CONTROL_NAME_IGNORE_NO_USER_MODIFICATION_REQUEST.get();
137 }
138
139
140
141 /**
142 * {@inheritDoc}
143 */
144 @Override()
145 public void toString(final StringBuilder buffer)
146 {
147 buffer.append("IgnoreNoUserModificationRequestControl(isCritical=");
148 buffer.append(isCritical());
149 buffer.append(')');
150 }
151 }