| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.util.LDIFWriter; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.BackendMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | extends Backend |
| | | implements ConfigurableComponent |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.backends.RootDSEBackend"; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | |
| | | // Perform all initialization in initializeBackend. |
| | |
| | | public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializeBackend", |
| | | String.valueOf(configEntry)); |
| | | |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_SUBORDINATE_BASE_EXCEPTION; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | throw new InitializationException(msgID, message,e); |
| | | throw new InitializationException(msgID, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializeBackend", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_ROOTDSE_CANNOT_DETERMINE_ALL_USER_ATTRIBUTES; |
| | | String message = getMessage(msgID, ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES, |
| | |
| | | */ |
| | | public void finalizeBackend() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "finalizeBackend"); |
| | | |
| | | DirectoryServer.deregisterConfigurableComponent(this); |
| | | } |
| | |
| | | */ |
| | | private boolean isDSEConfigAttribute(Attribute attribute) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isConfigAttribute", |
| | | String.valueOf(attribute)); |
| | | |
| | | AttributeType attrType = attribute.getAttributeType(); |
| | | if (attrType.hasName(ATTR_ROOT_DSE_SUBORDINATE_BASE_DN.toLowerCase()) || |
| | |
| | | */ |
| | | public DN[] getBaseDNs() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBaseDNs"); |
| | | |
| | | return baseDNs; |
| | | } |
| | |
| | | */ |
| | | public synchronized long getEntryCount() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEntryCount"); |
| | | |
| | | // There is always just a single entry in this backend. |
| | | return 1; |
| | |
| | | */ |
| | | public boolean isLocal() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isLocal"); |
| | | |
| | | // For the purposes of this method, this is a local backend. |
| | | return true; |
| | |
| | | public Entry getEntry(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getEntry", String.valueOf(entryDN)); |
| | | |
| | | |
| | | // If the requested entry was the root DSE, then create and return it. |
| | |
| | | */ |
| | | public Entry getRootDSE() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getRootDSE"); |
| | | |
| | | HashMap<AttributeType,List<Attribute>> dseUserAttrs = |
| | | new HashMap<AttributeType,List<Attribute>>(); |
| | |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | String value) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createAttribute", String.valueOf(name), |
| | | String.valueOf(lowerName), String.valueOf(value)); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | |
| | | private Attribute createDNAttribute(String name, String lowerName, |
| | | Collection<DN> values) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createDNAttribute", String.valueOf(name), |
| | | String.valueOf(lowerName), String.valueOf(values)); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | Collection<String> values) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createAttribute", String.valueOf(name), |
| | | String.valueOf(lowerName), String.valueOf(values)); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | |
| | | public boolean entryExists(DN entryDN) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "entryExists", String.valueOf(entryDN)); |
| | | |
| | | |
| | | // If the specified DN was the null DN, then it exists. |
| | |
| | | public void addEntry(Entry entry, AddOperation addOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "addEntry", String.valueOf(entry), |
| | | String.valueOf(addOperation)); |
| | | |
| | | int msgID = MSGID_ROOTDSE_ADD_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, String.valueOf(entry.getDN())); |
| | |
| | | public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "deleteEntry", String.valueOf(entryDN), |
| | | String.valueOf(deleteOperation)); |
| | | |
| | | int msgID = MSGID_ROOTDSE_DELETE_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, String.valueOf(entryDN)); |
| | |
| | | public void replaceEntry(Entry entry, ModifyOperation modifyOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "replaceEntry", String.valueOf(entry), |
| | | String.valueOf(modifyOperation)); |
| | | |
| | | int msgID = MSGID_ROOTDSE_MODIFY_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, String.valueOf(entry.getDN()), |
| | |
| | | ModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "renameEntry", String.valueOf(currentDN), |
| | | String.valueOf(entry), String.valueOf(modifyDNOperation)); |
| | | |
| | | int msgID = MSGID_ROOTDSE_MODIFY_DN_NOT_SUPPORTED; |
| | | String message = getMessage(msgID, String.valueOf(currentDN)); |
| | |
| | | public void search(SearchOperation searchOperation) |
| | | throws DirectoryException, CancelledOperationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "search", String.valueOf(searchOperation)); |
| | | |
| | | DN baseDN = searchOperation.getBaseDN(); |
| | | if (! baseDN.isNullDN()) |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | assert debugException(CLASS_NAME, "search", de); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, de); |
| | | } |
| | | |
| | | throw de; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "search", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_UNEXPECTED_SEARCH_FAILURE; |
| | | String message = getMessage(msgID, searchOperation.getConnectionID(), |
| | |
| | | */ |
| | | public HashSet<String> getSupportedControls() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSupportedControls"); |
| | | |
| | | return supportedControls; |
| | | } |
| | |
| | | */ |
| | | public HashSet<String> getSupportedFeatures() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSupportedFeatures"); |
| | | |
| | | return supportedFeatures; |
| | | } |
| | |
| | | */ |
| | | public boolean supportsLDIFExport() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsLDIFExport"); |
| | | |
| | | // We will only export the DSE entry itself. |
| | | return true; |
| | |
| | | LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "exportLDIF", String.valueOf(exportConfig)); |
| | | |
| | | |
| | | // Create the LDIF writer. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "exportLDIF", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "exportLDIF", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_UNABLE_TO_EXPORT_DSE; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "exportLDIF", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public boolean supportsLDIFImport() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsLDIFImport"); |
| | | |
| | | // This backend does not support LDIF imports. |
| | | return false; |
| | |
| | | LDIFImportConfig importConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "importLDIF", String.valueOf(importConfig)); |
| | | |
| | | |
| | | // This backend does not support LDIF imports. |
| | |
| | | */ |
| | | public boolean supportsBackup() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsBackup"); |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | | return false; |
| | |
| | | public boolean supportsBackup(BackupConfig backupConfig, |
| | | StringBuilder unsupportedReason) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsBackup"); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "createBackup", String.valueOf(backupConfig)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | String backupID) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "removeBackup", |
| | | String.valueOf(backupDirectory), |
| | | String.valueOf(backupID)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | */ |
| | | public boolean supportsRestore() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsRestore"); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | RestoreConfig restoreConfig) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "restoreBackup", |
| | | String.valueOf(restoreConfig)); |
| | | |
| | | |
| | | // This backend does not provide a backup/restore mechanism. |
| | |
| | | */ |
| | | public DN getConfigurableComponentEntryDN() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurableComponentEntryDN"); |
| | | |
| | | return configEntryDN; |
| | | } |
| | |
| | | */ |
| | | public List<ConfigAttribute> getConfigurationAttributes() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurationAttributes"); |
| | | |
| | | LinkedList<ConfigAttribute> attrList = new LinkedList<ConfigAttribute>(); |
| | | |
| | |
| | | public boolean hasAcceptableConfiguration(ConfigEntry configEntry, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "hasAcceptableConfiguration", |
| | | String.valueOf(configEntry), "java.util.List<String>"); |
| | | |
| | | |
| | | boolean configIsAcceptable = true; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "hasAcceptableConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_SUBORDINATE_BASE_EXCEPTION; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "hasAcceptableConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_CANNOT_DETERMINE_ALL_USER_ATTRIBUTES; |
| | | String message = getMessage(msgID, ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES, |
| | |
| | | public ConfigChangeResult applyNewConfiguration(ConfigEntry configEntry, |
| | | boolean detailedResults) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "applyNewConfiguration", |
| | | String.valueOf(configEntry), |
| | | String.valueOf(detailedResults)); |
| | | |
| | | |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_SUBORDINATE_BASE_EXCEPTION; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ROOTDSE_CANNOT_DETERMINE_ALL_USER_ATTRIBUTES; |
| | | String message = getMessage(msgID, ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES, |