use of org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent in project syncope by apache.
the class JPAGroupDAO method delete.
@Override
public void delete(final Group group) {
dynRealmDAO().removeDynMemberships(group.getKey());
findAMemberships(group).forEach(membership -> {
AnyObject leftEnd = membership.getLeftEnd();
leftEnd.getMemberships().remove(membership);
membership.setRightEnd(null);
leftEnd.getPlainAttrs(membership).stream().map(attr -> {
leftEnd.remove(attr);
attr.setOwner(null);
attr.setMembership(null);
return attr;
}).forEachOrdered(attr -> plainAttrDAO.delete(attr));
anyObjectDAO().save(leftEnd);
publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, leftEnd, AuthContextUtils.getDomain()));
});
findUMemberships(group).forEach(membership -> {
User leftEnd = membership.getLeftEnd();
leftEnd.getMemberships().remove(membership);
membership.setRightEnd(null);
leftEnd.getPlainAttrs(membership).stream().map(attr -> {
leftEnd.remove(attr);
attr.setOwner(null);
attr.setMembership(null);
return attr;
}).forEachOrdered(attr -> plainAttrDAO.delete(attr));
userDAO().save(leftEnd);
publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, leftEnd, AuthContextUtils.getDomain()));
});
clearUDynMembers(group);
clearADynMembers(group);
entityManager().remove(group);
publisher.publishEvent(new AnyDeletedEvent(this, AnyTypeKind.GROUP, group.getKey(), AuthContextUtils.getDomain()));
}
use of org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent in project syncope by apache.
the class JPAUserDAO method delete.
@Override
public void delete(final User user) {
roleDAO.removeDynMemberships(user.getKey());
groupDAO().removeDynMemberships(user);
dynRealmDAO().removeDynMemberships(user.getKey());
AccessToken accessToken = accessTokenDAO.findByOwner(user.getUsername());
if (accessToken != null) {
accessTokenDAO.delete(accessToken);
}
entityManager().remove(user);
publisher.publishEvent(new AnyDeletedEvent(this, AnyTypeKind.USER, user.getKey(), AuthContextUtils.getDomain()));
}
use of org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent in project syncope by apache.
the class JPAAnyObjectDAO method delete.
@Override
public void delete(final AnyObject anyObject) {
groupDAO().removeDynMemberships(anyObject);
dynRealmDAO().removeDynMemberships(anyObject.getKey());
findARelationships(anyObject).forEach(relationship -> {
relationship.getLeftEnd().getRelationships().remove(relationship);
save(relationship.getLeftEnd());
entityManager().remove(relationship);
});
findURelationships(anyObject).forEach(relationship -> {
relationship.getLeftEnd().getRelationships().remove(relationship);
userDAO().save(relationship.getLeftEnd());
entityManager().remove(relationship);
});
entityManager().remove(anyObject);
publisher.publishEvent(new AnyDeletedEvent(this, AnyTypeKind.ANY_OBJECT, anyObject.getKey(), AuthContextUtils.getDomain()));
}
Aggregations