From ff499dddfe79aabd9b995f3f4d2a033ae7b2cfa7 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 03 Apr 2013 23:12:04 +0000
Subject: [PATCH] OPENDJ-692: Implement delete support
---
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java | 37 +++++++++++++++----------------------
1 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
index c2837e3..7add0d5 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
@@ -79,12 +79,13 @@
private AuthorizationPolicy authzPolicy = AuthorizationPolicy.NONE;
private DN baseDN; // TODO: support template variables.
private ConnectionFactory factory;
- private MVCCStrategy mvccStrategy;
+ private AttributeDescription etagAttribute;
private NameStrategy nameStrategy;
private AuthzIdTemplate proxiedAuthzTemplate;
private ReadOnUpdatePolicy readOnUpdatePolicy = CONTROLS;
private AttributeMapper rootMapper;
private Schema schema = Schema.getDefaultSchema();
+ private boolean useSubtreeDelete;
Builder() {
useEtagAttribute();
@@ -142,8 +143,9 @@
break;
}
return new LDAPCollectionResourceProvider(baseDN, rootMapper, nameStrategy,
- mvccStrategy, new Config(factory, readOnUpdatePolicy, authzPolicy,
- proxiedAuthzTemplate, schema), additionalLDAPAttributes);
+ etagAttribute, new Config(factory, readOnUpdatePolicy, authzPolicy,
+ proxiedAuthzTemplate, useSubtreeDelete, schema),
+ additionalLDAPAttributes);
}
/**
@@ -194,6 +196,10 @@
useEtagAttribute(etagAttribute.asString());
}
+ if (configuration.get("useSubtreeDelete").required().asBoolean()) {
+ useSubtreeDelete();
+ }
+
mapper(configureObjectMapper(configuration.get("attributes").required()));
return this;
@@ -267,7 +273,7 @@
}
public Builder useEtagAttribute(final AttributeDescription attribute) {
- this.mvccStrategy = new AttributeMVCCStrategy(attribute);
+ this.etagAttribute = attribute;
return this;
}
@@ -294,6 +300,11 @@
return useServerNaming(at(dnAttribute), ad(idAttribute));
}
+ public Builder useSubtreeDelete() {
+ this.useSubtreeDelete = true;
+ return this;
+ }
+
private AttributeDescription ad(final String attribute) {
return AttributeDescription.valueOf(attribute, schema);
}
@@ -386,24 +397,6 @@
}
}
- private static final class AttributeMVCCStrategy extends MVCCStrategy {
- private final AttributeDescription ldapAttribute;
-
- private AttributeMVCCStrategy(final AttributeDescription ldapAttribute) {
- this.ldapAttribute = ldapAttribute;
- }
-
- @Override
- void getLDAPAttributes(final Context c, final Set<String> ldapAttributes) {
- ldapAttributes.add(ldapAttribute.toString());
- }
-
- @Override
- String getRevisionFromEntry(final Context c, final Entry entry) {
- return entry.parseAttribute(ldapAttribute).asString();
- }
- }
-
private static final class AttributeNameStrategy extends NameStrategy {
private final AttributeDescription dnAttribute;
private final AttributeDescription idAttribute;
--
Gitblit v1.10.0