public static ResourceAttribute<?> getSecondaryIdentifier(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> identifiers) throws SchemaException { if (identifiers == null) { return null; } ResourceAttribute<?> secondaryIdentifier = null; for (ResourceAttribute<?> identifier: identifiers) { if (identifier.getDefinition().isSecondaryIdentifier(objectClassDefinition)) { if (secondaryIdentifier != null) { throw new SchemaException("More than one secondary identifier in "+objectClassDefinition); } secondaryIdentifier = identifier; } } return secondaryIdentifier; }
public ResourceAttributeDefinitionAsserter<T,RA> assertIsSecondaryIdentifier() { assertNotNull("Cannot evaluate whether attribute is identifier because there is no objectClassDefinition set up in asserter", objectClassDefinition); assertTrue("Not a secondary identifier:" + desc(), getDefinition().isSecondaryIdentifier(objectClassDefinition)); return this; }
public ResourceAttributeDefinitionAsserter<T,RA> assertNotSecondaryIdentifier() { assertNotNull("Cannot evaluate whether attribute is identifier because there is no objectClassDefinition set up in asserter", objectClassDefinition); assertFalse("Secondary identifier but should not be:" + desc(), getDefinition().isSecondaryIdentifier(objectClassDefinition)); return this; }
new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME)); assertNotNull("No definition for attribute "+SchemaConstants.ICFS_NAME, idSecondaryDef); assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not secondary identifier",idSecondaryDef.isSecondaryIdentifier(accountDefinition)); assertFalse("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in in identifiers list and it should NOT be",identifiers.contains(idSecondaryDef)); assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not in secomdary identifiers list",accountDefinition.getSecondaryIdentifiers().contains(idSecondaryDef));
assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not an identifier",nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not in identifiers list",secondaryIdentifiers.contains(nameAttributeDefinition)); assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName());
assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not an identifier",nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not in identifiers list",secondaryIdentifiers.contains(nameAttributeDefinition)); assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_NAME, "Modified ConnId Name", nameAttributeDefinition.getDisplayName());