use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method update.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<UserPatch, List<PropagationStatus>> update(final UserPatch userPatch, final ProvisioningReport result, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:updateInPullPort");
Map<String, Object> props = new HashMap<>();
props.put("key", userPatch.getKey());
props.put("result", result);
props.put("enabled", enabled);
props.put("excludedResources", excludedResources);
props.put("nullPriorityAsync", nullPriorityAsync);
sendMessage("direct:updateUserInPull", userPatch, props);
Exchange exchange = pollingConsumer.receive();
Exception ex = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
if (ex != null) {
LOG.error("Update of user {} failed, trying to pull its status anyway (if configured)", nullPriorityAsync, ex);
result.setStatus(ProvisioningReport.Status.FAILURE);
result.setMessage("Update failed, trying to pull status anyway (if configured)\n" + ex.getMessage());
WorkflowResult<Pair<UserPatch, Boolean>> updated = new WorkflowResult<>(Pair.of(userPatch, false), new PropagationByResource(), new HashSet<>());
sendMessage("direct:userInPull", updated, props);
exchange = pollingConsumer.receive();
}
return exchange.getIn().getBody(Pair.class);
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method internalSuspend.
@Override
public void internalSuspend(final String key) {
PollingConsumer pollingConsumer = getConsumer("direct:internalSuspendUserPort");
sendMessage("direct:internalSuspendUser", key);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method requestPasswordReset.
@Override
public void requestPasswordReset(final String key) {
PollingConsumer pollingConsumer = getConsumer("direct:requestPwdResetPort");
sendMessage("direct:requestPwdReset", key);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method activate.
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> activate(final StatusPatch statusPatch, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
Map<String, Object> props = new HashMap<>();
props.put("token", statusPatch.getToken());
props.put("key", statusPatch.getKey());
props.put("statusPatch", statusPatch);
props.put("nullPriorityAsync", nullPriorityAsync);
if (statusPatch.isOnSyncope()) {
sendMessage("direct:activateUser", statusPatch.getKey(), props);
} else {
WorkflowResult<String> updated = new WorkflowResult<>(statusPatch.getKey(), null, statusPatch.getType().name().toLowerCase());
sendMessage("direct:userStatusPropagation", updated, props);
}
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(Pair.class);
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method create.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(final UserTO userTO, final boolean storePassword, final boolean disablePwdPolicyCheck, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:createPort");
Map<String, Object> props = new HashMap<>();
props.put("storePassword", storePassword);
props.put("disablePwdPolicyCheck", disablePwdPolicyCheck);
props.put("enabled", enabled);
props.put("excludedResources", excludedResources);
props.put("nullPriorityAsync", nullPriorityAsync);
sendMessage("direct:createUser", userTO, props);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(Pair.class);
}
Aggregations