Factor out duplicate code and fix cut n paste bug in LocalBackendModifyOperation which was preventing sync operations from bypassing backend INTERNAL_ONLY mode.
| | |
| | | } |
| | | } |
| | | |
| | | // If it is not a private backend, then check to see if the server or |
| | | // backend is operating in read-only mode. |
| | | if (!backend.isPrivateBackend()) |
| | | { |
| | | switch (DirectoryServer.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCodeAndMessageNoInfoDisclosure(entryDN, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_ADD_SERVER_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCodeAndMessageNoInfoDisclosure(entryDN, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_ADD_SERVER_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | switch (backend.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCodeAndMessageNoInfoDisclosure(entryDN, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_ADD_BACKEND_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCodeAndMessageNoInfoDisclosure(entryDN, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_ADD_BACKEND_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | LocalBackendWorkflowElement.checkIfBackendIsWritable(backend, this, |
| | | entryDN, ERR_ADD_SERVER_READONLY, ERR_ADD_BACKEND_READONLY); |
| | | |
| | | if (noOp) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | // If it is not a private backend, then check to see if the server or |
| | | // backend is operating in read-only mode. |
| | | if (!backend.isPrivateBackend()) |
| | | { |
| | | switch (DirectoryServer.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCodeAndMessageNoInfoDisclosure(entry, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_DELETE_SERVER_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCodeAndMessageNoInfoDisclosure(entry, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_DELETE_SERVER_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | switch (backend.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCodeAndMessageNoInfoDisclosure(entry, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_DELETE_BACKEND_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCodeAndMessageNoInfoDisclosure(entry, |
| | | ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_DELETE_BACKEND_READONLY.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | LocalBackendWorkflowElement.checkIfBackendIsWritable(backend, this, |
| | | entryDN, ERR_DELETE_SERVER_READONLY, ERR_DELETE_BACKEND_READONLY); |
| | | |
| | | // The selected backend will have the responsibility of making sure that |
| | | // the entry actually exists and does not have any children (or possibly |
| | |
| | | applyPreOpModifications(modifications, 0, false); |
| | | } |
| | | |
| | | // Actually perform the modify DN operation. |
| | | // This should include taking |
| | | // care of any synchronization that might be needed. |
| | | // If it is not a private backend, then check to see if the server or |
| | | // backend is operating in read-only mode. |
| | | if (!currentBackend.isPrivateBackend()) |
| | | { |
| | | switch (DirectoryServer.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_SERVER_READONLY.get(String |
| | | .valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_SERVER_READONLY.get(String |
| | | .valueOf(entryDN))); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | switch (currentBackend.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_BACKEND_READONLY.get(String |
| | | .valueOf(entryDN))); |
| | | return; |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_BACKEND_READONLY.get(String |
| | | .valueOf(entryDN))); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | LocalBackendWorkflowElement.checkIfBackendIsWritable(currentBackend, |
| | | this, entryDN, ERR_MODDN_SERVER_READONLY, ERR_MODDN_BACKEND_READONLY); |
| | | |
| | | if (noOp) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | checkWritability(); |
| | | LocalBackendWorkflowElement.checkIfBackendIsWritable(backend, this, |
| | | entryDN, ERR_MODIFY_SERVER_READONLY, ERR_MODIFY_BACKEND_READONLY); |
| | | |
| | | if (noOp) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Checks to ensure that both the Directory Server and the backend are |
| | | * writable. |
| | | * |
| | | * @throws DirectoryException If the modify operation should not be allowed |
| | | * as a result of the writability check. |
| | | */ |
| | | protected void checkWritability() |
| | | throws DirectoryException |
| | | { |
| | | // If it is not a private backend, then check to see if the server or |
| | | // backend is operating in read-only mode. |
| | | if (! backend.isPrivateBackend()) |
| | | { |
| | | switch (DirectoryServer.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_MODIFY_SERVER_READONLY.get( |
| | | String.valueOf(entryDN))); |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (! (isInternalOperation() || isSynchronizationOperation())) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_MODIFY_SERVER_READONLY.get( |
| | | String.valueOf(entryDN))); |
| | | } |
| | | } |
| | | |
| | | switch (backend.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_MODIFY_BACKEND_READONLY.get( |
| | | String.valueOf(entryDN))); |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (! isInternalOperation() || isSynchronizationOperation()) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_MODIFY_BACKEND_READONLY.get( |
| | | String.valueOf(entryDN))); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Handles any account status notifications that may be needed as a result of |
| | | * modify processing. |
| | | */ |
| | |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageDescriptor; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | |
| | | { |
| | | return persistentSearches; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Checks if an update operation can be performed against a backend. The |
| | | * operation will be rejected based on the server and backend writability |
| | | * modes. |
| | | * |
| | | * @param backend |
| | | * The backend handling the update. |
| | | * @param op |
| | | * The update operation. |
| | | * @param entryDN |
| | | * The name of the entry being updated. |
| | | * @param serverMsg |
| | | * The message to log if the update was rejected because the server |
| | | * is read-only. |
| | | * @param backendMsg |
| | | * The message to log if the update was rejected because the backend |
| | | * is read-only. |
| | | * @throws DirectoryException |
| | | * If the update operation has been rejected. |
| | | */ |
| | | static void checkIfBackendIsWritable(Backend backend, Operation op, |
| | | DN entryDN, MessageDescriptor.Arg1<CharSequence> serverMsg, |
| | | MessageDescriptor.Arg1<CharSequence> backendMsg) |
| | | throws DirectoryException |
| | | { |
| | | if (!backend.isPrivateBackend()) |
| | | { |
| | | switch (DirectoryServer.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | serverMsg.get(String.valueOf(entryDN))); |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(op.isInternalOperation() || op.isSynchronizationOperation())) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | serverMsg.get(String.valueOf(entryDN))); |
| | | } |
| | | } |
| | | |
| | | switch (backend.getWritabilityMode()) |
| | | { |
| | | case DISABLED: |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | backendMsg.get(String.valueOf(entryDN))); |
| | | |
| | | case INTERNAL_ONLY: |
| | | if (!(op.isInternalOperation() || op.isSynchronizationOperation())) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | backendMsg.get(String.valueOf(entryDN))); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |