Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BASE-89] Add ANY_OBJECT special object class #110

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion dotnet/Framework/CommonObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,11 @@ public sealed class ObjectClass
/// </summary>
public static readonly String ALL_NAME = ObjectClassUtil.CreateSpecialName("ALL");
/// <summary>
/// This constant defines a specific {@link #getObjectClassValue value
/// of ObjectClass} that is reserved for <seealso cref="ObjectClass#ANY"/>
/// </summary
public static readonly String ANY_OBJECT_NAME = ObjectClassUtil.CreateSpecialName("ANY");
/// <summary>
/// Denotes an account based object.
/// </summary>
public static readonly ObjectClass ACCOUNT = new ObjectClass(ACCOUNT_NAME);
Expand All @@ -2379,6 +2384,11 @@ public sealed class ObjectClass
/// </para>
/// </summary>
public static readonly ObjectClass ALL = new ObjectClass(ALL_NAME);
/// <summary>
/// Denotes any other type based object.
/// I.e. a device
/// </summary>
public static readonly ObjectClass ANY_OBJECT = new ObjectClass(ANY_OBJECT_NAME);

private readonly String _type;

Expand Down Expand Up @@ -6050,4 +6060,4 @@ public static CultureInfo Instance
}
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,16 @@ private void checkAttribute(ObjectClass objectClass, String attrName, Uid uid, O
public void testGroupsPredAttribute() {
final ObjectClassInfo accountInfo = findOInfo(ObjectClass.ACCOUNT);
final ObjectClassInfo groupInfo = findOInfo(ObjectClass.GROUP);
final ObjectClassInfo anyObjectInfo = findOInfo(ObjectClass.ANY_OBJECT);

// run test only in case ACCOUNT and GROUP are supported and GROUPS is supported for ACCOUNT
if (accountInfo != null && groupInfo != null
if (accountInfo != null && groupInfo != null && anyObjectInfo != null
&& ConnectorHelper.isCRU(accountInfo, PredefinedAttributes.GROUPS_NAME)) {

Uid groupUid1 = null;
Uid groupUid2 = null;
Uid accountUid1 = null;
Uid anyObjectUid1 = null;
try {
// create 1st group
Set<Attribute> groupAttrs1 = ConnectorHelper.getCreateableAttributes(
Expand All @@ -723,6 +725,10 @@ public void testGroupsPredAttribute() {

accountUid1 = getConnectorFacade().create(ObjectClass.ACCOUNT, accountAttrs1, null);

Set<Attribute> anyObjectAttrs1 = ConnectorHelper.getCreateableAttributes(
getDataProvider(), anyObjectInfo, getTestName(), 0, true, false);
anyObjectUid1 = getConnectorFacade().create(ObjectClass.ANY_OBJECT, anyObjectAttrs1, null);

// build attributes to get
OperationOptionsBuilder oob = new OperationOptionsBuilder();
oob.setAttributesToGet(ConnectorHelper.getReadableAttributesNames(accountInfo));
Expand All @@ -732,6 +738,13 @@ public void testGroupsPredAttribute() {
ConnectorObject obj = getConnectorFacade().getObject(ObjectClass.ACCOUNT,
accountUid1, attrsToGet);

// get the any-object to make sure it exists now
oob = new OperationOptionsBuilder();
oob.setAttributesToGet(ConnectorHelper.getReadableAttributesNames(anyObjectInfo));
OperationOptions anyObjectAttrsToGet = oob.build();
ConnectorObject anyObj = getConnectorFacade().getObject(ObjectClass.ANY_OBJECT,
anyObjectUid1, anyObjectAttrsToGet);

// check that object was created properly
ConnectorHelper.checkObject(accountInfo, obj, accountAttrs1);

Expand Down Expand Up @@ -767,6 +780,8 @@ public void testGroupsPredAttribute() {
false, null);
ConnectorHelper.deleteObject(getConnectorFacade(), ObjectClass.ACCOUNT,
accountUid1, false, null);
ConnectorHelper.deleteObject(getConnectorFacade(), ObjectClass.ANY_OBJECT, anyObjectUid1,
false, null);
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public final class ObjectClass {
*/
public static final String ALL_NAME = createSpecialName("ALL");

/**
* This constant defines a specific {@linkplain #getObjectClassValue value
* of ObjectClass} that is reserved for {@link ObjectClass#ANY}.
*/
public static final String ANY_OBJECT_NAME = createSpecialName("ANY_OBJECT");

// =======================================================================
// Create only after all other static initializers
// =======================================================================
Expand Down Expand Up @@ -100,6 +106,11 @@ public final class ObjectClass {
*/
public static final ObjectClass ALL = new ObjectClass(ALL_NAME);

/**
* Represents an object that is <i>neither</i> an account <i>nor</i> a group
*/
public static final ObjectClass ANY_OBJECT = new ObjectClass(ANY_OBJECT_NAME);

private final String type;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ public void testHashCode() {
set.add(ObjectClass.ACCOUNT);
set.add(ObjectClass.GROUP);
set.add(ObjectClass.ACCOUNT);
assertEquals(2, set.size());
set.add(ObjectClass.ANY_OBJECT);
assertEquals(3, set.size());
assertTrue(set.contains(ObjectClass.ACCOUNT));
assertTrue(set.contains(ObjectClass.GROUP));
assertTrue(set.contains(ObjectClass.ANY_OBJECT));

// Test case-insensitivity
set = new HashSet<ObjectClass>();
Expand Down