| | |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.RuntimeInformation; |
| | | |
| | | /** |
| | |
| | | public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException |
| | | { |
| | | checkNotNull(baseDN, "baseDN must not be null"); |
| | | final EntryContainer ec; |
| | | |
| | | try { |
| | | ec = accessBegin(null, baseDN); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw de; |
| | | } |
| | | |
| | | final EntryContainer ec = accessBegin(null, baseDN); |
| | | ec.sharedLock.lock(); |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | throw new DirectoryException(getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | } |
| | | finally |
| | | { |
| | |
| | | if (rootContainer == null) |
| | | { |
| | | LocalizableMessage msg = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID()); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), msg); |
| | | throw new DirectoryException(getServerErrorResultCode(), msg); |
| | | } |
| | | } |
| | | |
| | |
| | | // If the backend already has the root container open, we must use the same |
| | | // underlying root container |
| | | boolean openRootContainer = mustOpenRootContainer(); |
| | | final ResultCode errorRC = DirectoryServer.getServerErrorResultCode(); |
| | | try |
| | | { |
| | | if (openRootContainer) |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | throw new DirectoryException(errorRC, ERR_EXPORT_IO_ERROR.get(ioe.getMessage()), ioe); |
| | | throw new DirectoryException(getServerErrorResultCode(), ERR_EXPORT_IO_ERROR.get(ioe.getMessage()), ioe); |
| | | } |
| | | catch (StorageRuntimeException de) |
| | | { |
| | | throw createDirectoryException(de); |
| | | } |
| | | catch (ConfigException ce) |
| | | catch (ConfigException | InitializationException | LDIFException e) |
| | | { |
| | | throw new DirectoryException(errorRC, ce.getMessageObject(), ce); |
| | | } |
| | | catch (IdentifiedException e) |
| | | { |
| | | if (e instanceof DirectoryException) |
| | | { |
| | | throw (DirectoryException) e; |
| | | } |
| | | throw new DirectoryException(errorRC, e.getMessageObject(), e); |
| | | throw new DirectoryException(getServerErrorResultCode(), e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | |
| | | rootContainer = initializeRootContainer(); |
| | | return rootContainer.importLDIF(importConfig, serverContext); |
| | | return getImportStrategy().importLDIF(importConfig, rootContainer, serverContext); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | throw new DirectoryException(getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw e; |
| | | } |
| | | catch (OpenDsException e) |
| | | { |
| | | throw new DirectoryException(getServerErrorResultCode(), e.getMessageObject(), e); |
| | | } |
| | | catch (ConfigException e) |
| | | catch (OpenDsException | ConfigException e) |
| | | { |
| | | throw new DirectoryException(getServerErrorResultCode(), e.getMessageObject(), e); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private ImportStrategy getImportStrategy() throws DirectoryException |
| | | { |
| | | // TODO JNR may call new SuccessiveAddsImportStrategy() depending on configured import strategy |
| | | return new Importer.StrategyImpl(cfg); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long verifyBackend(VerifyConfig verifyConfig) |
| | |
| | | * If the rootContainer is open, the backend is initialized by something else. |
| | | * We can't do any rebuild of system indexes while others are using this backend. |
| | | */ |
| | | final ResultCode errorRC = DirectoryServer.getServerErrorResultCode(); |
| | | if (!openRootContainer && rebuildConfig.includesSystemIndex()) |
| | | { |
| | | throw new DirectoryException(errorRC, ERR_REBUILD_BACKEND_ONLINE.get()); |
| | | throw new DirectoryException(getServerErrorResultCode(), ERR_REBUILD_BACKEND_ONLINE.get()); |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (ExecutionException execEx) |
| | | { |
| | | throw new DirectoryException(errorRC, ERR_EXECUTION_ERROR.get(execEx.getMessage()), execEx); |
| | | throw new DirectoryException(getServerErrorResultCode(), ERR_EXECUTION_ERROR.get(execEx.getMessage()), execEx); |
| | | } |
| | | catch (InterruptedException intEx) |
| | | { |
| | | throw new DirectoryException(errorRC, ERR_INTERRUPTED_ERROR.get(intEx.getMessage()), intEx); |
| | | throw new DirectoryException(getServerErrorResultCode(), ERR_INTERRUPTED_ERROR.get(intEx.getMessage()), intEx); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | throw new DirectoryException(errorRC, ce.getMessageObject(), ce); |
| | | throw new DirectoryException(getServerErrorResultCode(), ce.getMessageObject(), ce); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | throw new DirectoryException(errorRC, LocalizableMessage.raw(e.getMessage()), e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | throw new InitializationException(e.getMessageObject(), e); |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.setResultCode(getServerErrorResultCode()); |
| | | ccr.addMessage(LocalizableMessage.raw(stackTraceToSingleLineString(e))); |
| | | } |
| | | return ccr; |
| | |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.setResultCode(getServerErrorResultCode()); |
| | | ccr.addMessage(ERR_BACKEND_CANNOT_REGISTER_BASEDN.get(baseDN, e)); |
| | | return false; |
| | | } |
| | |
| | | Throwable cause = e.getCause(); |
| | | if (cause instanceof OpenDsException) |
| | | { |
| | | return new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), (OpenDsException) cause); |
| | | return new DirectoryException(getServerErrorResultCode(), (OpenDsException) cause); |
| | | } |
| | | else |
| | | { |
| | | return new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), |
| | | LocalizableMessage.raw(e.getMessage()), e); |
| | | return new DirectoryException(getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | } |
| | | } |
| | | |