Search in sources :

Example 1 with PropagationByResource

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

the class FlowableUserWorkflowAdapter method doConfirmPasswordReset.

@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doConfirmPasswordReset(final User user, final String token, final String password) {
    Map<String, Object> variables = new HashMap<>(4);
    variables.put(TOKEN, token);
    variables.put(PASSWORD, password);
    variables.put(USER_TO, dataBinder.getUserTO(user, true));
    variables.put(EVENT, "confirmPasswordReset");
    Set<String> tasks = doExecuteTask(user, "confirmPasswordReset", variables);
    userDAO.save(user);
    PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
    UserPatch updatedPatch = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_PATCH, UserPatch.class);
    Boolean propagateEnable = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
    return new WorkflowResult<>(Pair.of(updatedPatch, propagateEnable), propByRes, tasks);
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) HashMap(java.util.HashMap) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 2 with PropagationByResource

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

the class FlowableUserWorkflowAdapter method doCreate.

@Override
protected WorkflowResult<Pair<String, Boolean>> doCreate(final UserTO userTO, final boolean disablePwdPolicyCheck, final Boolean enabled, final boolean storePassword) {
    Map<String, Object> variables = new HashMap<>();
    variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
    variables.put(USER_TO, userTO);
    variables.put(ENABLED, enabled);
    variables.put(STORE_PASSWORD, storePassword);
    ProcessInstance processInstance = null;
    try {
        processInstance = engine.getRuntimeService().startProcessInstanceByKey(WF_PROCESS_ID, variables);
    } catch (FlowableException e) {
        throwException(e, "While starting " + WF_PROCESS_ID + " instance");
    }
    User user = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), USER, User.class);
    Boolean updatedEnabled = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), ENABLED, Boolean.class);
    if (updatedEnabled != null) {
        user.setSuspended(!updatedEnabled);
    }
    // this will make UserValidator not to consider password policies at all
    if (disablePwdPolicyCheck) {
        user.removeClearPassword();
    }
    updateStatus(user);
    user = userDAO.save(user);
    Boolean propagateEnable = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), PROPAGATE_ENABLE, Boolean.class);
    if (propagateEnable == null) {
        propagateEnable = enabled;
    }
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
    saveForFormSubmit(user, userTO.getPassword(), propByRes);
    Set<String> tasks = getPerformedTasks(user);
    return new WorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, tasks);
}
Also used : FlowableException(org.flowable.engine.common.api.FlowableException) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User) HashMap(java.util.HashMap) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) ProcessInstance(org.flowable.engine.runtime.ProcessInstance)

Example 3 with PropagationByResource

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

the class FlowableUserWorkflowAdapter method doDelete.

@Override
protected void doDelete(final User user) {
    doExecuteTask(user, "delete", null);
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.DELETE, userDAO.findAllResourceKeys(user.getKey()));
    saveForFormSubmit(user, null, propByRes);
    if (engine.getRuntimeService().createProcessInstanceQuery().processInstanceId(user.getWorkflowId()).active().list().isEmpty()) {
        userDAO.delete(user.getKey());
        if (!engine.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(user.getWorkflowId()).list().isEmpty()) {
            engine.getHistoryService().deleteHistoricProcessInstance(user.getWorkflowId());
        }
    } else {
        updateStatus(user);
        userDAO.save(user);
    }
}
Also used : PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource)

Example 4 with PropagationByResource

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

the class Update method doExecute.

@Override
protected void doExecute(final String executionId) {
    User user = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
    UserPatch userPatch = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, UserPatch.class);
    user = userDAO.save(user);
    UserTO original = dataBinder.getUserTO(user, true);
    PropagationByResource propByRes = dataBinder.update(user, userPatch);
    PasswordPatch password = userPatch.getPassword();
    Set<AttrTO> virAttrs = userPatch.getVirAttrs();
    UserTO updated = dataBinder.getUserTO(user.getKey());
    userPatch = AnyOperations.diff(updated, original, false);
    userPatch.setPassword(password);
    userPatch.getVirAttrs().clear();
    userPatch.getVirAttrs().addAll(virAttrs);
    // report updated user and propagation by resource as result
    engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
    engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, updated);
    engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
    engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 5 with PropagationByResource

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

the class DefaultAnyObjectWorkflowAdapter method doUpdate.

@Override
protected WorkflowResult<AnyObjectPatch> doUpdate(final AnyObject anyObject, final AnyObjectPatch anyObjectPatch) {
    AnyObjectTO original = dataBinder.getAnyObjectTO(anyObject, true);
    PropagationByResource propByRes = dataBinder.update(anyObject, anyObjectPatch);
    Set<AttrTO> virAttrs = anyObjectPatch.getVirAttrs();
    AnyObjectTO updated = dataBinder.getAnyObjectTO(anyObjectDAO.save(anyObject), true);
    AnyObjectPatch effectivePatch = AnyOperations.diff(updated, original, false);
    effectivePatch.getVirAttrs().clear();
    effectivePatch.getVirAttrs().addAll(virAttrs);
    return new WorkflowResult<>(effectivePatch, propByRes, "update");
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch)

Aggregations

PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)56 PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)23 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)21 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)19 Realm (org.apache.syncope.core.persistence.api.entity.Realm)13 ArrayList (java.util.ArrayList)12 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)12 User (org.apache.syncope.core.persistence.api.entity.user.User)12 HashMap (java.util.HashMap)11 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)11 Transactional (org.springframework.transaction.annotation.Transactional)10 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)9 Pair (org.apache.commons.lang3.tuple.Pair)8 List (java.util.List)7 RealmTO (org.apache.syncope.common.lib.to.RealmTO)7 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)6 AttrTO (org.apache.syncope.common.lib.to.AttrTO)6