List of usage examples for org.apache.commons.lang StringUtils removeStart
public static String removeStart(String str, String remove)
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
From source file:org.jfrog.build.client.DeploymentUrlUtils.java
/** * Calculate the full Artifactory deployment URL which includes the matrix params appended to it. see {@link * ClientProperties#PROP_DEPLOY_PARAM_PROP_PREFIX} for the property prefix that this method takes into account. * * @param artifactoryUrl The Artifactory upload URL. * @param properties The properties to append to the Artifactory URL. * @return The generated Artifactory URL with the matrix params appended to it. *//*from ww w . j a v a 2 s. c o m*/ public static String getDeploymentUrl(String artifactoryUrl, Properties properties) throws UnsupportedEncodingException { Map<Object, Object> filteredProperties = Maps.filterKeys(properties, new Predicate<Object>() { public boolean apply(Object input) { String inputKey = (String) input; return inputKey.startsWith(ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX); } }); StringBuilder deploymentUrl = new StringBuilder(artifactoryUrl); Set<Map.Entry<Object, Object>> propertyEntries = filteredProperties.entrySet(); for (Map.Entry<Object, Object> propertyEntry : propertyEntries) { String key = StringUtils.removeStart((String) propertyEntry.getKey(), ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX); deploymentUrl.append(";").append(URLEncoder.encode(key, "UTF-8")).append("=") .append(URLEncoder.encode(((String) propertyEntry.getValue()), "UTF-8")); } return deploymentUrl.toString(); }
From source file:org.jfrog.build.extractor.BuildInfoExtractorUtils.java
public static Properties stripPrefixFromProperties(Properties source, String prefix) { Properties props = new Properties(); for (Map.Entry<Object, Object> entry : source.entrySet()) { String key = entry.getKey().toString(); props.put(StringUtils.removeStart(key, prefix), entry.getValue()); }/*from w ww .j ava 2 s . c o m*/ return props; }
From source file:org.jfrog.build.extractor.clientConfiguration.util.PublishedItemsHelper.java
private static String calculateTargetRelativePath(File artifactFile) { String relativePath = artifactFile.getAbsolutePath(); String parentDir = artifactFile.getParent(); if (!StringUtils.isBlank(parentDir)) { relativePath = StringUtils.removeStart(artifactFile.getAbsolutePath(), parentDir); }//from w w w . ja va2 s .c o m relativePath = FilenameUtils.separatorsToUnix(relativePath); relativePath = StringUtils.removeStart(relativePath, "/"); return relativePath; }
From source file:org.jfrog.hudson.gradle.ArtifactoryGradleConfigurator.java
private String cleanString(String artifactPattern) { return StringUtils.removeEnd(StringUtils.removeStart(artifactPattern, "\""), "\""); }
From source file:org.jfrog.hudson.ivy.ArtifactoryIvyConfigurator.java
/** * Clears the extra apostrophes from the start and the end of the string *///w w w. ja v a 2 s .co m private String clearApostrophes(String artifactPattern) { return StringUtils.removeEnd(StringUtils.removeStart(artifactPattern, "\""), "\""); }
From source file:org.jfrog.hudson.plugins.artifactory.util.PublisherContext.java
private String getCleanString(String stringToClean) { return StringUtils.removeEnd(StringUtils.removeStart(stringToClean, "\""), "\""); }
From source file:org.jfrog.hudson.release.gradle.BaseGradleReleaseAction.java
@Override protected void doPerModuleVersioning(StaplerRequest req) { releaseVersionPerModule = Maps.newHashMap(); nextVersionPerModule = Maps.newHashMap(); Enumeration params = req.getParameterNames(); while (params.hasMoreElements()) { String key = (String) params.nextElement(); if (key.startsWith("release.")) { releaseVersionPerModule.put(StringUtils.removeStart(key, "release."), req.getParameter(key)); } else if (key.startsWith("next.")) { nextVersionPerModule.put(StringUtils.removeStart(key, "next."), req.getParameter(key)); }// www. ja v a 2s . co m } }
From source file:org.jfrog.hudson.release.maven.BaseMavenReleaseAction.java
@Override protected void doPerModuleVersioning(StaplerRequest req) { releaseVersionPerModule = Maps.newHashMap(); nextVersionPerModule = Maps.newHashMap(); Enumeration params = req.getParameterNames(); while (params.hasMoreElements()) { String key = (String) params.nextElement(); if (key.startsWith("release.")) { ModuleName moduleName = ModuleName.fromString(StringUtils.removeStart(key, "release.")); releaseVersionPerModule.put(moduleName, req.getParameter(key)); } else if (key.startsWith("next.")) { ModuleName moduleName = ModuleName.fromString(StringUtils.removeStart(key, "next.")); nextVersionPerModule.put(moduleName, req.getParameter(key)); }/*from w w w. ja v a 2 s . c om*/ } }
From source file:org.jfrog.hudson.release.scm.git.GitManager.java
public String getBranchNameWithoutRemote(String branchName) { List<RemoteConfig> repositories = getJenkinsScm().getRepositories(); for (RemoteConfig remoteConfig : repositories) { String prefix = remoteConfig.getName() + "/"; if (branchName.startsWith(prefix)) { return StringUtils.removeStart(branchName, prefix); }/*from www .j a va2 s . c o m*/ } return branchName; }
From source file:org.jfrog.teamcity.server.trigger.ArtifactoryPolledBuildTrigger.java
private void triggerPolling(PolledTriggerContext context, ServerConfigBean serverConfig, String username, String password, String repoKey) { String buildName = context.getBuildType().getExtendedName(); boolean foundChange = false; ArtifactoryBuildInfoClient client = getBuildInfoClient(serverConfig, username, password); List<BuildWatchedItem> replacedValues = Lists.newArrayList(); try {/* ww w .j av a 2 s . c om*/ Iterator<BuildWatchedItem> iterator = watchedItems.get(buildName).iterator(); while (iterator.hasNext()) { BuildWatchedItem buildWatchedItem = iterator.next(); //Preserve the user entered item path as is to keep it persistent with the map key String itemPath = buildWatchedItem.getItemPath(); //Format the path in another variable for use in a request String formattedPath = StringUtils.removeStart(itemPath.trim(), "/"); formattedPath = StringUtils.removeEnd(formattedPath, "/"); long itemValue = buildWatchedItem.getItemLastModified(); String itemUrl = repoKey + "/" + formattedPath; try { String itemLastModifiedString = client.getItemLastModified(itemUrl); long itemLastModified = format.parse(itemLastModifiedString).getTime(); if (itemValue != itemLastModified) { if (itemLastModified != 0) { replacedValues.add(new BuildWatchedItem(itemPath, itemLastModified)); String message = String.format( "Artifactory trigger has found changes on the watched " + "item '%s' for build '%s'. Last modified time was %s and is now %s.", itemUrl, buildName, format.format(itemValue), itemLastModifiedString); Loggers.SERVER.info(message); foundChange = true; } } else { replacedValues.add(buildWatchedItem); } } catch (Exception e) { Loggers.SERVER.error("Error occurred while polling for changes for build '" + buildName + "' on path '" + serverConfig.getUrl() + "/" + itemUrl + "': " + e.getMessage()); } } } finally { client.shutdown(); } if (foundChange) { watchedItems.replaceValues(buildName, replacedValues); SBuildType buildType = context.getBuildType(); buildType.addToQueue(context.getTriggerDescriptor().getTriggerName()); } }