}
protected List<Long> findByAccountIdItem(final String uid, final AttributableUtil attrUtil) {
final List<Long> result = new ArrayList<Long>();
final AbstractMappingItem accountIdItem = attrUtil.getAccountIdItem(syncTask.getResource());
switch (accountIdItem.getIntMappingType()) {
case UserSchema:
case RoleSchema:
final AbstractAttrValue value = attrUtil.newAttrValue();
AbstractSchema schema = schemaDAO.find(accountIdItem.getIntAttrName(), attrUtil.schemaClass());
if (schema == null) {
value.setStringValue(uid);
} else {
try {
value.parseValue(schema, uid);
} catch (ParsingValidationException e) {
LOG.error("While parsing provided __UID__ {}", uid, e);
value.setStringValue(uid);
}
}
List<AbstractAttributable> subjects =
userDAO.findByAttrValue(accountIdItem.getIntAttrName(), value, attrUtil);
for (AbstractAttributable subject : subjects) {
result.add(subject.getId());
}
break;
case UserDerivedSchema:
case RoleDerivedSchema:
try {
subjects = userDAO.findByDerAttrValue(accountIdItem.getIntAttrName(), uid, attrUtil);
for (AbstractAttributable subject : subjects) {
result.add(subject.getId());
}
} catch (InvalidSearchConditionException e) {
LOG.error("Could not search for matching subjects", e);
}
break;
case Username:
SyncopeUser user = userDAO.find(uid);
if (user != null) {
result.add(user.getId());
}
break;
case UserId:
user = userDAO.find(Long.parseLong(uid));
if (user != null) {
result.add(user.getId());
}
break;
case RoleName:
List<SyncopeRole> roles = roleDAO.find(uid);
for (SyncopeRole role : roles) {
result.add(role.getId());
}
break;
case RoleId:
SyncopeRole role = roleDAO.find(Long.parseLong(uid));
if (role != null) {
result.add(role.getId());
}
break;
default:
LOG.error("Invalid accountId type '{}'", accountIdItem.getIntMappingType());
}
return result;
}