| | |
| | | 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(); |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | useEtagAttribute(etagAttribute.asString()); |
| | | } |
| | | |
| | | if (configuration.get("useSubtreeDelete").required().asBoolean()) { |
| | | useSubtreeDelete(); |
| | | } |
| | | |
| | | mapper(configureObjectMapper(configuration.get("attributes").required())); |
| | | |
| | | return this; |
| | |
| | | } |
| | | |
| | | public Builder useEtagAttribute(final AttributeDescription attribute) { |
| | | this.mvccStrategy = new AttributeMVCCStrategy(attribute); |
| | | this.etagAttribute = attribute; |
| | | return this; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |