Search in sources :

Example 31 with WorkflowResult

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

the class DefaultUserWorkflowAdapter method doActivate.

@Override
protected WorkflowResult<String> doActivate(final User user, final String token) {
    if (!user.checkToken(token)) {
        throw new WorkflowException(new IllegalArgumentException("Wrong token: " + token + " for " + user));
    }
    user.removeToken();
    user.setStatus("active");
    User updated = userDAO.save(user);
    return new WorkflowResult<>(updated.getKey(), null, "activate");
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User) WorkflowException(org.apache.syncope.core.workflow.api.WorkflowException)

Example 32 with WorkflowResult

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

the class DefaultUserWorkflowAdapter method doCreate.

@Override
protected WorkflowResult<Pair<String, Boolean>> doCreate(final UserTO userTO, final boolean disablePwdPolicyCheck, final Boolean enabled, final boolean storePassword) {
    User user = entityFactory.newEntity(User.class);
    dataBinder.create(user, userTO, storePassword);
    // this will make UserValidator not to consider password policies at all
    if (disablePwdPolicyCheck) {
        user.removeClearPassword();
    }
    String status;
    boolean propagateEnable;
    if (enabled == null) {
        status = "created";
        propagateEnable = true;
    } else {
        status = enabled ? "active" : "suspended";
        propagateEnable = enabled;
        user.setSuspended(!enabled);
    }
    user.setStatus(status);
    user = userDAO.save(user);
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
    return new WorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, "create");
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource)

Aggregations

WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)32 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)18 User (org.apache.syncope.core.persistence.api.entity.user.User)14 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)11 Pair (org.apache.commons.lang3.tuple.Pair)8 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)8 HashMap (java.util.HashMap)7 PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)6 Exchange (org.apache.camel.Exchange)4 PollingConsumer (org.apache.camel.PollingConsumer)4 List (java.util.List)3 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)3 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)3 AttrTO (org.apache.syncope.common.lib.to.AttrTO)3 AnyObjectPatch (org.apache.syncope.common.lib.patch.AnyObjectPatch)2 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)2 GroupTO (org.apache.syncope.common.lib.to.GroupTO)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 WorkflowException (org.apache.syncope.core.workflow.api.WorkflowException)2 FlowableException (org.flowable.engine.common.api.FlowableException)2