protected GenericFileEndpoint<File> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { // the starting directory must be a static (not containing dynamic expressions) if (SimpleLanguage.hasStartToken(remaining)) { throw new IllegalArgumentException("Invalid directory: " + remaining + ". Dynamic expressions with ${ } placeholders is not allowed." + " Use the fileName option to set the dynamic expression."); } getFiles(remaining); File file = new File(TEMP_FOLDER); FileEndpoint result = new FileEndpoint(uri, this); result.setFile(file); GenericFileConfiguration config = new GenericFileConfiguration(); config.setDirectory(file.getPath()); result.setConfiguration(config); return result; }
@Override protected void doStart() throws Exception { // turn off scheduler first, so autoCreate is handled before scheduler starts boolean startScheduler = isStartScheduler(); setStartScheduler(false); try { super.doStart(); if (endpoint.isAutoCreate()) { log.debug("Auto creating directory: {}", endpoint.getConfiguration().getDirectory()); try { connectIfNecessary(); operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true); } catch (GenericFileOperationFailedException e) { // log a WARN as we want to start the consumer. log.warn("Error auto creating directory: " + endpoint.getConfiguration().getDirectory() + " due " + e.getMessage() + ". This exception is ignored.", e); } } } finally { if (startScheduler) { setStartScheduler(true); startScheduler(); } } }
@Override public void configure(URI uri) { super.configure(uri); // after configure the directory has been resolved, so we can use it for directoryName // (directoryName is the name we use in the other file components, to use consistent name) setDirectoryName(getDirectory()); setProtocol(uri.getScheme()); setDefaultPort(); // UserInfo can contain both username and password as: user:pwd@ftpserver // see: http://en.wikipedia.org/wiki/URI_scheme String username = uri.getUserInfo(); String pw = null; if (username != null && username.contains(":")) { pw = ObjectHelper.after(username, ":"); username = ObjectHelper.before(username, ":"); } if (username != null) { setUsername(username); } if (pw != null) { setPassword(pw); } setHost(uri.getHost()); setPort(uri.getPort()); }
@Override protected void doStart() throws Exception { // turn off scheduler first, so autoCreate is handled before scheduler starts boolean startScheduler = isStartScheduler(); setStartScheduler(false); try { super.doStart(); if (endpoint.isAutoCreate()) { log.debug("Auto creating directory: {}", endpoint.getConfiguration().getDirectory()); try { connectIfNecessary(); operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true); } catch (GenericFileOperationFailedException e) { // log a WARN as we want to start the consumer. log.warn("Error auto creating directory: " + endpoint.getConfiguration().getDirectory() + " due " + e.getMessage() + ". This exception is ignored.", e); } } } finally { if (startScheduler) { setStartScheduler(true); startScheduler(); } } }