use of com.unboundid.ldap.sdk.ChangeType in project ldapsdk by pingidentity.
the class GetChangelogBatchExtendedRequestTestCase method testMostConstructorWithListener.
/**
* Provides test coverage for the constructor which may be used to create an
* instance of this extended request using a full set of information and takes
* an entry listener.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testMostConstructorWithListener() throws Exception {
final List<String> includeBases = Arrays.asList("dc=example,dc=com");
final List<String> excludeBases = Arrays.asList("ou=People,dc=example,dc=com");
final EnumSet<ChangeType> changeTypes = EnumSet.of(ChangeType.ADD, ChangeType.DELETE, ChangeType.MODIFY_DN);
GetChangelogBatchExtendedRequest r = new GetChangelogBatchExtendedRequest(new TestChangelogEntryListener(), new EndOfChangelogStartingPoint(), -1, -1L, true, includeBases, excludeBases, changeTypes, false, "uid=test.user,ou=People,dc=example,dc=com", new IgnoreAttributesChangeSelectionCriteria(true), new Control("1.2.3.4"));
assertNotNull(r.getEntryListener());
assertTrue(r.getEntryListener() instanceof TestChangelogEntryListener);
r = new GetChangelogBatchExtendedRequest(r);
r = r.duplicate();
assertNotNull(r);
assertNotNull(r.getStartingPoint());
assertTrue(r.getStartingPoint() instanceof EndOfChangelogStartingPoint);
assertEquals(r.getMaxChanges(), 0);
assertEquals(r.getMaxWaitTimeMillis(), 0L);
assertTrue(r.waitForMaxChanges());
assertNotNull(r.getIncludeBaseDNs());
assertEquals(r.getIncludeBaseDNs(), includeBases);
assertNotNull(r.getExcludeBaseDNs());
assertEquals(r.getExcludeBaseDNs(), excludeBases);
assertNotNull(r.getChangeTypes());
assertEquals(r.getChangeTypes(), changeTypes);
assertFalse(r.continueOnMissingChanges());
assertNotNull(r.getPareEntriesForUserDN());
assertEquals(new DN(r.getPareEntriesForUserDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(r.getChangeSelectionCriteria());
assertFalse(r.includeSoftDeletedEntryMods());
assertFalse(r.includeSoftDeletedEntryDeletes());
assertNotNull(r.getExtendedRequestName());
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ChangeType in project ldapsdk by pingidentity.
the class GetChangelogBatchExtendedRequestTestCase method testMostConstructorWithoutListener.
/**
* Provides test coverage for the constructor which may be used to create an
* instance of this extended request using a full set of information and
* doesn't take an entry listener.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testMostConstructorWithoutListener() throws Exception {
final List<String> includeBases = Arrays.asList("dc=example,dc=com", "o=example.com");
final List<String> excludeBases = Arrays.asList("ou=People,dc=example,dc=com", "ou=Groups,ec=example,dc=com");
final EnumSet<ChangeType> changeTypes = EnumSet.of(ChangeType.MODIFY);
GetChangelogBatchExtendedRequest r = new GetChangelogBatchExtendedRequest(null, new EndOfChangelogStartingPoint(), -1, 0L, false, includeBases, excludeBases, changeTypes, true, new Control("1.2.3.4"), new Control("5.6.7.8"));
assertNull(r.getEntryListener());
r = new GetChangelogBatchExtendedRequest(r);
r = r.duplicate();
assertNotNull(r);
assertNotNull(r.getStartingPoint());
assertTrue(r.getStartingPoint() instanceof EndOfChangelogStartingPoint);
assertEquals(r.getMaxChanges(), 0);
assertEquals(r.getMaxWaitTimeMillis(), 0L);
assertFalse(r.waitForMaxChanges());
assertNotNull(r.getIncludeBaseDNs());
assertEquals(r.getIncludeBaseDNs(), includeBases);
assertNotNull(r.getExcludeBaseDNs());
assertEquals(r.getExcludeBaseDNs(), excludeBases);
assertNotNull(r.getChangeTypes());
assertEquals(r.getChangeTypes(), changeTypes);
assertTrue(r.continueOnMissingChanges());
assertNull(r.getPareEntriesForUserDN());
assertNull(r.getChangeSelectionCriteria());
assertFalse(r.includeSoftDeletedEntryMods());
assertFalse(r.includeSoftDeletedEntryDeletes());
assertNotNull(r.getExtendedRequestName());
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ChangeType in project ldapsdk by pingidentity.
the class GetChangelogBatchExtendedRequestTestCase method testFullConstructorWithoutListener.
/**
* Provides test coverage for the constructor which may be used to create an
* instance of this extended request using a full set of information and a
* {@code null} entry listener.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testFullConstructorWithoutListener() throws Exception {
final List<String> includeBases = Arrays.asList("dc=example,dc=com");
final List<String> excludeBases = Arrays.asList("ou=People,dc=example,dc=com");
final EnumSet<ChangeType> changeTypes = EnumSet.of(ChangeType.ADD, ChangeType.DELETE, ChangeType.MODIFY_DN);
GetChangelogBatchExtendedRequest r = new GetChangelogBatchExtendedRequest(null, new EndOfChangelogStartingPoint(), -1, -1L, true, includeBases, excludeBases, changeTypes, false, "uid=test.user,ou=People,dc=example,dc=com", new IgnoreAttributesChangeSelectionCriteria(true), true, false, new Control("1.2.3.4"));
assertNull(r.getEntryListener());
r = new GetChangelogBatchExtendedRequest(r);
r = r.duplicate();
assertNotNull(r);
assertNotNull(r.getStartingPoint());
assertTrue(r.getStartingPoint() instanceof EndOfChangelogStartingPoint);
assertEquals(r.getMaxChanges(), 0);
assertEquals(r.getMaxWaitTimeMillis(), 0L);
assertTrue(r.waitForMaxChanges());
assertNotNull(r.getIncludeBaseDNs());
assertEquals(r.getIncludeBaseDNs(), includeBases);
assertNotNull(r.getExcludeBaseDNs());
assertEquals(r.getExcludeBaseDNs(), excludeBases);
assertNotNull(r.getChangeTypes());
assertEquals(r.getChangeTypes(), changeTypes);
assertFalse(r.continueOnMissingChanges());
assertNotNull(r.getPareEntriesForUserDN());
assertEquals(new DN(r.getPareEntriesForUserDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(r.getChangeSelectionCriteria());
assertTrue(r.includeSoftDeletedEntryMods());
assertFalse(r.includeSoftDeletedEntryDeletes());
assertNotNull(r.getExtendedRequestName());
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ChangeType in project ldapsdk by pingidentity.
the class ExcludeChangeTypeTransformationTestCase method testExcludeNullSet.
/**
* Tests the behavior when the set of change types to exclude is
* {@code null}}.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExcludeNullSet() throws Exception {
final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation((ChangeType[]) null);
final LDIFAddChangeRecord addChangeRecord = new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
assertNotNull(t.transformChangeRecord(addChangeRecord));
assertEquals(t.transformChangeRecord(addChangeRecord), addChangeRecord);
assertNotNull(t.translate(addChangeRecord, 0));
assertEquals(t.translate(addChangeRecord, 0), addChangeRecord);
assertNotNull(t.translateChangeRecordToWrite(addChangeRecord));
assertEquals(t.translateChangeRecordToWrite(addChangeRecord), addChangeRecord);
final LDIFDeleteChangeRecord deleteChangeRecord = new LDIFDeleteChangeRecord("dc=example,dc=com");
assertNotNull(t.transformChangeRecord(deleteChangeRecord));
assertEquals(t.transformChangeRecord(deleteChangeRecord), deleteChangeRecord);
assertNotNull(t.translate(deleteChangeRecord, 0));
assertEquals(t.translate(deleteChangeRecord, 0), deleteChangeRecord);
assertNotNull(t.translateChangeRecordToWrite(deleteChangeRecord));
assertEquals(t.translateChangeRecordToWrite(deleteChangeRecord), deleteChangeRecord);
final LDIFModifyChangeRecord modifyChangeRecord = new LDIFModifyChangeRecord(new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: foo"));
assertNotNull(t.transformChangeRecord(modifyChangeRecord));
assertEquals(t.transformChangeRecord(modifyChangeRecord), modifyChangeRecord);
assertNotNull(t.translate(modifyChangeRecord, 0));
assertEquals(t.translate(modifyChangeRecord, 0), modifyChangeRecord);
assertNotNull(t.translateChangeRecordToWrite(modifyChangeRecord));
assertEquals(t.translateChangeRecordToWrite(modifyChangeRecord), modifyChangeRecord);
final LDIFModifyDNChangeRecord modifyDNChangeRecord = new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, null);
assertNotNull(t.transformChangeRecord(modifyDNChangeRecord));
assertEquals(t.transformChangeRecord(modifyDNChangeRecord), modifyDNChangeRecord);
assertNotNull(t.translate(modifyDNChangeRecord, 0));
assertEquals(t.translate(modifyDNChangeRecord, 0), modifyDNChangeRecord);
assertNotNull(t.translateChangeRecordToWrite(modifyDNChangeRecord));
assertEquals(t.translateChangeRecordToWrite(modifyDNChangeRecord), modifyDNChangeRecord);
}
use of com.unboundid.ldap.sdk.ChangeType in project ldapsdk by pingidentity.
the class GetChangelogBatchExtendedRequest method encodeValue.
/**
* Encodes the value for this extended request using the provided information.
*
* @param startingPoint An object which indicates the
* starting point for the batch of
* changes to retrieve. It must not
* be {@code null}.
* @param maxChanges The maximum number of changes that
* should be retrieved before the
* server should return the
* corresponding extended result. A
* value less than or equal to zero
* may be used to indicate that the
* server should not return any
* entries but should just return a
* result containing a token which
* represents the starting point.
* @param maxWaitTimeMillis The maximum length of time in
* milliseconds to wait for changes.
* A value less than or equal to zero
* indicates that there should not be
* any wait and the result should be
* returned as soon as all
* immediately-available changes (up
* to the specified maximum count)
* have been returned.
* @param waitForMaxChanges Indicates whether the server should
* wait for up to the maximum length
* of time for up to the maximum
* number of changes to be returned.
* If this is {@code false}, then the
* result will be returned as soon as
* any changes are available (after
* sending those changes), even if the
* number of available changes is less
* than {@code maxChanges}.
* Otherwise, the result will not be
* returned until either the maximum
* number of changes have been
* returned or the maximum wait time
* has elapsed.
* @param includeBaseDNs A list of base DNs for entries to
* include in the set of changes to be
* returned.
* @param excludeBaseDNs A list of base DNs for entries to
* exclude from the set of changes to
* be returned.
* @param changeTypes The types of changes that should be
* returned. If this is {@code null}
* or empty, then all change types
* will be included.
* @param continueOnMissingChanges Indicates whether the server should
* make a best-effort attempt to
* return changes even if the starting
* point represents a point that is
* before the first available change
* in the changelog and therefore the
* results returned may be missing
* changes.
* @param pareEntriesForUserDN The DN of a user for whom to pare
* down the contents of changelog
* entries based on the access control
* and sensitive attribute
* restrictions defined for that user.
* It may be {@code null} if changelog
* entries should not be pared down
* for any user, an empty string if
* changelog entries should be pared
* down to what is available to
* anonymous users, or a user DN to
* pare down entries for the specified
* user.
* @param changeSelectionCriteria The optional criteria to use to
* pare down the changelog entries
* that should be returned. It may be
* {@code null} if all changelog
* entries should be returned.
* @param includeSoftDeletedEntryMods Indicates whether to include
* changelog entries that represent
* changes to soft-deleted entries.
* @param includeSoftDeletedEntryDeletes Indicates whether to include
* changelog entries that represent
* deletes of soft-deleted entries.
*
* @return The value for the extended request.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final ChangelogBatchStartingPoint startingPoint, final int maxChanges, final long maxWaitTimeMillis, final boolean waitForMaxChanges, @Nullable final List<String> includeBaseDNs, @Nullable final List<String> excludeBaseDNs, @Nullable final Set<ChangeType> changeTypes, final boolean continueOnMissingChanges, @Nullable final String pareEntriesForUserDN, @Nullable final ChangelogBatchChangeSelectionCriteria changeSelectionCriteria, final boolean includeSoftDeletedEntryMods, final boolean includeSoftDeletedEntryDeletes) {
Validator.ensureNotNull(startingPoint);
final ArrayList<ASN1Element> elements = new ArrayList<>(12);
elements.add(startingPoint.encode());
if (maxChanges > 0) {
elements.add(new ASN1Integer(maxChanges));
} else {
elements.add(new ASN1Integer(0));
}
if (maxWaitTimeMillis > 0L) {
elements.add(new ASN1Long(TYPE_MAX_TIME, maxWaitTimeMillis));
}
if (waitForMaxChanges) {
elements.add(new ASN1Boolean(TYPE_WAIT_FOR_MAX_CHANGES, true));
}
if ((includeBaseDNs != null) && (!includeBaseDNs.isEmpty())) {
final ArrayList<ASN1Element> l = new ArrayList<>(includeBaseDNs.size());
for (final String s : includeBaseDNs) {
l.add(new ASN1OctetString(s));
}
elements.add(new ASN1Sequence(TYPE_INCLUDE_BASE, l));
}
if ((excludeBaseDNs != null) && (!excludeBaseDNs.isEmpty())) {
final ArrayList<ASN1Element> l = new ArrayList<>(excludeBaseDNs.size());
for (final String s : excludeBaseDNs) {
l.add(new ASN1OctetString(s));
}
elements.add(new ASN1Sequence(TYPE_EXCLUDE_BASE, l));
}
if ((changeTypes != null) && (!changeTypes.isEmpty()) && (!changeTypes.equals(EnumSet.allOf(ChangeType.class)))) {
final ArrayList<ASN1Element> l = new ArrayList<>(changeTypes.size());
for (final ChangeType t : changeTypes) {
switch(t) {
case ADD:
l.add(new ASN1Enumerated(CHANGE_TYPE_ADD));
break;
case DELETE:
l.add(new ASN1Enumerated(CHANGE_TYPE_DELETE));
break;
case MODIFY:
l.add(new ASN1Enumerated(CHANGE_TYPE_MODIFY));
break;
case MODIFY_DN:
l.add(new ASN1Enumerated(CHANGE_TYPE_MODIFY_DN));
break;
}
}
elements.add(new ASN1Set(TYPE_CHANGE_TYPES, l));
}
if (continueOnMissingChanges) {
elements.add(new ASN1Boolean(TYPE_CONTINUE_ON_MISSING_CHANGES, true));
}
if (pareEntriesForUserDN != null) {
elements.add(new ASN1OctetString(TYPE_PARE_ENTRIES_FOR_USER_DN, pareEntriesForUserDN));
}
if (changeSelectionCriteria != null) {
elements.add(changeSelectionCriteria.encode());
}
if (includeSoftDeletedEntryMods) {
elements.add(new ASN1Boolean(TYPE_INCLUDE_SOFT_DELETED_ENTRY_MODS, true));
}
if (includeSoftDeletedEntryDeletes) {
elements.add(new ASN1Boolean(TYPE_INCLUDE_SOFT_DELETED_ENTRY_DELETES, true));
}
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Aggregations