| | |
| | | import org.forgerock.opendj.server.config.server.RootDSEBackendCfg; |
| | | import org.forgerock.util.Reject; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.LocalBackend; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | |
| | | * with the other backends. |
| | | */ |
| | | public class RootDSEBackend |
| | | extends Backend<RootDSEBackendCfg> |
| | | extends LocalBackend<RootDSEBackendCfg> |
| | | implements ConfigurationChangeListener<RootDSEBackendCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | * The set of subordinate base DNs and their associated backends that will be |
| | | * used for non-base searches. |
| | | */ |
| | | private ConcurrentHashMap<DN, Backend<?>> subordinateBaseDNs; |
| | | private ConcurrentHashMap<DN, LocalBackend<?>> subordinateBaseDNs; |
| | | |
| | | /** |
| | | * Creates a new backend with the provided information. All backend |
| | |
| | | subordinateBaseDNs = new ConcurrentHashMap<>(); |
| | | for (DN baseDN : subDNs) |
| | | { |
| | | Backend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | LocalBackend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | if (backend != null) |
| | | { |
| | | subordinateBaseDNs.put(baseDN, backend); |
| | |
| | | } |
| | | |
| | | long count = 1; |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | for (Map.Entry<DN, LocalBackend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | DN subBase = entry.getKey(); |
| | | Backend<?> b = entry.getValue(); |
| | | LocalBackend<?> b = entry.getValue(); |
| | | Entry subBaseEntry = b.getEntry(subBase); |
| | | if (subBaseEntry != null) |
| | | { |
| | |
| | | |
| | | long count = 0; |
| | | |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | for (Map.Entry<DN, LocalBackend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | DN subBase = entry.getKey(); |
| | | Entry subBaseEntry = entry.getValue().getEntry(subBase); |
| | |
| | | // specified. |
| | | if (subordinateBaseDNs != null) |
| | | { |
| | | for (Backend<?> b : subordinateBaseDNs.values()) |
| | | for (LocalBackend<?> b : subordinateBaseDNs.values()) |
| | | { |
| | | if (b.handlesEntry(entryDN)) |
| | | { |
| | |
| | | Map<AttributeType, List<Attribute>> dseUserAttrs = new HashMap<>(); |
| | | Map<AttributeType, List<Attribute>> dseOperationalAttrs = new HashMap<>(); |
| | | |
| | | Map<DN, Backend<?>> publicNamingContexts = showSubordinatesNamingContexts ? |
| | | Map<DN, LocalBackend<?>> publicNamingContexts = showSubordinatesNamingContexts ? |
| | | DirectoryServer.getAllPublicNamingContexts() : |
| | | DirectoryServer.getPublicNamingContexts(); |
| | | Attribute publicNamingContextAttr = createAttribute(ATTR_NAMING_CONTEXTS, publicNamingContexts.keySet()); |
| | |
| | | |
| | | // If it was not the null DN, then iterate through the associated |
| | | // subordinate backends to make the determination. |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | for (Map.Entry<DN, LocalBackend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | DN baseDN = entry.getKey(); |
| | | if (entryDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | Backend<?> b = entry.getValue(); |
| | | LocalBackend<?> b = entry.getValue(); |
| | | if (b.entryExists(entryDN)) |
| | | { |
| | | return true; |
| | |
| | | break; |
| | | |
| | | case SINGLE_LEVEL: |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | for (Map.Entry<DN, LocalBackend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | searchOperation.checkIfCanceled(false); |
| | | |
| | | DN subBase = entry.getKey(); |
| | | Backend<?> b = entry.getValue(); |
| | | LocalBackend<?> b = entry.getValue(); |
| | | Entry subBaseEntry = b.getEntry(subBase); |
| | | if (subBaseEntry != null && filter.matchesEntry(subBaseEntry)) |
| | | { |
| | |
| | | case SUBORDINATES: |
| | | try |
| | | { |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | for (Map.Entry<DN, LocalBackend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | searchOperation.checkIfCanceled(false); |
| | | |
| | | DN subBase = entry.getKey(); |
| | | Backend<?> b = entry.getValue(); |
| | | LocalBackend<?> b = entry.getValue(); |
| | | |
| | | searchOperation.setBaseDN(subBase); |
| | | try |
| | |
| | | * @return the subordinate base DNs of the root DSE |
| | | */ |
| | | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| | | public Map<DN, Backend<?>> getSubordinateBaseDNs() |
| | | public Map<DN, LocalBackend<?>> getSubordinateBaseDNs() |
| | | { |
| | | if (subordinateBaseDNs != null) |
| | | { |
| | |
| | | { |
| | | for (DN baseDN : subDNs) |
| | | { |
| | | Backend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | LocalBackend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | if (backend == null) |
| | | { |
| | | unacceptableReasons.add(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE.get(baseDN)); |
| | |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | // Check to see if we should apply a new set of base DNs. |
| | | ConcurrentHashMap<DN, Backend<?>> subBases; |
| | | ConcurrentHashMap<DN, LocalBackend<?>> subBases; |
| | | try |
| | | { |
| | | Set<DN> subDNs = cfg.getSubordinateBaseDN(); |
| | |
| | | subBases = new ConcurrentHashMap<>(); |
| | | for (DN baseDN : subDNs) |
| | | { |
| | | Backend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | LocalBackend<?> backend = DirectoryServer.getBackend(baseDN); |
| | | if (backend == null) |
| | | { |
| | | // This is not fine. We can't use a suffix that doesn't exist. |