| | |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | LocalizableMessage message = WARN_JEB_GET_ENTRY_COUNT_FAILED.get(e.getMessage()); |
| | | throw new InitializationException(message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new InitializationException(ERR_BACKEND_CANNOT_REGISTER_BASEDN.get(dn, e), e); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException |
| | | { |
| | | long ret = numSubordinates(entryDN, false); |
| | | if(ret < 0) |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | EntryContainer container; |
| | | try { |
| | | container = accessBegin(null, entryDN); |
| | | } |
| | | return ConditionResult.valueOf(ret != 0); |
| | | catch (DirectoryException de) |
| | | { |
| | | if (de.getResultCode() == ResultCode.UNDEFINED) |
| | | { |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | throw de; |
| | | } |
| | | |
| | | container.sharedLock.lock(); |
| | | try |
| | | { |
| | | return ConditionResult.valueOf(container.hasSubordinates(entryDN)); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | | { |
| | | container.sharedLock.unlock(); |
| | | accessEnd(); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long numSubordinates(DN entryDN, boolean subtree) throws DirectoryException |
| | | 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; |
| | | } |
| | | |
| | | ec.sharedLock.lock(); |
| | | try |
| | | { |
| | | return ec.getNumberOfEntriesInBaseDN(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | } |
| | | finally |
| | | { |
| | | ec.sharedLock.unlock(); |
| | | accessEnd(); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getNumberOfChildren(DN parentDN) throws DirectoryException |
| | | { |
| | | checkNotNull(parentDN, "parentDN must not be null"); |
| | | EntryContainer ec; |
| | | |
| | | /* |
| | |
| | | * error if the EntryContainer is null... |
| | | */ |
| | | try { |
| | | ec = accessBegin(null, entryDN); |
| | | ec = accessBegin(null, parentDN); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | ec.sharedLock.lock(); |
| | | try |
| | | { |
| | | long count = ec.getNumSubordinates(entryDN, subtree); |
| | | if(count == Long.MAX_VALUE) |
| | | { |
| | | // The index entry limit has exceeded and there is no count maintained. |
| | | return -1; |
| | | } |
| | | return count; |
| | | return ec.getNumberOfChildren(parentDN); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | | { |
| | | ec.sharedLock.unlock(); |
| | | accessEnd(); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean entryExists(final DN entryDN) throws DirectoryException |
| | | { |
| | | EntryContainer ec = accessBegin(null, entryDN); |
| | | ec.sharedLock.lock(); |
| | | try |
| | | { |
| | | return ec.entryExists(entryDN); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | logger.traceException(ioe); |
| | | throw new DirectoryException(errorRC, ERR_JEB_EXPORT_IO_ERROR.get(ioe.getMessage()), ioe); |
| | | } |
| | | catch (StorageRuntimeException de) |
| | | { |
| | | logger.traceException(de); |
| | | throw createDirectoryException(de); |
| | | } |
| | | catch (ConfigException ce) |
| | |
| | | { |
| | | throw (DirectoryException) e; |
| | | } |
| | | logger.traceException(e); |
| | | throw new DirectoryException(errorRC, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new DirectoryException(getServerErrorResultCode(), LocalizableMessage.raw(e.getMessage()), e); |
| | | } |
| | | catch (DirectoryException e) |
| | |
| | | } |
| | | catch (OpenDsException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new DirectoryException(getServerErrorResultCode(), e.getMessageObject(), e); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new DirectoryException(getServerErrorResultCode(), e.getMessageObject(), e); |
| | | } |
| | | finally |
| | |
| | | { |
| | | rootContainer = getReadOnlyRootContainer(); |
| | | } |
| | | |
| | | VerifyJob verifyJob = new VerifyJob(verifyConfig); |
| | | return verifyJob.verifyBackend(rootContainer); |
| | | return new VerifyJob(rootContainer, verifyConfig).verifyBackend(); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw createDirectoryException(e); |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (ExecutionException execEx) |
| | | { |
| | | logger.traceException(execEx); |
| | | throw new DirectoryException(errorRC, ERR_EXECUTION_ERROR.get(execEx.getMessage())); |
| | | throw new DirectoryException(errorRC, ERR_EXECUTION_ERROR.get(execEx.getMessage()), execEx); |
| | | } |
| | | catch (InterruptedException intEx) |
| | | { |
| | | logger.traceException(intEx); |
| | | throw new DirectoryException(errorRC, ERR_INTERRUPTED_ERROR.get(intEx.getMessage())); |
| | | throw new DirectoryException(errorRC, ERR_INTERRUPTED_ERROR.get(intEx.getMessage()), intEx); |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | logger.traceException(ce); |
| | | throw new DirectoryException(errorRC, ce.getMessageObject()); |
| | | throw new DirectoryException(errorRC, ce.getMessageObject(), ce); |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new DirectoryException(errorRC, LocalizableMessage.raw(e.getMessage())); |
| | | throw new DirectoryException(errorRC, LocalizableMessage.raw(e.getMessage()), e); |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | logger.traceException(e); |
| | | throw new InitializationException(e.getMessageObject()); |
| | | throw new InitializationException(e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (StorageRuntimeException e) |
| | | { |
| | | logger.traceException(e); |
| | | LocalizableMessage message = ERR_JEB_OPEN_ENV_FAIL.get(e.getMessage()); |
| | | throw new InitializationException(message, e); |
| | | } |