private void addDTSIncomingFileRouter(final CamelContext context) throws Exception { final CIAOConfig config = CamelApplication.getConfig(context); final DTSIncomingFileRouterRoute route = new DTSIncomingFileRouterRoute(); // IN folder properties route.setDTSInUri(context.resolvePropertyPlaceholders("file://{{dts.rootFolder}}/IN")); route.setDTSMessageReceiverUri("direct:dtsMessageReceiver"); route.setInIdempotentRepositoryId("dtsReceiverIdempotentRepository"); route.setInInProgressRepositoryId("dtsReceiverInProgressRepository"); // SEND folder properties route.setDTSSentUri(context.resolvePropertyPlaceholders("file://{{dts.rootFolder}}/SENT")); route.setDTSMessageSendNotificationReceiverUri("direct:dtsMessageSendNotificationReceiver"); route.setSentIdempotentRepositoryId("dtsSentIdempotentRepository"); route.setSentInProgressRepositoryId("dtsSentInProgressRepository"); route.setDTSFilePrefix(Strings.nullToEmpty(config.getConfigValue("dts.filePrefix"))); // common properties route.setMailboxes(Arrays.asList(config.getConfigValue("dts.senderMailbox"))); final Set<String> workflowIds = Sets.newHashSet(config.getConfigValue("dts.workflowId")); for (final String workflowId : config.getConfigValue("dts.receiverWorkflowIds").split(",")) { if (!workflowId.trim().isEmpty()) { workflowIds.add(workflowId); } } route.setWorkflowIds(workflowIds); context.addRoutes(route); }
/** * Generate a "help" message. * * @param exchange the incoming message */ public void process(final Exchange exchange) throws IOException { final Message in = exchange.getIn(); final CamelContext context = exchange.getContext(); final String fedora; final String endpoint; try { fedora = context.resolvePropertyPlaceholders("{{fcrepo.baseUrl}}"); endpoint = InetAddress.getLocalHost().getHostName() + ":" + context.resolvePropertyPlaceholders("{{rest.port}}") + context.resolvePropertyPlaceholders("{{rest.prefix}}"); } catch (final Exception ex) { throw new RuntimeCamelException("Could not resolve property placeholders", ex); } final StringBuilder sb = new StringBuilder(); sb.append("Geneva Synchronization Service\n\n"); sb.append("\tConfigured Fedora Location: " + fedora + "\n"); sb.append("\tConfigured REST Endpoint: " + endpoint + "\n\n"); sb.append("You can POST to defined endpoint, and it will begin\n"); sb.append("a re-synchronization task with the configured datastore.\n\n"); sb.append("For example:\n\n"); sb.append("\tcurl -XPOST " + endpoint + "\n\n"); in.setBody(sb.toString()); }
@Override protected DistributionEnvelopeSenderRoute createDistributionEnvelopeSenderRoute( final CamelContext context, final CIAOConfig config) throws Exception { final DTSDistributionEnvelopeSenderRoute route = new DTSDistributionEnvelopeSenderRoute(); route.setDTSMessageSenderUri( context.resolvePropertyPlaceholders("file://{{dts.rootFolder}}/OUT")); route.setDTSMessageSendNotificationReceiverUri("direct:dtsMessageSendNotificationReceiver"); route.setDTSTemporaryFolder(context.resolvePropertyPlaceholders("{{dts.temporaryFolder}}")); route.setDTSFilePrefix(Strings.nullToEmpty(config.getConfigValue("dts.filePrefix"))); route.setIdGenerator(get(context, IdGenerator.class, "dtsIdGenerator")); // File housekeeping final DTSFileHousekeeper fileHousekeeper = new DTSFileHousekeeper(); fileHousekeeper.setDestinationFolder( context.resolvePropertyPlaceholders("{{dts.completedFolder}}")); route.setFileHousekeeper(fileHousekeeper); final DTSFileHousekeeper errorFileHousekeeper = new DTSFileHousekeeper(); errorFileHousekeeper.setDestinationFolder( context.resolvePropertyPlaceholders("{{dts.errorFolder}}")); route.setErrorFileHousekeeper(errorFileHousekeeper); final ControlFile prototype = new ControlFile(); prototype.setWorkflowId(config.getConfigValue("dts.workflowId")); prototype.setFromDTS(config.getConfigValue("dts.senderMailbox")); route.setPrototypeControlFile(prototype); return route; }
private void addDTSMessageReceiverRoute(final CamelContext context) throws Exception { final DTSMessageReceiverRoute route = new DTSMessageReceiverRoute(); route.setDTSMessageReceiverUri("direct:dtsMessageReceiver"); route.setPayloadDestinationUri(getDistributionEnvelopeReceiverUri()); // File housekeeping final DTSFileHousekeeper fileHousekeeper = new DTSFileHousekeeper(); fileHousekeeper.setDestinationFolder( context.resolvePropertyPlaceholders("{{dts.completedFolder}}")); route.setFileHousekeeper(fileHousekeeper); final DTSFileHousekeeper errorFileHousekeeper = new DTSFileHousekeeper(); errorFileHousekeeper.setDestinationFolder( context.resolvePropertyPlaceholders("{{dts.errorFolder}}")); route.setErrorFileHousekeeper(errorFileHousekeeper); context.addRoutes(route); }
@DirtiesContext @Test public void camelPropertiesAreLoadedFromMultipleFilesInOrderAndAccessedViaTheCamelContext() throws Exception { camelPropertyValue = context.resolvePropertyPlaceholders(camelPropertyKey); assertThat("The context cannot be null.", context != null); assertThat(camelPropertyValue, is(equalTo("MY SECOND VAR"))); }
@DirtiesContext @Test public void camelPropertiesAreLoadedFromSingleFileAndAccessedViaTheCamelValueAnnotation() throws Exception { String camelPropertyValue = context.resolvePropertyPlaceholders("{{" + propertyKey + "}}"); assertThat("The context cannot be null.", context != null); assertThat(camelPropertyValue, is(equalTo(expectedPropertyValue))); }
@Test public void nonExistentPropertiesWhenrequestedViaCamelThrowIllegalArgumentExceptions() { try { context.resolvePropertyPlaceholders("{{" + nonExistentPropertyKey + "}}"); fail("An IllegalArgument Exception shound be thrown"); } catch (IllegalArgumentException ex) { assertThat( ex.getMessage(), is( equalTo( "Property with key [" + nonExistentPropertyKey + "] not found in properties from text: {{" + nonExistentPropertyKey + "}}"))); } catch (Exception ex) { fail("All other exceptions should not be thrown: " + ex.getMessage()); } }
@Converter public TypeConverterOutput convert(TypeConverterInput input) throws Exception { TypeConverterOutput output = new TypeConverterOutput(); output.setProperty(context.resolvePropertyPlaceholders(input.getProperty())); return output; }