public String getDisplayName() { String displayName; if(title!=null) displayName = title; else displayName = name; return StringUtils.removeStart(displayName, "Jenkins "); }
private static String removeEscape(String str) { String result = StringUtils.removeEnd(str, "`"); result = StringUtils.removeStart(result, "`"); return result; }
private static String toDbcpPropertyKey(String key) { if (SONAR_JDBC_TO_DBCP_PROPERTY_MAPPINGS.containsKey(key)) { return SONAR_JDBC_TO_DBCP_PROPERTY_MAPPINGS.get(key); } return StringUtils.removeStart(key, SONAR_JDBC); }
/** * Returns true if specified value matches this pattern. */ public boolean match(String value) { value = StringUtils.removeStart(value, "/"); value = StringUtils.removeEnd(value, "/"); return pattern.matcher(value).matches(); }
public String getDisplayName() { return StringUtils.removeStart(getLongName(), "Jenkins "); }
/** * Removes the leading slash if present. * */ public static Path withoutLeadingSeparator(Path path) { return new Path(StringUtils.removeStart(path.toString(), Path.SEPARATOR)); }
protected String getDatasetName(String path, String basePath) { int startPos = path.indexOf(basePath) + basePath.length(); return StringUtils.removeStart(path.substring(startPos), "/"); }
static String sanitizeExtension(String suffix) { return StringUtils.lowerCase(StringUtils.removeStart(suffix, ".")); } }
static String sanitizeExtension(String suffix) { return StringUtils.lowerCase(StringUtils.removeStart(suffix, ".")); } }
protected DateTime getFolderTime(Path path, Path basePath) { int startPos = path.toString().indexOf(basePath.toString()) + basePath.toString().length(); return this.timeFormatter.parseDateTime(StringUtils.removeStart(path.toString().substring(startPos), "/")); }
/** * Retrieves the name of a dataset from a given {@link ConfigKeyPath}, relative to the store root. */ private static String getDatasetFromConfigKey(ConfigKeyPath configKey) { return StringUtils.removeStart(configKey.getAbsolutePathString(), SingleLinkedListConfigKeyPath.PATH_DELIMETER); }
private void parseTimeAndDatasetName (FileSystemDataset dataset, CompactionParserResult rst) { String commonBase = rst.getSrcBaseDir(); String fullPath = dataset.datasetURN(); int startPos = fullPath.indexOf(commonBase) + commonBase.length(); String relative = StringUtils.removeStart(fullPath.substring(startPos), "/"); int delimiterStart = StringUtils.indexOf(relative, rst.getSrcSubDir()); if (delimiterStart == -1) { throw new StringIndexOutOfBoundsException(); } int delimiterEnd = relative.indexOf("/", delimiterStart); String datasetName = StringUtils.removeEnd(relative.substring(0, delimiterStart), "/"); String timeString = StringUtils.removeEnd(relative.substring(delimiterEnd + 1), "/"); rst.datasetName = datasetName; rst.timeString = timeString; rst.time = getTime (timeString); }
/** * If we get - for whatever reason - a relative URL like * assets/../conf/application.conf we expand that to the "real" path. In the * above case conf/application.conf. * * You should then add the assets prefix. * * Otherwise someone can create an attack and read all resources of our app. * If we expand and normalize the incoming path this is no longer possible. * * @param fileName A potential "fileName" * @param enforceUnixSeparator If true it will force the usage of the unix separator '/' * If false it will use the separator of the underlying system. * usually '/' in case of unix and '\' in case of windows. * @return A normalized fileName. */ public String normalizePathWithoutLeadingSlash(String fileName, boolean enforceUnixSeparator) { String fileNameNormalized = enforceUnixSeparator ? FilenameUtils.normalize(fileName, true) : FilenameUtils.normalize(fileName); return StringUtils.removeStart(fileNameNormalized, "/"); }
@Test @UseDataProvider("sonarJdbcAndDbcpProperties") public void shouldExtractCommonsDbcpPropertiesIfDuplicatedPropertiesWithSameValue(String jdbcProperty, String dbcpProperty) { Properties props = new Properties(); props.setProperty(jdbcProperty, "100"); props.setProperty(dbcpProperty, "100"); Properties commonsDbcpProps = DefaultDatabase.extractCommonsDbcpProperties(props); assertThat(commonsDbcpProps.getProperty(removeStart(dbcpProperty, SONAR_JDBC))).isEqualTo("100"); }
@Test @UseDataProvider("sonarJdbcAndDbcpProperties") public void shouldThrowISEIfDuplicatedResolvedPropertiesWithDifferentValue(String jdbcProperty, String dbcpProperty) { Properties props = new Properties(); props.setProperty(jdbcProperty, "100"); props.setProperty(dbcpProperty, "200"); expectedException.expect(IllegalStateException.class); expectedException.expectMessage(String.format("Duplicate property declaration for resolved jdbc key '%s': conflicting values are", removeStart(dbcpProperty, SONAR_JDBC))); DefaultDatabase.extractCommonsDbcpProperties(props); }
private ComponentImpl buildDirectory(String parentPath, String path, List<Component> children) { String key = keyGenerator.generateKey(rootComponent.getKey(), path); String publicKey = publicKeyGenerator.generateKey(rootComponent.getKey(), path); return ComponentImpl.builder(Component.Type.DIRECTORY) .setUuid(uuidSupplier.apply(key)) .setDbKey(key) .setKey(publicKey) .setName(path) .setShortName(removeStart(removeStart(path, parentPath), "/")) .setStatus(convertStatus(FileStatus.UNAVAILABLE)) .setReportAttributes(createAttributesBuilder(null, path, scmBasePath).build()) .addChildren(children) .build(); }
private static String getBuildBranchOrTag(Run<?, ?> build) { GitLabWebHookCause cause = build.getCause(GitLabWebHookCause.class); if (cause == null) { return null; } if (cause.getData().getActionType() == CauseData.ActionType.TAG_PUSH) { return StringUtils.removeStart(cause.getData().getSourceBranch(), "refs/tags/"); } return cause.getData().getSourceBranch(); }
private static String trim(final String fun) { String result = fun; result = StringUtils.trim(result); result = StringUtils.removeStart(result, "\""); result = StringUtils.removeEnd(result, "\""); return result; }
@Override public String visitNamedAs(ZQLParser.NamedAsContext ctx) { String name = ctx.namedAsValue().getText(); name = StringUtils.removeStart(name, "'"); name = StringUtils.removeStart(name, "\""); name = StringUtils.removeEnd(name, "\""); name = StringUtils.removeEnd(name, "'"); return name; } }
private String getDecodedUrl(HttpServletRequest req) { try { if (req.getContextPath() == null) { return UriUtils.decode(req.getRequestURI(), "UTF-8"); } else { return UriUtils.decode(StringUtils.removeStart(req.getRequestURI(), req.getContextPath()), "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new CloudRuntimeException(e); } }