final String value = att.getNodeValue(); String before = ObjectHelper.before(value, "?"); String after = ObjectHelper.after(value, "?");
final String value = att.getNodeValue(); String before = ObjectHelper.before(value, "?"); String after = ObjectHelper.after(value, "?");
@Override public Endpoint createEndpoint(String uri) throws Exception { String endpointURI = ObjectHelper.after(uri, ":"); if (endpointURI != null && endpointURI.startsWith("//")) { endpointURI = endpointURI.substring(2); } Assert.hasText(endpointURI, "External Call endpoint URI must not be empty"); String keyTypeString = ObjectHelper.before(endpointURI, ":"); Assert.notNull(keyTypeString, "External Call endpoint URI must be in format [keyType]:[targetURI]"); String targetURI = ObjectHelper.after(endpointURI, ":"); if (targetURI != null && targetURI.startsWith("//")) { targetURI = targetURI.substring(2); } Assert.hasText(keyTypeString, "External Call key type must not be empty"); Assert.hasText(targetURI, "External Call target URI must not be empty"); ExternalCallKeyType keyType = null; for (ExternalCallKeyType aKeyType : ExternalCallKeyType.values()) { if (aKeyType.name().equalsIgnoreCase(keyTypeString)) { keyType = aKeyType; break; } } Assert.notNull(keyType, String.format("External Call key type \"%s\" is invalid. It must be one of: %s", keyTypeString, Arrays.toString(ExternalCallKeyType.values()))); return new ExternalCallEndpoint(uri, this, keyType, targetURI); }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { AsynchChildEndpoint endpoint = new AsynchChildEndpoint(uri, this); // parse URI - "service:operation" String endpointURI = ObjectHelper.after(uri, ":"); if (endpointURI != null && endpointURI.startsWith("//")) { endpointURI = endpointURI.substring(2); } Assert.hasText(endpointURI, "Asynch-child endpoint URI must not be empty"); // endpointURI = "service:operation" String serviceName = ObjectHelper.before(endpointURI, ":"); String operationName = ObjectHelper.after(endpointURI, ":"); if (operationName != null && operationName.contains("?")) { operationName = ObjectHelper.before(operationName, "?"); } Assert.hasText(serviceName, "Service name can't be empty for asynch-child component"); Assert.hasText(operationName, "Operation name can't be empty for asynch-child component"); endpoint.setService(serviceName); endpoint.setOperationName(operationName); setProperties(endpoint, parameters); return endpoint; }
@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()); }
String path = ObjectHelper.after(u.getPath(), "/"); String host = u.getHost(); String cron = getAndRemoveParameter(parameters, "cron", String.class);
String after = ObjectHelper.after(uri, ":");
String relativePath = ObjectHelper.after(absoluteFileName, endpointPath);
private RemoteFile<SftpRemoteFile> asRemoteFile(String absolutePath, SftpRemoteFile file, String charset) { RemoteFile<SftpRemoteFile> answer = new RemoteFile<>(); answer.setCharset(charset); answer.setEndpointPath(endpointPath); answer.setFile(file); answer.setFileNameOnly(file.getFilename()); answer.setFileLength(file.getFileLength()); answer.setLastModified(file.getLastModified()); answer.setHostname(((RemoteFileConfiguration) endpoint.getConfiguration()).getHost()); answer.setDirectory(file.isDirectory()); // absolute or relative path boolean absolute = FileUtil.hasLeadingSeparator(absolutePath); answer.setAbsolute(absolute); // create a pseudo absolute name String dir = FileUtil.stripTrailingSeparator(absolutePath); String absoluteFileName = FileUtil.stripLeadingSeparator(dir + "/" + file.getFilename()); // if absolute start with a leading separator otherwise let it be relative if (absolute) { absoluteFileName = "/" + absoluteFileName; } answer.setAbsoluteFilePath(absoluteFileName); // the relative filename, skip the leading endpoint configured path String relativePath = ObjectHelper.after(absoluteFileName, endpointPath); // skip trailing / relativePath = FileUtil.stripLeadingSeparator(relativePath); answer.setRelativeFilePath(relativePath); // the file name should be the relative path answer.setFileName(answer.getRelativeFilePath()); return answer; }