mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Chris Ridd
17.26.2012 fe6b7743202b99a10ba61038e4540c410b1344f3
Fix OPENDJ-611 Return something in ResultCode descr attribute
1 files added
8 files modified
153 ■■■■ changed files
opends/resource/dsml/schema/DSMLv2.xsd 2 ●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLAddOperation.java 6 ●●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLCompareOperation.java 4 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLDeleteOperation.java 6 ●●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java 3 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLModifyDNOperation.java 4 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLModifyOperation.java 4 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLSearchOperation.java 13 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/ResultCodeFactory.java 111 ●●●●● patch | view | raw | blame | history
opends/resource/dsml/schema/DSMLv2.xsd
@@ -228,7 +228,7 @@
            <xsd:enumeration value="noSuchObject"/>
            <xsd:enumeration value="aliasProblem"/>
            <xsd:enumeration value="invalidDNSyntax"/>
            <xsd:enumeration value="aliasDerefencingProblem"/>
            <xsd:enumeration value="aliasDereferencingProblem"/>
            <xsd:enumeration value="inappropriateAuthentication"/>
            <xsd:enumeration value="invalidCredentials"/>
            <xsd:enumeration value="insufficientAccessRights"/>
opends/src/dsml/org/opends/dsml/protocol/DSMLAddOperation.java
@@ -23,9 +23,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -117,8 +120,7 @@
    // Set the result code and error message for the DSML response.
    addResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    addResponse.setResultCode(code);
    return addResponse;
opends/src/dsml/org/opends/dsml/protocol/DSMLCompareOperation.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
@@ -106,8 +107,7 @@
    // Set the response code and error message for the DSML response.
    compareResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    compareResponse.setResultCode(code);
    if(compareOp.getMatchedDN() != null)
opends/src/dsml/org/opends/dsml/protocol/DSMLDeleteOperation.java
@@ -23,9 +23,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
import java.io.IOException;
import org.opends.messages.Message;
@@ -104,8 +107,7 @@
    // Set the result code and error message for the DSML response.
    delResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    delResponse.setResultCode(code);
    // set the match DN
opends/src/dsml/org/opends/dsml/protocol/DSMLExtendedOperation.java
@@ -126,8 +126,7 @@
    extendedResponse.setResponse(value);
    extendedResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    extendedResponse.setResultCode(code);
    return extendedResponse;
opends/src/dsml/org/opends/dsml/protocol/DSMLModifyDNOperation.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
@@ -115,8 +116,7 @@
    modDNResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    modDNResponse.setResultCode(code);
    return modDNResponse;
opends/src/dsml/org/opends/dsml/protocol/DSMLModifyOperation.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
@@ -141,8 +142,7 @@
    // Set the result code and error message for the DSML response.
    modResponse.setErrorMessage(
            errorMessage != null ? errorMessage.toString() : null);
    ResultCode code = objFactory.createResultCode();
    code.setCode(resultCode);
    ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
    modResponse.setResultCode(code);
    return modResponse;
opends/src/dsml/org/opends/dsml/protocol/DSMLSearchOperation.java
@@ -23,13 +23,12 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
import org.opends.messages.Message;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
@@ -38,6 +37,7 @@
import javax.xml.bind.JAXBElement;
import org.opends.messages.Message;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPConstants;
@@ -45,8 +45,8 @@
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.protocols.ldap.SearchRequestProtocolOp;
import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp;
import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp;
import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp;
import org.opends.server.tools.LDAPConnection;
import org.opends.server.types.ByteString;
import org.opends.server.types.DereferencePolicy;
@@ -532,8 +532,8 @@
          // code to the client to cover possible cases.
          Message message = ERR_UNEXPECTED_CONNECTION_CLOSURE.get();
          LDAPResult result = objFactory.createLDAPResult();
          ResultCode code = objFactory.createResultCode();
          code.setCode(LDAPResultCode.UNAVAILABLE);
          ResultCode code = ResultCodeFactory.create(objFactory,
              LDAPResultCode.UNAVAILABLE);
          result.setResultCode(code);
          result.setErrorMessage(message.toString());
          searchResponse.setSearchResultDone(result);
@@ -580,8 +580,7 @@
          resultCode = searchOp.getResultCode();
          errorMessage = searchOp.getErrorMessage();
          LDAPResult result = objFactory.createLDAPResult();
          ResultCode code = objFactory.createResultCode();
          code.setCode(resultCode);
          ResultCode code = ResultCodeFactory.create(objFactory, resultCode);
          result.setResultCode(code);
          result.setErrorMessage(errorMessage != null ? errorMessage.toString()
              : null);
opends/src/dsml/org/opends/dsml/protocol/ResultCodeFactory.java
New file
@@ -0,0 +1,111 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2012 ForgeRock AS.
 */
package org.opends.dsml.protocol;
import java.util.HashMap;
/**
 * A utility class to help creating ResultCode objects containing a
 * code value (integer) and a descr value (String).
 */
