@CheckForNull private static String mediaTypeFromUrl(String url) { String formatSuffix = substringAfterLast(url, "."); return SUPPORTED_MEDIA_TYPES_BY_URL_SUFFIX.get(formatSuffix.toLowerCase(ENGLISH)); }
@Override public int getJobTrackerPort() throws UnsupportedOperationException { String address = conf.get("yarn.resourcemanager.address"); address = StringUtils.substringAfterLast(address, ":"); if (StringUtils.isBlank(address)) { throw new IllegalArgumentException("Invalid YARN resource manager port."); } return Integer.parseInt(address); }
@Override public int getJobTrackerPort() throws UnsupportedOperationException { String address = conf.get("yarn.resourcemanager.address"); address = StringUtils.substringAfterLast(address, ":"); if (StringUtils.isBlank(address)) { throw new IllegalArgumentException("Invalid YARN resource manager port."); } return Integer.parseInt(address); }
@Override public int getJobTrackerPort() throws UnsupportedOperationException { String address = conf.get("yarn.resourcemanager.address"); address = StringUtils.substringAfterLast(address, ":"); if (StringUtils.isBlank(address)) { throw new IllegalArgumentException("Invalid YARN resource manager port."); } return Integer.parseInt(address); }
ActionExtractor(String path) { this.path = path; String pathWithoutExtension = substringBeforeLast(path, POINT); this.controller = extractController(pathWithoutExtension); this.action = substringAfterLast(pathWithoutExtension, SLASH); checkArgument(!action.isEmpty(), "Url is incorrect : '%s'", path); this.extension = substringAfterLast(path, POINT); }
@Override public String retrieve(Config config, String targetDir) throws IOException { final String zipFile = appendSlash(targetDir) + StringUtils.substringAfterLast(this.uri, File.separator); LOGGER.debug("Downloading to zip: " + zipFile + " from uri: " + uri); FileUtils.copyURLToFile(new URL(this.uri), new File(zipFile)); return zipFile; } }
private static Duplications.File toWsFile(String componentKey, @Nullable String branch, @Nullable String pullRequest) { Duplications.File.Builder wsFile = Duplications.File.newBuilder(); String keyWithoutBranch = ComponentDto.removeBranchAndPullRequestFromKey(componentKey); wsFile.setKey(keyWithoutBranch); wsFile.setName(StringUtils.substringAfterLast(keyWithoutBranch, ":")); ofNullable(branch).ifPresent(wsFile::setBranch); ofNullable(pullRequest).ifPresent(wsFile::setPullRequest); return wsFile.build(); }
@Override public String retrieve(Config config, String targetDir) throws IOException { URI uri = URI.create(this.fsUri); FileSystem fs = FileSystem.get(uri, HadoopUtils.getConfFromState(ConfigUtils.configToState(config))); final Path sourceFile = new Path(path); final String zipFile = appendSlash(targetDir) + StringUtils.substringAfterLast(this.path, File.separator); LOGGER.debug("Downloading to zip: " + zipFile + " from uri: " + sourceFile); fs.copyToLocalFile(sourceFile, new Path(zipFile)); return zipFile; } }
if (StringUtils.substringAfterLast(rootPath, "/").indexOf('.') >= 0) { rootDirectory = StringUtils.substringBeforeLast(rootPath, "/");
private void downloadRelease(Release release) throws URISyntaxException, IOException { String url = release.getDownloadUrl(); URI uri = new URI(url); if (url.startsWith("file:")) { // used for tests File file = toFile(uri.toURL()); copyFileToDirectory(file, downloadDir); } else { String filename = substringAfterLast(uri.getPath(), "/"); if (!filename.endsWith("." + PLUGIN_EXTENSION)) { filename = release.getKey() + "-" + release.getVersion() + "." + PLUGIN_EXTENSION; } File targetFile = new File(downloadDir, filename); File tempFile = new File(downloadDir, filename + "." + TMP_SUFFIX); downloader.download(uri, tempFile); copyFile(tempFile, targetFile); deleteQuietly(tempFile); } }
public static List<ColumnDefinition> getIndexMetadata( String indexes ) { if ( indexes == null ) { return null; } String[] index_entries = split( indexes, ',' ); List<ColumnDef> columns = new ArrayList<ColumnDef>(); for ( String index_entry : index_entries ) { String column_name = stringOrSubstringBeforeFirst( index_entry, ':' ).trim(); String comparer = substringAfterLast( index_entry, ":" ).trim(); if ( StringUtils.isBlank( comparer ) ) { comparer = "UUIDType"; } if ( StringUtils.isNotBlank( column_name ) ) { ColumnDef cd = new ColumnDef( bytebuffer( column_name ), comparer ); cd.setIndex_name( column_name ); cd.setIndex_type( IndexType.KEYS ); columns.add( cd ); } } return ThriftColumnDef.fromThriftList( columns ); }
private void insertSnapshot(Path snapshotPath) throws Exception { String datasetPath = StringUtils.substringBeforeLast(snapshotPath.toString(), Path.SEPARATOR); String snapshotName = StringUtils.substringAfterLast(snapshotPath.toString(), Path.SEPARATOR); long ts = Long.parseLong(StringUtils.substringBefore(snapshotName, "-PT-")); long recordCount = Long.parseLong(StringUtils.substringAfter(snapshotName, "-PT-")); PreparedStatement insert = connection.prepareStatement("INSERT INTO Snapshots VALUES (?, ?, ?, ?, ?)"); insert.setString(1, datasetPath); insert.setString(2, snapshotName); insert.setString(3, snapshotPath.toString()); insert.setTimestamp(4, new Timestamp(ts)); insert.setLong(5, recordCount); insert.executeUpdate(); }
fileName = StringUtils.substringAfterLast(fileName, File.separator);
fileName = StringUtils.substringAfterLast(fileName, File.separator);
public Long addBatch(ClientIdentity clientIdentity, PositionRange positionRange) throws CanalMetaManagerException { String path = ZookeeperPathUtils.getBatchMarkPath(clientIdentity.getDestination(), clientIdentity.getClientId()); byte[] data = JsonUtils.marshalToByte(positionRange, SerializerFeature.WriteClassName); String batchPath = zkClientx .createPersistentSequential(path + ZookeeperPathUtils.ZOOKEEPER_SEPARATOR, data, true); String batchIdString = StringUtils.substringAfterLast(batchPath, ZookeeperPathUtils.ZOOKEEPER_SEPARATOR); return ZookeeperPathUtils.getBatchMarkId(batchIdString); }
private String getTokenFromMessage( Message msg ) throws IOException, MessagingException { String body = ( ( MimeMultipart ) msg.getContent() ).getBodyPart( 0 ).getContent().toString(); // TODO better token extraction // this is going to get the wrong string if the first part is not // text/plain and the url isn't the last character in the email return StringUtils.substringAfterLast( body, "token=" ); }
private static WebService newWs(String path, Consumer<WebService.NewAction> consumer) { return context -> { WebService.NewController controller = context.createController(substringBeforeLast(path, "/")); WebService.NewAction action = createNewDefaultAction(controller, substringAfterLast(path, "/")); action.setHandler((request, response) -> { }); consumer.accept(action); controller.done(); }; }
columnLabel = StringUtils.substringAfterLast(columnLabel, ".");
public static String extractValue(String refValue) { refValue = StringUtils.removeAllQuotes(refValue); return org.apache.commons.lang.StringUtils.substringAfterLast(refValue, SLASH); }
private Optional<String> getType( final PsiElement targetElement, final PsiElement originalElement) { final String unquotedText = StringUtil.unquoteString(originalElement.getText()); final Optional<String> refName = Optional.of(StringUtils.substringAfterLast(unquotedText, "/")) .map(v -> v.isEmpty() ? unquotedText : v); return refName.map( name -> { String type = getUnquotedFieldValue(targetElement, "type").orElse("undefined type"); return String.format("%s: %s", name, type); }); }