| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The set of user-defined attributes that will be included in the base monitor entry. */ |
| | | /** The set of user-defined attributes that will be included in the base monitor entry. */ |
| | | private ArrayList<Attribute> userDefinedAttributes; |
| | | /** The set of objectclasses that will be used in monitor entries. */ |
| | | private final HashMap<ObjectClass, String> monitorObjectClasses = new LinkedHashMap<>(2); |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addEntry(final Entry entry, final AddOperation addOperation) |
| | | throws DirectoryException |
| | |
| | | ERR_BACKEND_ADD_NOT_SUPPORTED.get(entry.getName(), getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | final MonitorBackendCfg backendCfg) |
| | |
| | | addAllNonMonitorConfigAttributes(attributes, attributesToAdd); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void createBackup(final BackupConfig backupConfig) |
| | | throws DirectoryException |
| | |
| | | ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void deleteEntry(final DN entryDN, |
| | | final DeleteOperation deleteOperation) throws DirectoryException |
| | |
| | | ERR_BACKEND_DELETE_NOT_SUPPORTED.get(entryDN, getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean entryExists(final DN entryDN) throws DirectoryException |
| | | { |
| | | return getDIT().containsKey(entryDN); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void exportLDIF(final LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | // TODO export-ldif reports nonsense for upTime etc. |
| | | |
| | | // Create the LDIF writer. |
| | | LDIFWriter ldifWriter; |
| | | try |
| | | try (LDIFWriter ldifWriter = newLDIFWriter(exportConfig)) |
| | | { |
| | | ldifWriter = new LDIFWriter(exportConfig); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | final LocalizableMessage message = ERR_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER |
| | | .get(stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | |
| | | // Write the base monitor entry to the LDIF. |
| | | try |
| | | { |
| | | ldifWriter.writeEntry(getBaseMonitorEntry()); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | close(ldifWriter); |
| | | |
| | | final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_BASE |
| | | .get(stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | |
| | | // Get all the monitor providers, convert them to entries, and write them to |
| | | // LDIF. |
| | | for (final MonitorProvider<?> monitorProvider : DirectoryServer |
| | | .getMonitorProviders().values()) |
| | | { |
| | | // Write the base monitor entry to the LDIF. |
| | | try |
| | | { |
| | | // TODO implementation of export is incomplete |
| | | ldifWriter.writeEntry(getBaseMonitorEntry()); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_BASE.get(stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | |
| | | close(ldifWriter); |
| | | |
| | | final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_PROVIDER_ENTRY |
| | | .get(monitorProvider.getMonitorInstanceName(), stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | // Get all the monitor providers, convert them to entries, and write them to LDIF. |
| | | for (final MonitorProvider<?> monitorProvider : DirectoryServer.getMonitorProviders().values()) |
| | | { |
| | | try |
| | | { |
| | | // TODO implementation of export is incomplete |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | final LocalizableMessage message = |
| | | ERR_MONITOR_UNABLE_TO_EXPORT_PROVIDER_ENTRY.get(monitorProvider.getMonitorInstanceName(), |
| | | stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | close(ldifWriter); |
| | | catch (IOException ignoreOnClose) |
| | | { |
| | | logger.traceException(ignoreOnClose); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | private LDIFWriter newLDIFWriter(final LDIFExportConfig exportConfig) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | return new LDIFWriter(exportConfig); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | final LocalizableMessage message = ERR_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER.get(stackTraceToSingleLineString(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void closeBackend() |
| | | { |
| | |
| | | return getEntry(entryDN, dit); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getEntryCount() |
| | | { |
| | | return getDIT().size(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getSupportedControls() |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getSupportedFeatures() |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult hasSubordinates(final DN entryDN) |
| | | throws DirectoryException |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFImportResult importLDIF(final LDIFImportConfig importConfig, ServerContext serverContext) |
| | | throws DirectoryException |
| | |
| | | ERR_BACKEND_IMPORT_NOT_SUPPORTED.get(getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void openBackend() throws ConfigException, InitializationException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | final MonitorBackendCfg backendCfg, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isIndexed(final AttributeType attributeType, |
| | | final IndexType indexType) |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getNumberOfEntriesInBaseDN(final DN baseDN) throws DirectoryException { |
| | | checkNotNull(baseDN, "baseDN must not be null"); |
| | | return getNumberOfSubordinates(baseDN, true) + 1; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getNumberOfChildren(final DN parentDN) throws DirectoryException { |
| | | checkNotNull(parentDN, "parentDN must not be null"); |
| | |
| | | return count; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeBackup(final BackupDirectory backupDirectory, |
| | | final String backupID) throws DirectoryException |
| | |
| | | ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void renameEntry(final DN currentDN, final Entry entry, |
| | | final ModifyDNOperation modifyDNOperation) throws DirectoryException |
| | |
| | | ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void replaceEntry(final Entry oldEntry, final Entry newEntry, |
| | | final ModifyOperation modifyOperation) throws DirectoryException |
| | |
| | | ERR_MONITOR_MODIFY_NOT_SUPPORTED.get(newEntry.getName(), configEntryDN)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void restoreBackup(final RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | |
| | | ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void search(final SearchOperation searchOperation) |
| | | throws DirectoryException |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean supports(BackendOperation backendOperation) |
| | | { |
| | |
| | | return dit; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates the monitor entry having the specified DN. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Generates and returns a monitor entry based on the contents of the provided |
| | | * monitor provider. |