org.apache.camel.component.box.BoxComponent Java Examples

The following examples show how to use org.apache.camel.component.box.BoxComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoxComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "box-component")
@ConditionalOnMissingBean(BoxComponent.class)
public BoxComponent configureBoxComponent() throws Exception {
    BoxComponent component = new BoxComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<BoxComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.box.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.box.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #2
Source File: BoxConnector.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureDelegateComponent(ComponentDefinition definition, Component component, Map<String, Object> options) {
    super.configureDelegateComponent(definition, component, options);

    if (component instanceof BoxComponent) {
        BoxConfiguration configuration = new BoxConfiguration();
        configuration.setAuthenticationType(authenticationType);
        configuration.setUserName(userName);
        configuration.setUserPassword(userPassword);
        configuration.setClientId(clientId);
        configuration.setClientSecret(clientSecret);
        ((BoxComponent) component).setConfiguration(configuration);
    }
}
 
Example #3
Source File: BoxIntegrationTest.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Test
public void testBoxComponent() throws Exception {
    Map<String, Object> boxOptions = createBoxOptions();

    // Do nothing if the required credentials are not present
    Assume.assumeTrue(boxOptions.size() == BoxOption.values().length);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").
            to("box://folders/createFolder");
        }
    });

    BoxConfiguration configuration = new BoxConfiguration();
    configuration.setAuthenticationType(BoxConfiguration.STANDARD_AUTHENTICATION);
    IntrospectionSupport.setProperties(configuration, boxOptions);

    BoxComponent component = new BoxComponent(camelctx);
    component.setConfiguration(configuration);
    camelctx.addComponent("box", component);

    BoxFolder folder = null;

    camelctx.start();
    try {
        Map<String, Object> headers = new HashMap<>();
        headers.put("CamelBox.parentFolderId", "0");
        headers.put("CamelBox.folderName", "TestFolder");

        ProducerTemplate template = camelctx.createProducerTemplate();
        folder = template.requestBodyAndHeaders("direct:start", null, headers, BoxFolder.class);

        Assert.assertNotNull("Folder was null", folder);
        Assert.assertEquals("Expected folder name to be TestFolder", "TestFolder", folder.getInfo().getName());
    } finally {
        // Clean up
        if (folder != null) {
            folder.delete(true);
        }

        camelctx.close();
    }
}