use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SCIMFilterTest method sw.
@Test
public void sw() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "userName sw \"J\"");
assertNotNull(cond);
assertNotNull(cond.getAnyCond());
assertEquals("username", cond.getAnyCond().getSchema());
assertEquals(AttributeCond.Type.ILIKE, cond.getAnyCond().getType());
assertEquals("J%", cond.getAnyCond().getExpression());
SearchCond fqn = SearchCondConverter.convert(VISITOR, "urn:ietf:params:scim:schemas:core:2.0:User:userName sw \"J\"");
assertEquals(cond, fqn);
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SCIMFilterTest method not.
@Test
public void not() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "not (title pr)");
assertNotNull(cond);
assertNotNull(cond.getAttributeCond());
assertEquals("title", cond.getAttributeCond().getSchema());
assertEquals(AttributeCond.Type.ISNULL, cond.getAttributeCond().getType());
assertNull(cond.getAttributeCond().getExpression());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class SCIMFilterTest method or.
@Test
public void or() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "title pr or displayName eq \"Other\"");
assertNotNull(cond);
assertEquals(SearchCond.Type.OR, cond.getType());
SearchCond left = cond.getLeftSearchCond();
assertNotNull(left);
assertNotNull(left.getAttributeCond());
assertEquals("title", left.getAttributeCond().getSchema());
assertEquals(AttributeCond.Type.ISNOTNULL, left.getAttributeCond().getType());
assertNull(left.getAttributeCond().getExpression());
SearchCond right = cond.getRightSearchCond();
assertNotNull(right);
assertNotNull(right.getAttributeCond());
assertEquals("cn", right.getAttributeCond().getSchema());
assertEquals(AttributeCond.Type.IEQ, right.getAttributeCond().getType());
assertEquals("Other", right.getAttributeCond().getExpression());
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class DefaultRealmPullResultHandler method delete.
private List<ProvisioningReport> delete(final SyncDelta delta, final List<String> keys) throws JobExecutionException {
if (!profile.getTask().isPerformDelete()) {
LOG.debug("PullTask not configured for delete");
finalize(ResourceOperation.DELETE.name().toLowerCase(), Result.SUCCESS, null, null, delta);
return Collections.<ProvisioningReport>emptyList();
}
LOG.debug("About to delete {}", keys);
List<ProvisioningReport> results = new ArrayList<>();
for (String key : keys) {
Object output;
Result resultStatus = Result.FAILURE;
ProvisioningReport result = new ProvisioningReport();
try {
result.setKey(key);
result.setOperation(ResourceOperation.DELETE);
result.setAnyType(REALM_TYPE);
result.setStatus(ProvisioningReport.Status.SUCCESS);
Realm realm = realmDAO.find(key);
RealmTO before = binder.getRealmTO(realm, true);
if (before == null) {
result.setStatus(ProvisioningReport.Status.FAILURE);
result.setMessage(String.format("Realm '%s' not found", key));
} else {
result.setName(before.getFullPath());
}
if (!profile.isDryRun()) {
for (PullActions action : profile.getActions()) {
action.beforeDelete(profile, delta, before);
}
try {
if (!realmDAO.findChildren(realm).isEmpty()) {
throw SyncopeClientException.build(ClientExceptionType.HasChildren);
}
Set<String> adminRealms = Collections.singleton(realm.getFullPath());
AnyCond keyCond = new AnyCond(AttributeCond.Type.ISNOTNULL);
keyCond.setSchema("key");
SearchCond allMatchingCond = SearchCond.getLeafCond(keyCond);
int users = searchDAO.count(adminRealms, allMatchingCond, AnyTypeKind.USER);
int groups = searchDAO.count(adminRealms, allMatchingCond, AnyTypeKind.GROUP);
int anyObjects = searchDAO.count(adminRealms, allMatchingCond, AnyTypeKind.ANY_OBJECT);
if (users + groups + anyObjects > 0) {
SyncopeClientException containedAnys = SyncopeClientException.build(ClientExceptionType.AssociatedAnys);
containedAnys.getElements().add(users + " user(s)");
containedAnys.getElements().add(groups + " group(s)");
containedAnys.getElements().add(anyObjects + " anyObject(s)");
throw containedAnys;
}
PropagationByResource propByRes = new PropagationByResource();
for (String resource : realm.getResourceKeys()) {
propByRes.add(ResourceOperation.DELETE, resource);
}
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
taskExecutor.execute(tasks, false);
realmDAO.delete(realm);
output = null;
resultStatus = Result.SUCCESS;
for (PullActions action : profile.getActions()) {
action.after(profile, delta, before, result);
}
} catch (Exception e) {
throwIgnoreProvisionException(delta, e);
result.setStatus(ProvisioningReport.Status.FAILURE);
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
LOG.error("Could not delete {}", realm, e);
output = e;
}
finalize(ResourceOperation.DELETE.name().toLowerCase(), resultStatus, before, output, delta);
}
results.add(result);
} catch (DelegatedAdministrationException e) {
LOG.error("Not allowed to read Realm {}", key, e);
} catch (Exception e) {
LOG.error("Could not delete Realm {}", key, e);
}
}
return results;
}
use of org.apache.syncope.core.persistence.api.dao.search.SearchCond in project syncope by apache.
the class RoleDataBinderImpl method setDynMembership.
private void setDynMembership(final Role role, final String dynMembershipFIQL) {
SearchCond dynMembershipCond = SearchCondConverter.convert(dynMembershipFIQL);
if (!dynMembershipCond.isValid()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchExpression);
sce.getElements().add(dynMembershipFIQL);
throw sce;
}
DynRoleMembership dynMembership;
if (role.getDynMembership() == null) {
dynMembership = entityFactory.newEntity(DynRoleMembership.class);
dynMembership.setRole(role);
role.setDynMembership(dynMembership);
} else {
dynMembership = role.getDynMembership();
}
dynMembership.setFIQLCond(dynMembershipFIQL);
}
Aggregations