| | |
| | | import org.opends.server.monitors.BackendMonitor; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented for a Directory Server backend. |
| | |
| | | * The set of backends that hold portions of the DIT that are hierarchically |
| | | * below the information in this backend. |
| | | */ |
| | | private Backend<?>[] subordinateBackends; |
| | | private Backend<?>[] subordinateBackends = new Backend[0]; |
| | | |
| | | /** The backend monitor associated with this backend. */ |
| | | private BackendMonitor backendMonitor; |
| | |
| | | private String backendID; |
| | | |
| | | /** The writability mode for this backend. */ |
| | | private WritabilityMode writabilityMode; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new backend with the provided information. All backend |
| | | * implementations must implement a default constructor that use |
| | | * {@code super} to invoke this constructor. |
| | | */ |
| | | protected Backend() |
| | | { |
| | | backendID = null; |
| | | parentBackend = null; |
| | | subordinateBackends = new Backend[0]; |
| | | isPrivateBackend = false; |
| | | writabilityMode = WritabilityMode.ENABLED; |
| | | backendMonitor = null; |
| | | } |
| | | |
| | | |
| | | private WritabilityMode writabilityMode = WritabilityMode.ENABLED; |
| | | |
| | | /** |
| | | * Configure this backend based on the information in the provided |
| | |
| | | * matching rule should be considered indexed, or |
| | | * {@code false} if not. |
| | | */ |
| | | public boolean isIndexed(AttributeType attributeType, |
| | | private boolean isIndexed(AttributeType attributeType, |
| | | MatchingRule matchingRule) |
| | | { |
| | | return false; |
| | | return false; // FIXME This should be overridden by the JE Backend at least! |
| | | } |
| | | |
| | | |
| | |
| | | // NOT filters are not considered indexed by default. |
| | | return false; |
| | | |
| | | |
| | | case EQUALITY: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.EQUALITY); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.EQUALITY); |
| | | |
| | | case SUBSTRING: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.SUBSTRING); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.SUBSTRING); |
| | | |
| | | case GREATER_OR_EQUAL: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.GREATER_OR_EQUAL); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.GREATER_OR_EQUAL); |
| | | |
| | | case LESS_OR_EQUAL: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.LESS_OR_EQUAL); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.LESS_OR_EQUAL); |
| | | |
| | | case PRESENT: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.PRESENCE); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.PRESENCE); |
| | | |
| | | case APPROXIMATE_MATCH: |
| | | return isIndexed(filter.getAttributeType(), |
| | | IndexType.APPROXIMATE); |
| | | |
| | | return isIndexed(filter.getAttributeType(), IndexType.APPROXIMATE); |
| | | |
| | | case EXTENSIBLE_MATCH: |
| | | // The attribute type must be provided for us to make the |
| | |
| | | { |
| | | matchingRule = attrType.getEqualityMatchingRule(); |
| | | } |
| | | // FIXME isIndexed() always return false down below |
| | | return matchingRule != null && isIndexed(attrType, matchingRule); |
| | | |
| | | |
| | |
| | | return writabilityMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Specifies the writability mode for this backend. |
| | | * |
| | |
| | | public final void setWritabilityMode( |
| | | WritabilityMode writabilityMode) |
| | | { |
| | | if (writabilityMode == null) |
| | | { |
| | | this.writabilityMode = WritabilityMode.ENABLED; |
| | | } |
| | | else |
| | | { |
| | | this.writabilityMode = writabilityMode; |
| | | } |
| | | this.writabilityMode = |
| | | writabilityMode != null ? writabilityMode : WritabilityMode.ENABLED; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this backend has a subordinate backend |
| | | * registered with the provided base DN. This may check recursively |
| | | * if a subordinate backend has its own subordinate backends. |
| | | * |
| | | * @param subSuffixDN The DN of the sub-suffix for which to make |
| | | * the determination. |
| | | * |
| | | * @return {@code true} if this backend has a subordinate backend |
| | | * registered with the provided base DN, or {@code false} |
| | | * if it does not. |
| | | */ |
| | | public final boolean hasSubSuffix(DN subSuffixDN) |
| | | { |
| | | for (Backend<?> b : subordinateBackends) |
| | | { |
| | | for (DN baseDN : b.getBaseDNs()) |
| | | { |
| | | if (baseDN.equals(subSuffixDN)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | if (b.hasSubSuffix(subSuffixDN)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Removes the backend associated with the specified sub-suffix if |
| | | * it is registered. This may check recursively if a subordinate |
| | | * backend has its own subordinate backends. |
| | | * |
| | | * @param subSuffixDN The DN of the sub-suffix to remove from this |
| | | * backend. |
| | | * @param parentDN The superior DN for the sub-suffix DN that |
| | | * matches one of the subordinate base DNs for |
| | | * this backend. |
| | | * |
| | | * @throws ConfigException If the sub-suffix exists but it is not |
| | | * possible to remove it for some reason. |
| | | */ |
| | | public final void removeSubSuffix(DN subSuffixDN, DN parentDN) |
| | | throws ConfigException |
| | | { |
| | | synchronized (this) |
| | | { |
| | | boolean matchFound = false; |
| | | ArrayList<Backend<?>> subBackendList = |
| | | new ArrayList<Backend<?>>(subordinateBackends.length); |
| | | for (Backend<?> b : subordinateBackends) |
| | | { |
| | | boolean thisMatches = false; |
| | | DN[] subBaseDNs = b.getBaseDNs(); |
| | | for (DN dn : subBaseDNs) |
| | | { |
| | | if (dn.equals(subSuffixDN)) |
| | | { |
| | | if (subBaseDNs.length > 1) |
| | | { |
| | | Message message = |
| | | ERR_BACKEND_CANNOT_REMOVE_MULTIBASE_SUB_SUFFIX. |
| | | get(String.valueOf(subSuffixDN), |
| | | String.valueOf(parentDN)); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | thisMatches = true; |
| | | matchFound = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (! thisMatches) |
| | | { |
| | | if (b.hasSubSuffix(subSuffixDN)) |
| | | { |
| | | b.removeSubSuffix(subSuffixDN, parentDN); |
| | | } |
| | | else |
| | | { |
| | | subBackendList.add(b); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (matchFound) |
| | | { |
| | | Backend<?>[] newSubordinateBackends = |
| | | new Backend[subBackendList.size()]; |
| | | subBackendList.toArray(newSubordinateBackends); |
| | | subordinateBackends = newSubordinateBackends; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the provided backend to the set of subordinate backends for |
| | | * this backend. |