| | |
| | | import java.util.zip.CheckedInputStream; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn; |
| | | import org.opends.server.admin.std.server.LocalDBBackendCfg; |
| | |
| | | * This is an implementation of a Directory Server Backend which stores entries |
| | | * locally in a Berkeley DB JE database. |
| | | */ |
| | | public class BackendImpl |
| | | extends Backend |
| | | public class BackendImpl extends Backend<LocalDBBackendCfg> |
| | | implements ConfigurationChangeListener<LocalDBBackendCfg>, AlertGenerator, |
| | | DiskSpaceMonitorHandler |
| | | { |
| | |
| | | /** |
| | | * The controls supported by this backend. |
| | | */ |
| | | private static HashSet<String> supportedControls; |
| | | |
| | | static |
| | | { |
| | | // Set our supported controls. |
| | | supportedControls = new HashSet<String>(); |
| | | supportedControls.add(OID_SUBTREE_DELETE_CONTROL); |
| | | supportedControls.add(OID_PAGED_RESULTS_CONTROL); |
| | | supportedControls.add(OID_MANAGE_DSAIT_CONTROL); |
| | | supportedControls.add(OID_SERVER_SIDE_SORT_REQUEST_CONTROL); |
| | | supportedControls.add(OID_VLV_REQUEST_CONTROL); |
| | | } |
| | | |
| | | /** |
| | | * The features supported by this backend. |
| | | */ |
| | | private static HashSet<String> supportedFeatures = new HashSet<String>(); |
| | | private static final Set<String> supportedControls = new HashSet<String>(Arrays.asList( |
| | | OID_SUBTREE_DELETE_CONTROL, |
| | | OID_PAGED_RESULTS_CONTROL, |
| | | OID_MANAGE_DSAIT_CONTROL, |
| | | OID_SERVER_SIDE_SORT_REQUEST_CONTROL, |
| | | OID_VLV_REQUEST_CONTROL)); |
| | | |
| | | /** |
| | | * Begin a Backend API method that reads the database. |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } finally { |
| | | if (fis != null) { |
| | | try { |
| | | fis.close(); |
| | | } catch (Exception e) { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | close(fis); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configureBackend(Configuration cfg) |
| | | throws ConfigException |
| | | public void configureBackend(LocalDBBackendCfg cfg) throws ConfigException |
| | | { |
| | | Validator.ensureNotNull(cfg); |
| | | Validator.ensureTrue(cfg instanceof LocalDBBackendCfg); |
| | | |
| | | this.cfg = (LocalDBBackendCfg)cfg; |
| | | |
| | | Set<DN> dnSet = this.cfg.getBaseDN(); |
| | | baseDNs = new DN[dnSet.size()]; |
| | | dnSet.toArray(baseDNs); |
| | | this.cfg = cfg; |
| | | baseDNs = this.cfg.getBaseDN().toArray(new DN[0]); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void initializeBackend() |
| | | throws ConfigException, InitializationException |
| | | { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void finalizeBackend() |
| | | { |
| | | // Deregister as a change listener. |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean isLocal() |
| | | { |
| | | return true; |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean isIndexed(AttributeType attributeType, IndexType indexType) |
| | | { |
| | | try |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean supportsLDIFExport() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean supportsLDIFImport() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean supportsBackup() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean supportsBackup(BackupConfig backupConfig, |
| | | StringBuilder unsupportedReason) |
| | | { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean supportsRestore() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public HashSet<String> getSupportedFeatures() |
| | | @Override |
| | | public Set<String> getSupportedFeatures() |
| | | { |
| | | return supportedFeatures; |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public HashSet<String> getSupportedControls() |
| | | @Override |
| | | public Set<String> getSupportedControls() |
| | | { |
| | | return supportedControls; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public DN[] getBaseDNs() |
| | | { |
| | | return baseDNs; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public long getEntryCount() |
| | | { |
| | | if (rootContainer != null) |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public ConditionResult hasSubordinates(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public long numSubordinates(DN entryDN, boolean subtree) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public Entry getEntry(DN entryDN) throws DirectoryException |
| | | { |
| | | readerBegin(); |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void addEntry(Entry entry, AddOperation addOperation) |
| | | throws DirectoryException, CanceledOperationException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) |
| | | throws DirectoryException, CanceledOperationException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void replaceEntry(Entry oldEntry, Entry newEntry, |
| | | ModifyOperation modifyOperation) throws DirectoryException, |
| | | CanceledOperationException |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void renameEntry(DN currentDN, Entry entry, |
| | | ModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException, CanceledOperationException |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void search(SearchOperation searchOperation) |
| | | throws DirectoryException, CanceledOperationException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public LDIFImportResult importLDIF(LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void createBackup(BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void removeBackup(BackupDirectory backupDirectory, String backupID) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public void restoreBackup(RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean isConfigurationAcceptable(Configuration configuration, |
| | | @Override |
| | | public boolean isConfigurationAcceptable(LocalDBBackendCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | LocalDBBackendCfg config = (LocalDBBackendCfg) configuration; |
| | | return isConfigurationChangeAcceptable(config, unacceptableReasons); |
| | | } |
| | | |