mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
04.12.2013 e23491effc24d8de7a3a0593880767f6478cb06b
opendj-sdk/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;