public class ResultCodeFactory
{
  static HashMap<Integer,LDAPResultCode> codeToDescr =
    new HashMap<Integer,LDAPResultCode>();
  static
  {
    codeToDescr.put(new Integer(0), LDAPResultCode.SUCCESS);
    codeToDescr.put(new Integer(1), LDAPResultCode.OPERATIONS_ERROR);
    codeToDescr.put(new Integer(2), LDAPResultCode.PROTOCOL_ERROR);
    codeToDescr.put(new Integer(3), LDAPResultCode.TIME_LIMIT_EXCEEDED);
    codeToDescr.put(new Integer(4), LDAPResultCode.SIZE_LIMIT_EXCEEDED);
    codeToDescr.put(new Integer(5), LDAPResultCode.COMPARE_FALSE);
    codeToDescr.put(new Integer(6), LDAPResultCode.COMPARE_TRUE);
    codeToDescr.put(new Integer(7), LDAPResultCode.AUTH_METHOD_NOT_SUPPORTED);
    // Note not STRONGER_AUTH_REQUIRED, that's the RFC 4511 name
    codeToDescr.put(new Integer(8), LDAPResultCode.STRONG_AUTH_REQUIRED);
    codeToDescr.put(new Integer(10), LDAPResultCode.REFERRAL);
    codeToDescr.put(new Integer(11), LDAPResultCode.ADMIN_LIMIT_EXCEEDED);
    codeToDescr.put(new Integer(12),
      LDAPResultCode.UNAVAILABLE_CRITICAL_EXTENSION);
    codeToDescr.put(new Integer(13), LDAPResultCode.CONFIDENTIALITY_REQUIRED);
    codeToDescr.put(new Integer(14), LDAPResultCode.SASL_BIND_IN_PROGRESS);
    codeToDescr.put(new Integer(16), LDAPResultCode.NO_SUCH_ATTRIBUTE);
    codeToDescr.put(new Integer(17), LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE);
    codeToDescr.put(new Integer(18), LDAPResultCode.INAPPROPRIATE_MATCHING);
    codeToDescr.put(new Integer(19), LDAPResultCode.CONSTRAINT_VIOLATION);
    codeToDescr.put(new Integer(20), LDAPResultCode.ATTRIBUTE_OR_VALUE_EXISTS);
    codeToDescr.put(new Integer(21), LDAPResultCode.INVALID_ATTRIBUTE_SYNTAX);
    codeToDescr.put(new Integer(32), LDAPResultCode.NO_SUCH_OBJECT);
    codeToDescr.put(new Integer(33), LDAPResultCode.ALIAS_PROBLEM);
    codeToDescr.put(new Integer(34), LDAPResultCode.INVALID_DN_SYNTAX);
    codeToDescr.put(new Integer(36),
      LDAPResultCode.ALIAS_DEREFERENCING_PROBLEM);
    codeToDescr.put(new Integer(48),
      LDAPResultCode.INAPPROPRIATE_AUTHENTICATION);
    codeToDescr.put(new Integer(49), LDAPResultCode.INVALID_CREDENTIALS);
    codeToDescr.put(new Integer(50), LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS);
    codeToDescr.put(new Integer(51), LDAPResultCode.BUSY);
    codeToDescr.put(new Integer(52), LDAPResultCode.UNAVAILABLE);
    codeToDescr.put(new Integer(53), LDAPResultCode.UNWILLING_TO_PERFORM);
    codeToDescr.put(new Integer(54), LDAPResultCode.LOOP_DETECT);
    codeToDescr.put(new Integer(64), LDAPResultCode.NAMING_VIOLATION);
    codeToDescr.put(new Integer(65), LDAPResultCode.OBJECT_CLASS_VIOLATION);
    codeToDescr.put(new Integer(66), LDAPResultCode.NOT_ALLOWED_ON_NON_LEAF);
    codeToDescr.put(new Integer(67), LDAPResultCode.NOT_ALLOWED_ON_RDN);
    codeToDescr.put(new Integer(68), LDAPResultCode.ENTRY_ALREADY_EXISTS);
    codeToDescr.put(new Integer(69),
      LDAPResultCode.OBJECT_CLASS_MODS_PROHIBITED);
    // Note not AFFECTS_MULTIPLE_DSAS, xjc mangles the string.
    codeToDescr.put(new Integer(71), LDAPResultCode.AFFECT_MULTIPLE_DS_AS);
    codeToDescr.put(new Integer(80), LDAPResultCode.OTHER);
  }
  /**
   * Create a ResultCode object that contains the resultCode, and, if valid,
   * a text description (from RFC 2251) of the resultCode.
   *
   * @param objFactory
   *                  The JAXB factory used to create the underlying object.
   * @param resultCode
   *                  The LDAP result code.
   * @return A ResultCode object with a code and possibly a description.
   */
  public static ResultCode create(ObjectFactory objFactory, int resultCode)
  {
    ResultCode result = objFactory.createResultCode();
    result.setCode(resultCode);
    Integer r = new Integer(resultCode);
    if (ResultCodeFactory.codeToDescr.containsKey(r))
    {
      result.setDescr(ResultCodeFactory.codeToDescr.get(r));
    }
    return result;
  }
}