Search in sources :

Example 56 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelUserProvisioningManager method suspend.

@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> suspend(final StatusPatch statusPatch, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
    Map<String, Object> props = new HashMap<>();
    props.put("key", statusPatch.getKey());
    props.put("statusPatch", statusPatch);
    props.put("nullPriorityAsync", nullPriorityAsync);
    if (statusPatch.isOnSyncope()) {
        sendMessage("direct:suspendUser", 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);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) HashMap(java.util.HashMap)

Example 57 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelUserProvisioningManager method confirmPasswordReset.

@Override
public void confirmPasswordReset(final String key, final String token, final String password) {
    PollingConsumer pollingConsumer = getConsumer("direct:confirmPwdResetPort");
    Map<String, Object> props = new HashMap<>();
    props.put("key", key);
    props.put("token", token);
    props.put("password", password);
    sendMessage("direct:confirmPwdReset", key, props);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap)

Example 58 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelUserProvisioningManager method link.

@Override
public String link(final UserPatch anyPatch) {
    PollingConsumer pollingConsumer = getConsumer("direct:linkPort");
    sendMessage("direct:linkUser", anyPatch);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
    return exchange.getIn().getBody(UserPatch.class).getKey();
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 59 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelUserProvisioningManager method delete.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> delete(final String key, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:deletePort");
    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:deleteUser", key, props);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
    return exchange.getIn().getBody(List.class);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 60 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelUserProvisioningManager method deprovision.

@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> deprovision(final String user, final Collection<String> resources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:deprovisionPort");
    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:deprovisionUser", user, props);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
    return exchange.getIn().getBody(List.class);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap)

Aggregations

PollingConsumer (org.apache.camel.PollingConsumer)73 Exchange (org.apache.camel.Exchange)41 Test (org.junit.Test)27 HashMap (java.util.HashMap)21 CamelContext (org.apache.camel.CamelContext)21 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)21 RouteBuilder (org.apache.camel.builder.RouteBuilder)19 Endpoint (org.apache.camel.Endpoint)10 Connection (javax.jms.Connection)9 Transactional (org.springframework.transaction.annotation.Transactional)9 ConnectionFactory (javax.jms.ConnectionFactory)7 JMSException (javax.jms.JMSException)7 MessageConversionException (org.springframework.jms.support.converter.MessageConversionException)5 ProducerTemplate (org.apache.camel.ProducerTemplate)4 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)4 Message (javax.jms.Message)3 Session (javax.jms.Session)3 TextMessage (javax.jms.TextMessage)3 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)3 File (java.io.File)2