use of com.evolveum.midpoint.schema.processor.ResourceAttribute in project midpoint by Evolveum.
the class ObjectAlreadyExistHandler method createQueryBySecondaryIdentifier.
protected static ObjectQuery createQueryBySecondaryIdentifier(ShadowType shadow, PrismContext prismContext) {
// TODO ensure that the identifiers are normalized here
// Note that if the query is to be used against the repository, we should not provide matching rules here. See MID-5547.
Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow);
S_AtomicFilterEntry q = prismContext.queryFor(ShadowType.class);
q = q.block();
if (secondaryIdentifiers.isEmpty()) {
for (ResourceAttribute<?> primaryIdentifier : ShadowUtil.getPrimaryIdentifiers(shadow)) {
q = q.itemAs(primaryIdentifier).or();
}
} else {
// secondary identifiers connected by 'or' clause
for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) {
q = q.itemAs(secondaryIdentifier).or();
}
}
q = q.none().endBlock().and();
// resource + object class
q = q.item(ShadowType.F_RESOURCE_REF).ref(shadow.getResourceRef().getOid()).and();
return q.item(ShadowType.F_OBJECT_CLASS).eq(shadow.getObjectClass()).build();
}
use of com.evolveum.midpoint.schema.processor.ResourceAttribute in project midpoint by Evolveum.
the class AbstractEDirTest method test200AssignAccountBarbossa.
@Test
public void test200AssignAccountBarbossa() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
long tsStart = System.currentTimeMillis();
// WHEN
when();
assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result);
// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
long tsEnd = System.currentTimeMillis();
Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
assertAttribute(entry, "title", null);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
String shadowOid = getSingleLinkOid(user);
PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
display("Shadow (model)", shadow);
accountBarbossaOid = shadow.getOid();
Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow);
String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue();
assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid);
assertEquals("Wrong ICFS UID", MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes()), accountBarbossaIcfUid);
assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD);
assertPasswordAllowChange(shadow, null);
ResourceAttribute<Long> createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimestamp"));
assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute);
Long createTimestamp = createTimestampAttribute.getRealValue();
// LDAP server may be on a different host. Allow for some clock offset.
TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 1000, roundTsUp(tsEnd) + 1000, createTimestamp);
}
Aggregations