Search in sources :

Example 26 with PollingConsumer

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

the class CamelGroupProvisioningManager method create.

@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(final GroupTO groupTO, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:createGroupPort");
    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", Collections.<String>emptySet());
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:createGroup", groupTO, 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) HashMap(java.util.HashMap)

Example 27 with PollingConsumer

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

the class CamelGroupProvisioningManager method link.

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

Example 28 with PollingConsumer

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

the class CamelGroupProvisioningManager method deprovision.

@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:deprovisionGroupPort");
    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:deprovisionGroup", 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)

Example 29 with PollingConsumer

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

the class CamelGroupProvisioningManager 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:deleteGroupPort");
    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:deleteGroup", 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 30 with PollingConsumer

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

the class CamelUserProvisioningManager method provision.

@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> provision(final String key, final boolean changePwd, final String password, final Collection<String> resources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:provisionPort");
    Map<String, Object> props = new HashMap<>();
    props.put("key", key);
    props.put("changePwd", changePwd);
    props.put("password", password);
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:provisionUser", 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)

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