001package com.nimbusds.infinispan.persistence.ldap; 002 003 004/** 005 * Write strategy for persisting Infinispan entries into an LDAP directory. 006 * 007 * <p>Background: 008 * 009 * <p>LDAP directories don't support a generic write (or put) operation. New 010 * entries are created with an ADD operation, and may then be updated with a 011 * separate MODIFY operation. Generic write requests must therefore be 012 * translated to an LDAP ADD or an LDAP MODIFY operation, and each operation 013 * then tried individually until we have success. 014 */ 015public enum LDAPWriteStrategy { 016 017 018 /** 019 * Try to write the entry with an LDAP ADD operation first. If the ADD 020 * operation fails with an {@code 68} error code (entry already 021 * exists), then the entry write can then be attempted with an LDAP 022 * MODIFY operation. 023 */ 024 TRY_LDAP_ADD_FIRST, 025 026 027 /** 028 * Try to write the entry with an LDAP MODIFY operation first. If the 029 * MODIFY operation fails with an {@code 32} (no such entry), then the 030 * entry write can be attempted with an LDAP ADD operation. 031 */ 032 TRY_LDAP_MODIFY_FIRST; 033 034 035 /** 036 * Returns the default write strategy. 037 * 038 * @return The default write strategy ({@link #TRY_LDAP_ADD_FIRST}). 039 */ 040 public static LDAPWriteStrategy getDefault() { 041 042 return TRY_LDAP_ADD_FIRST; 043 } 044}