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

neil_a_wilson
21.49.2007 1f3592b4ab0a329ed8e54e311b89d2bca68efb81
Update a number of result codes to make the values more consistent across
operations. Also, eliminate a number of incorrect uses of the
OPERATIONS_ERROR result and replace them with the more correct OTHER result.

OpenDS Issue Number: 1786
11 files modified
96 ■■■■ changed files
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 6 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java 14 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 16 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java 20 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
@@ -472,7 +472,7 @@
           DirectoryServer.getExtendedOperationHandler(requestOID);
      if (handler == null)
      {
        setResultCode(ResultCode.UNAVAILABLE_CRITICAL_EXTENSION);
        setResultCode(ResultCode.UNWILLING_TO_PERFORM);
        appendErrorMessage(ERR_EXTENDED_NO_HANDLER.get(
                String.valueOf(requestOID)));
        break extendedProcessing;
opends/src/server/org/opends/server/protocols/jmx/JmxConnectionHandler.java
@@ -164,7 +164,7 @@
      }
      catch (RuntimeException e)
      {
        resultCode = ResultCode.OPERATIONS_ERROR;
        resultCode = DirectoryServer.getServerErrorResultCode();
        messages.add(Message.raw(e.getMessage()));
      }
    }
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -656,13 +656,15 @@
      {
        Message message = ERR_COULD_NOT_CLOSE_THE_SOCKET.get(e.toString());
        logError(message);
        new ConfigChangeResult(ResultCode.OPERATIONS_ERROR, false);
        new ConfigChangeResult(DirectoryServer.getServerErrorResultCode(),
                               false);
      }
      catch (InterruptedException e)
      {
        Message message = ERR_COULD_NOT_STOP_LISTEN_THREAD.get(e.toString());
        logError(message);
        new ConfigChangeResult(ResultCode.OPERATIONS_ERROR, false);
        new ConfigChangeResult(DirectoryServer.getServerErrorResultCode(),
                               false);
      }
    }
opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -497,16 +497,16 @@
                LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
          } catch (DefinitionDecodingException e) {
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(rufn, rufn, rufn);
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
            throw new ClientException(LDAPResultCode.OTHER, msg);
          } catch (ManagedObjectDecodingException e) {
            // FIXME: should not abort here. Instead, display the
            // errors (if verbose) and apply the changes to the
            // partial managed object.
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(rufn);
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
            throw new ClientException(LDAPResultCode.OTHER, msg, e);
          } catch (CommunicationException e) {
            Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage());
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
            throw new ClientException(LDAPResultCode.OTHER, msg);
          } catch (ManagedObjectNotFoundException e) {
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_MONFE.get(rufn);
            throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
@@ -567,7 +567,7 @@
              } catch (CommunicationException e) {
                Message msg = ERR_DSCFG_ERROR_CREATE_CE
                    .get(ufn, e.getMessage());
                throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
                throw new ClientException(LDAPResultCode.OTHER, msg);
              } catch (ManagedObjectAlreadyExistsException e) {
                // Should never happen.
                throw new IllegalStateException(e);
@@ -696,7 +696,7 @@
        }
      } catch (CommunicationException e) {
        Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage());
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
        throw new ClientException(LDAPResultCode.OTHER, msg);
      } catch (ManagedObjectAlreadyExistsException e) {
        Message msg = ERR_DSCFG_ERROR_CREATE_MOAEE.get(ufn);
        throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg);
