Search in sources :

Example 1 with AnyDeletedEvent

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()));
}
Also used : AopUtils(org.springframework.aop.support.AopUtils) Date(java.util.Date) Realm(org.apache.syncope.core.persistence.api.entity.Realm) NoResultException(javax.persistence.NoResultException) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) Entity(org.apache.syncope.core.persistence.api.entity.Entity) AnyDeletedEvent(org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent) AssignableCond(org.apache.syncope.core.persistence.api.dao.search.AssignableCond) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) AnyCreatedUpdatedEvent(org.apache.syncope.core.provisioning.api.event.AnyCreatedUpdatedEvent) JPAGroup(org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup) GroupDAO(org.apache.syncope.core.persistence.api.dao.GroupDAO) Pair(org.apache.commons.lang3.tuple.Pair) AnyObjectDAO(org.apache.syncope.core.persistence.api.dao.AnyObjectDAO) Map(java.util.Map) AuthContextUtils(org.apache.syncope.core.spring.security.AuthContextUtils) JPATypeExtension(org.apache.syncope.core.persistence.jpa.entity.group.JPATypeExtension) JPAUMembership(org.apache.syncope.core.persistence.jpa.entity.user.JPAUMembership) Repository(org.springframework.stereotype.Repository) JPAADynGroupMembership(org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAADynGroupMembership) AnyTypeClass(org.apache.syncope.core.persistence.api.entity.AnyTypeClass) JPAAMembership(org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAMembership) TypeExtension(org.apache.syncope.core.persistence.api.entity.group.TypeExtension) UserDAO(org.apache.syncope.core.persistence.api.dao.UserDAO) Collection(java.util.Collection) AMembership(org.apache.syncope.core.persistence.api.entity.anyobject.AMembership) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Query(javax.persistence.Query) Group(org.apache.syncope.core.persistence.api.entity.group.Group) StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) AnySearchDAO(org.apache.syncope.core.persistence.api.dao.AnySearchDAO) UDynGroupMembership(org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) TypedQuery(javax.persistence.TypedQuery) JPAAnyUtilsFactory(org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) RealmUtils(org.apache.syncope.core.provisioning.api.utils.RealmUtils) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) SearchCondConverter(org.apache.syncope.core.persistence.api.search.SearchCondConverter) UMembership(org.apache.syncope.core.persistence.api.entity.user.UMembership) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) User(org.apache.syncope.core.persistence.api.entity.user.User) ADynGroupMembership(org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership) JPAUDynGroupMembership(org.apache.syncope.core.persistence.jpa.entity.user.JPAUDynGroupMembership) AnyDAO(org.apache.syncope.core.persistence.api.dao.AnyDAO) AnyUtils(org.apache.syncope.core.persistence.api.entity.AnyUtils) ApplicationContextProvider(org.apache.syncope.core.spring.ApplicationContextProvider) Collections(java.util.Collections) PlainAttrDAO(org.apache.syncope.core.persistence.api.dao.PlainAttrDAO) Transactional(org.springframework.transaction.annotation.Transactional) AnyDeletedEvent(org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent) AnyObject(org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject) User(org.apache.syncope.core.persistence.api.entity.user.User)

Example 2 with AnyDeletedEvent

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()));
}
Also used : AnyDeletedEvent(org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent) AccessToken(org.apache.syncope.core.persistence.api.entity.AccessToken)

Example 3 with AnyDeletedEvent

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()));
}
Also used : AnyDeletedEvent(org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent)

Aggregations

AnyDeletedEvent (org.apache.syncope.core.provisioning.api.event.AnyDeletedEvent)3 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 Pair (org.apache.commons.lang3.tuple.Pair)1 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)1 StandardEntitlement (org.apache.syncope.common.lib.types.StandardEntitlement)1 AnyDAO (org.apache.syncope.core.persistence.api.dao.AnyDAO)1 AnyObjectDAO (org.apache.syncope.core.persistence.api.dao.AnyObjectDAO)1 AnySearchDAO (org.apache.syncope.core.persistence.api.dao.AnySearchDAO)1 GroupDAO (org.apache.syncope.core.persistence.api.dao.GroupDAO)1