Search in sources :

Example 1 with LogicActions

use of org.apache.syncope.core.provisioning.api.LogicActions in project syncope by apache.

the class AbstractAnyLogic method beforeUpdate.

protected Pair<P, List<LogicActions>> beforeUpdate(final P input, final String realmPath) {
    Realm realm = realmDAO.findByFullPath(realmPath);
    if (realm == null) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm);
        sce.getElements().add(realmPath);
        throw sce;
    }
    P mod = input;
    List<LogicActions> actions = getActions(realm);
    for (LogicActions action : actions) {
        mod = action.beforeUpdate(mod);
    }
    LOG.debug("Input: {}\nOutput: {}\n", input, mod);
    return ImmutablePair.of(mod, actions);
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Realm(org.apache.syncope.core.persistence.api.entity.Realm) LogicActions(org.apache.syncope.core.provisioning.api.LogicActions)

Example 2 with LogicActions

use of org.apache.syncope.core.provisioning.api.LogicActions in project syncope by apache.

the class AbstractAnyLogic method beforeCreate.

protected Pair<TO, List<LogicActions>> beforeCreate(final TO input) {
    Realm realm = realmDAO.findByFullPath(input.getRealm());
    if (realm == null) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm);
        sce.getElements().add(input.getRealm());
        throw sce;
    }
    AnyType anyType = input instanceof UserTO ? anyTypeDAO.findUser() : input instanceof GroupTO ? anyTypeDAO.findGroup() : anyTypeDAO.find(input.getType());
    if (anyType == null) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType);
        sce.getElements().add(input.getType());
        throw sce;
    }
    TO any = input;
    templateUtils.apply(any, realm.getTemplate(anyType));
    List<LogicActions> actions = getActions(realm);
    for (LogicActions action : actions) {
        any = action.beforeCreate(any);
    }
    LOG.debug("Input: {}\nOutput: {}\n", input, any);
    return ImmutablePair.of(any, actions);
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTO(org.apache.syncope.common.lib.to.AnyTO) GroupTO(org.apache.syncope.common.lib.to.GroupTO) UserTO(org.apache.syncope.common.lib.to.UserTO) Realm(org.apache.syncope.core.persistence.api.entity.Realm) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType) LogicActions(org.apache.syncope.core.provisioning.api.LogicActions) GroupTO(org.apache.syncope.common.lib.to.GroupTO)

Example 3 with LogicActions

use of org.apache.syncope.core.provisioning.api.LogicActions in project syncope by apache.

the class AbstractAnyLogic method afterDelete.

protected ProvisioningResult<TO> afterDelete(final TO input, final List<PropagationStatus> statuses, final List<LogicActions> actions) {
    TO any = input;
    for (LogicActions action : actions) {
        any = action.afterDelete(any);
    }
    ProvisioningResult<TO> result = new ProvisioningResult<>();
    result.setEntity(any);
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) AnyTO(org.apache.syncope.common.lib.to.AnyTO) GroupTO(org.apache.syncope.common.lib.to.GroupTO) UserTO(org.apache.syncope.common.lib.to.UserTO) LogicActions(org.apache.syncope.core.provisioning.api.LogicActions)

Example 4 with LogicActions

use of org.apache.syncope.core.provisioning.api.LogicActions in project syncope by apache.

the class AbstractAnyLogic method afterUpdate.

protected ProvisioningResult<TO> afterUpdate(final TO input, final List<PropagationStatus> statuses, final List<LogicActions> actions, final boolean authDynRealms, final Set<String> dynRealmsBefore) {
    Set<String> dynRealmsAfter = new HashSet<>(input.getDynRealms());
    if (authDynRealms && !dynRealmsBefore.equals(dynRealmsAfter)) {
        throw new DelegatedAdministrationException(this instanceof UserLogic ? AnyTypeKind.USER : this instanceof GroupLogic ? AnyTypeKind.GROUP : AnyTypeKind.ANY_OBJECT, input.getKey());
    }
    TO any = input;
    for (LogicActions action : actions) {
        any = action.afterUpdate(any);
    }
    ProvisioningResult<TO> result = new ProvisioningResult<>();
    result.setEntity(any);
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) AnyTO(org.apache.syncope.common.lib.to.AnyTO) GroupTO(org.apache.syncope.common.lib.to.GroupTO) UserTO(org.apache.syncope.common.lib.to.UserTO) LogicActions(org.apache.syncope.core.provisioning.api.LogicActions) HashSet(java.util.HashSet)

Example 5 with LogicActions

use of org.apache.syncope.core.provisioning.api.LogicActions in project syncope by apache.

the class AbstractAnyLogic method beforeDelete.

protected Pair<TO, List<LogicActions>> beforeDelete(final TO input) {
    Realm realm = realmDAO.findByFullPath(input.getRealm());
    if (realm == null) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm);
        sce.getElements().add(input.getRealm());
        throw sce;
    }
    TO any = input;
    List<LogicActions> actions = getActions(realm);
    for (LogicActions action : actions) {
        any = action.beforeDelete(any);
    }
    LOG.debug("Input: {}\nOutput: {}\n", input, any);
    return ImmutablePair.of(any, actions);
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTO(org.apache.syncope.common.lib.to.AnyTO) GroupTO(org.apache.syncope.common.lib.to.GroupTO) UserTO(org.apache.syncope.common.lib.to.UserTO) Realm(org.apache.syncope.core.persistence.api.entity.Realm) LogicActions(org.apache.syncope.core.provisioning.api.LogicActions)

Aggregations

LogicActions (org.apache.syncope.core.provisioning.api.LogicActions)6 AnyTO (org.apache.syncope.common.lib.to.AnyTO)5 GroupTO (org.apache.syncope.common.lib.to.GroupTO)5 UserTO (org.apache.syncope.common.lib.to.UserTO)5 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)3 Realm (org.apache.syncope.core.persistence.api.entity.Realm)3 HashSet (java.util.HashSet)1 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)1 DelegatedAdministrationException (org.apache.syncope.core.spring.security.DelegatedAdministrationException)1