@@ -1072,11 +1072,11 @@
    } catch (DefinitionDecodingException e) {
      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ManagedObjectDecodingException e) {
      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
      throw new ClientException(LDAPResultCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e
          .getMessage());
opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -215,11 +215,11 @@
    } catch (DefinitionDecodingException e) {
      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ManagedObjectDecodingException e) {
      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
      throw new ClientException(LDAPResultCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
      throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
opends/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
@@ -232,10 +232,10 @@
      throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
    } catch (DefinitionDecodingException e) {
      Message msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(ufn, ufn, ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ManagedObjectDecodingException e) {
      Message msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
      throw new ClientException(LDAPResultCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_GET_CHILD_CE.get(ufn, e.getMessage());
      throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
@@ -224,11 +224,11 @@
    } catch (DefinitionDecodingException e) {
      ufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(ufn, ufn, ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ManagedObjectDecodingException e) {
      ufn = path.getManagedObjectDefinition().getUserFriendlyName();
      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
      throw new ClientException(LDAPResultCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
      throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
@@ -265,12 +265,12 @@
        // FIXME: just output this as a warnings (incl. the name) but
        // continue.
        Message msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn);
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
        throw new ClientException(LDAPResultCode.OTHER, msg);
      } catch (ManagedObjectDecodingException e) {
        // FIXME: just output this as a warnings (incl. the name) but
        // continue.
        Message msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn);
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
        throw new ClientException(LDAPResultCode.OTHER, msg, e);
      } catch (AuthorizationException e) {
        Message msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn);
        throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
@@ -300,10 +300,10 @@
            msg);
      } catch (DefinitionDecodingException e) {
        Message msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn);
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
        throw new ClientException(LDAPResultCode.OTHER, msg);
      } catch (ManagedObjectDecodingException e) {
        Message msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn);
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
        throw new ClientException(LDAPResultCode.OTHER, msg, e);
      } catch (ConcurrentModificationException e) {
        Message msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
        throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -137,12 +137,12 @@
          Message pufn = path.getManagedObjectDefinition()
              .getUserFriendlyName();
          Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
          throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
          throw new ClientException(LDAPResultCode.OTHER, msg);
        } catch (ManagedObjectDecodingException e) {
          Message pufn = path.getManagedObjectDefinition()
              .getUserFriendlyName();
          Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
          throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
          throw new ClientException(LDAPResultCode.OTHER, msg, e);
        } catch (CommunicationException e) {
          Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage());
          throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN,
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -322,7 +322,7 @@
        }
      } catch (CommunicationException e) {
        Message msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());
        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
        throw new ClientException(LDAPResultCode.OTHER, msg);
      } catch (ManagedObjectAlreadyExistsException e) {
        // Should never happen.
        throw new IllegalStateException(e);
@@ -383,16 +383,16 @@
                LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
          } catch (DefinitionDecodingException e) {
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(rufn, rufn, rufn);
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
            throw new ClientException(LDAPResultCode.OTHER, msg);
          } catch (ManagedObjectDecodingException e) {
            // FIXME: should not abort here. Instead, display the
            // errors (if verbose) and apply the changes to the
            // partial managed object.
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(rufn);
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
            throw new ClientException(LDAPResultCode.OTHER, msg, e);
          } catch (CommunicationException e) {
            Message msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());
            throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
            throw new ClientException(LDAPResultCode.OTHER, msg);
          } catch (ManagedObjectNotFoundException e) {
            Message msg = ERR_DSCFG_ERROR_GET_CHILD_MONFE.get(rufn);
            throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
@@ -453,7 +453,7 @@
              } catch (CommunicationException e) {
                Message msg = ERR_DSCFG_ERROR_MODIFY_CE
                    .get(ufn, e.getMessage());
                throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
                throw new ClientException(LDAPResultCode.OTHER, msg);
              } catch (ManagedObjectAlreadyExistsException e) {
                // Should never happen.
                throw new IllegalStateException(e);
@@ -607,15 +607,15 @@
      throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
    } catch (DefinitionDecodingException e) {
      Message msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(ufn, ufn, ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ManagedObjectDecodingException e) {
      // FIXME: should not abort here. Instead, display the errors (if
      // verbose) and apply the changes to the partial managed object.
      Message msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn);
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
      throw new ClientException(LDAPResultCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());
      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
      throw new ClientException(LDAPResultCode.OTHER, msg);
    } catch (ConcurrentModificationException e) {
      Message msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -145,7 +145,7 @@
      // passwords.
      Message message = ERR_PWPOLICY_ATTRIBUTE_OPTIONS_NOT_ALLOWED.get(
          passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    Attribute passwordAttr = attrList.get(0);
@@ -153,7 +153,7 @@
    {
      Message message = ERR_PWPOLICY_ATTRIBUTE_OPTIONS_NOT_ALLOWED.get(
          passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    LinkedHashSet<AttributeValue> values = passwordAttr.getValues();
@@ -170,7 +170,7 @@
      Message message = ERR_PWPOLICY_MULTIPLE_PW_VALUES_NOT_ALLOWED.get(
          passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    CopyOnWriteArrayList<PasswordStorageScheme> defaultStorageSchemes =
@@ -198,7 +198,7 @@
            Message message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(
                passwordAttribute.getNameOrOID());
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                         message);
          }
        }
@@ -219,7 +219,7 @@
            Message message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(
                passwordAttribute.getNameOrOID());
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                         message);
          }
        }
@@ -245,7 +245,7 @@
            Message message = ERR_PWPOLICY_VALIDATION_FAILED.
                get(passwordAttribute.getNameOrOID(),
                    String.valueOf(invalidReason));
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                         message);
          }
        }
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -962,7 +962,7 @@
                  localOp.isSynchronizationOperation() ||
                  m.isInternal()))
              {
                localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                localOp.appendErrorMessage(
                    ERR_MODIFY_ATTR_IS_OBSOLETE.get(String.valueOf(entryDN),
                    a.getName()));
@@ -5052,7 +5052,7 @@
              }
              else
              {
                localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                localOp.appendErrorMessage(ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
                        String.valueOf(entryDN),
@@ -5094,7 +5094,7 @@
                }
                else
                {
                  localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                  localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                  localOp.appendErrorMessage(
                      ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
@@ -5124,7 +5124,7 @@
              }
              else
              {
                localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                localOp.appendErrorMessage(
                    ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
@@ -5166,7 +5166,7 @@
                }
                else
                {
                  localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                  localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                  localOp.appendErrorMessage(
                      ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
@@ -5277,7 +5277,7 @@
                    ERR_ADD_NO_SUCH_PWPOLICY.get(String.valueOf(entryDN),
                        String.valueOf(policyDN)));
                localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                break addProcessing;
              }
            }
@@ -5450,7 +5450,7 @@
                      String.valueOf(entryDN),
                      at.getNameOrOID());
              localOp.appendErrorMessage(message);
              localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              break addProcessing;
            }
          }
@@ -5463,7 +5463,7 @@
                      String.valueOf(entryDN),
                      at.getNameOrOID());
              localOp.appendErrorMessage(message);
              localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              break addProcessing;
            }
          }
@@ -5476,7 +5476,7 @@
                      String.valueOf(entryDN),
                      oc.getNameOrOID());
              localOp.appendErrorMessage(message);
              localOp.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              localOp.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              break addProcessing;
            }
          }
@@ -8166,7 +8166,7 @@
            AttributeType at = newRDN.getAttributeType(i);
            if (at.isObsolete())
            {
              op.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              op.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              op.appendErrorMessage(ERR_MODDN_NEWRDN_ATTR_IS_OBSOLETE.get(
                      String.valueOf(entryDN),
                      at.getNameOrOID()));