本文整理汇总了Java中jetbrains.buildServer.util.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于jetbrains.buildServer.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideCommandLine
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@NotNull
public List<String> provideCommandLine(@NotNull final PowerShellInfo info,
@NotNull final Map<String, String> runnerParams,
@NotNull final File scriptFile,
final boolean useExecutionPolicy) throws RunBuildException {
final List<String> result = new ArrayList<String>();
final PowerShellExecutionMode mod = PowerShellExecutionMode.fromString(runnerParams.get(RUNNER_EXECUTION_MODE));
if (mod == null) {
throw new RunBuildException("'" + RUNNER_EXECUTION_MODE + "' runner parameter is not defined");
}
addVersion(result, runnerParams, info); // version must be the 1st arg after executable path
if (!StringUtil.isEmptyOrSpaces(runnerParams.get(RUNNER_NO_PROFILE))) {
result.add("-NoProfile");
}
result.add("-NonInteractive");
addCustomArguments(result, runnerParams, RUNNER_CUSTOM_ARGUMENTS);
if (useExecutionPolicy) {
addExecutionPolicyPreference(result);
}
addScriptBody(result, mod, scriptFile, runnerParams);
return result;
}
示例2: getCMDWrappedCommand
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
/**
* Gets path to {@code cmd.exe} wrapper for powershell process.
* Wrapper implicitly causes child process to inherit its bitness.
*
* @param info powershell info
* @param env environment variables
* @return path to {@code cmd.exe}
*/
public String getCMDWrappedCommand(@NotNull final PowerShellInfo info, @NotNull final Map<String, String> env) {
final String windir = env.get("windir");
if (StringUtil.isEmptyOrSpaces(windir)) {
LOG.warn("Failed to find %windir%");
return "cmd.exe";
}
switch (info.getBitness()) {
case x64:
if (mySystemBitness.is32bit()) {
return windir + "\\sysnative\\cmd.exe";
}
return windir + "\\System32\\cmd.exe";
case x86:
if (mySystemBitness.is64bit()) {
return windir + "\\SysWOW64\\cmd.exe";
}
return windir + "\\System32\\cmd.exe";
}
return "cmd.exe";
}
示例3: parseImageData
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
public static <T extends CloudImageDetails> Collection<T> parseImageData(Class<T> clazz, final CloudClientParameters params) {
Gson gson = new Gson();
final String imageData = StringUtil.emptyIfNull(params.getParameter(CloudImageParameters.SOURCE_IMAGES_JSON));
if (StringUtil.isEmpty(imageData)) {
return Collections.emptyList();
}
final ListParametrizedType listType = new ListParametrizedType(clazz);
final List<T> images = gson.fromJson(imageData, listType);
if (CloudImagePasswordDetails.class.isAssignableFrom(clazz)) {
final String passwordData = params.getParameter("secure:passwords_data");
final Map<String, String> data = gson.fromJson(passwordData, stringStringMapType);
if (data != null) {
for (T image : images) {
final CloudImagePasswordDetails userImage = (CloudImagePasswordDetails) image;
if (data.get(image.getSourceId()) != null) {
userImage.setPassword(data.get(image.getSourceId()));
}
}
}
}
return new ArrayList<>(images);
}
示例4: doHandle
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@Nullable
@Override
protected ModelAndView doHandle(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception {
String projectId = httpServletRequest.getParameter("projectId");
String profileId = httpServletRequest.getParameter("profileId");
String imageId = httpServletRequest.getParameter("imageId");
if(StringUtil.isEmpty(imageId)) return null;
final CloudClientEx client = myCloudManager.getClientIfExistsByProjectExtId(projectId, profileId);
CloudImage image = client.findImageById(imageId);
if(isGet(httpServletRequest)){
ModelAndView modelAndView = new ModelAndView(myPluginDescriptor.getPluginResourcesPath("deleteImageDialog.jsp"));
modelAndView.getModelMap().put("instances", image == null ? Collections.emptyList() : image.getInstances());
return modelAndView;
} else if(isPost(httpServletRequest) && image != null){
for (CloudInstance instance : image.getInstances()){
client.terminateInstance(instance);
}
}
return null;
}
示例5: validate
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
private ActionErrors validate(@NotNull TelegramSettingsBean settings) {
ActionErrors errors = new ActionErrors();
if (StringUtil.isEmptyOrSpaces(settings.getBotToken())) {
errors.addError("emptyBotToken", "Bot token must not be empty");
}
if (settings.isUseProxy()) {
if (StringUtils.isEmpty(settings.getProxyServer())) {
errors.addError("emptyProxyServer", "Proxy server must not be empty");
}
if (StringUtils.isEmpty(settings.getProxyPort())) {
errors.addError("emptyProxyPort", "Proxy port must not be empty");
}
}
String port = settings.getProxyPort();
if (!StringUtils.isEmpty(port) &&
(!StringUtil.isNumber(port) || Integer.valueOf(port) < 1 || Integer.valueOf(port) > 65535)) {
errors.addError("badProxyPort", "Proxy port must be integer between 1 and 65535");
}
return errors;
}
示例6: reloadIfNeeded
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
/**
* Reload bot if settings changed
* @param newSettings updated user settings
*/
public synchronized void reloadIfNeeded(@NotNull TelegramSettings newSettings) {
if (Objects.equals(newSettings, settings)) {
LOG.debug("Telegram bot token settings has not changed");
return;
}
LOG.debug("New telegram bot token is received: " +
StringUtil.truncateStringValueWithDotsAtEnd(newSettings.getBotToken(), 6));
this.settings = newSettings;
cleanupBot();
if (settings.getBotToken() != null && !settings.isPaused()) {
TelegramBot newBot = createBot(settings);
addUpdatesListener(newBot);
bot = newBot;
}
}
示例7: getContent
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public InputStream getContent(@NotNull StoredBuildArtifactInfo storedBuildArtifactInfo) throws IOException {
final Map<String, String> params;
try {
params = S3Util.validateParameters(storedBuildArtifactInfo.getStorageSettings());
} catch (IllegalArgumentException e) {
throw new IOException("Failed to get artifact " + storedBuildArtifactInfo.getArtifactData() + " content from S3: " + e.getMessage(), e);
}
final String bucketName = S3Util.getBucketName(params);
final String key = S3Util.getPathPrefix(storedBuildArtifactInfo.getCommonProperties()) + storedBuildArtifactInfo.getArtifactData().getPath();
try {
return S3Util.withS3Client(params, client -> client.getObject(bucketName, key).getObjectContent());
} catch (Throwable t) {
final AWSException awsException = new AWSException(t);
final String details = awsException.getDetails();
if (StringUtil.isNotEmpty(details)) {
LOG.warn(details);
}
throw new IOException("Failed to get artifact " + storedBuildArtifactInfo.getArtifactData() + " content from S3 bucket " + bucketName + ": " + awsException.getMessage(), awsException);
}
}
开发者ID:JetBrains,项目名称:teamcity-s3-artifact-storage-plugin,代码行数:27,代码来源:S3ArtifactContentProvider.java
示例8: ExportPrParticipants
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
private void ExportPrParticipants(PullRequestService service, RepositoryId repo, int prNum) {
try {
HashSet<String> participants = new HashSet<String>();
getParticipantsFromComments(participants, service.getComments(repo, prNum));
IssueService issueService = new IssueService(service.getClient());
getParticipantsFromComments(participants, issueService.getComments(repo, prNum));
if(participants.isEmpty()){
return;
}
exportConfigParam(getBuild(), "teamcity.build.pull_req.participants",
StringUtil.join(";", participants));
} catch (IOException e) {
e.printStackTrace();
getLogger().error(e.getMessage());
}
}
示例9: getRunnerPropertiesProcessor
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@Nullable
@Override
public PropertiesProcessor getRunnerPropertiesProcessor() {
return new PropertiesProcessor() {
@Override
public Collection<InvalidProperty> process(final Map<String, String> properties) {
final ArrayList<InvalidProperty> result = new ArrayList<InvalidProperty>();
final String user = properties.get(RunAsBean.Shared.getRunAsUserKey());
final String password = properties.get(RunAsBean.Shared.getRunAsPasswordKey());
if(!(StringUtil.isEmpty(user) && StringUtil.isEmpty(password))) {
if (StringUtil.isEmptyOrSpaces(user)) {
result.add(new InvalidProperty(RunAsBean.Shared.getRunAsUserKey(), "The user must be specified."));
}
if (StringUtil.isEmpty(password)) {
result.add(new InvalidProperty(RunAsBean.Shared.getRunAsPasswordKey(), "The password must be specified."));
}
}
return result;
}
};
}
示例10: tryGetParameter
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@Nullable
@Override
public String tryGetParameter(@NotNull final String paramName) {
final String isRunAsUiEnabledStr = myRunnerParametersService.tryGetConfigParameter(Constants.RUN_AS_UI_ENABLED);
final boolean isRunAsUiEnabled = StringUtil.isEmpty(isRunAsUiEnabledStr) || !Boolean.toString(false).equalsIgnoreCase(isRunAsUiEnabledStr);
if(isRunAsUiEnabled) {
String paramValue = myRunnerParametersService.tryGetRunnerParameter(paramName);
if (!StringUtil.isEmptyOrSpaces(paramValue)) {
return paramValue;
}
paramValue = myBuildFeatureParametersService.tryGetBuildFeatureParameter(Constants.BUILD_FEATURE_TYPE, paramName);
if (!StringUtil.isEmptyOrSpaces(paramValue)) {
return paramValue;
}
}
return tryGetConfigParameter(paramName);
}
示例11: createCredentials
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@NotNull
private UserCredentials createCredentials(@NotNull final String profileName, @NotNull final String userName, @NotNull final String password, boolean isPredefined)
{
// Get parameters
final WindowsIntegrityLevel windowsIntegrityLevel = WindowsIntegrityLevel.tryParse(getParam(profileName, Constants.WINDOWS_INTEGRITY_LEVEL, isPredefined));
final LoggingLevel loggingLevel = LoggingLevel.tryParse(getParam(profileName, Constants.LOGGING_LEVEL, isPredefined));
String additionalArgs = tryGetFirstNotEmpty(getParam(profileName, Constants.ADDITIONAL_ARGS, isPredefined));
if(StringUtil.isEmptyOrSpaces(additionalArgs)) {
additionalArgs = "";
}
return new UserCredentials(
profileName,
userName,
password,
windowsIntegrityLevel,
loggingLevel,
myCommandLineArgumentsService.parseCommandLineArguments(additionalArgs));
}
示例12: createBuildProcess
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public BuildProcess createBuildProcess(@NotNull final AgentRunningBuild runningBuild,
@NotNull final BuildRunnerContext context) throws RunBuildException {
final Map<String, String> runnerParameters = context.getRunnerParameters();
final String username = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_USERNAME));
final String password = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_PASSWORD));
final String target = StringUtil.emptyIfNull(runnerParameters.get(DeployerRunnerConstants.PARAM_TARGET_URL));
final String sourcePaths = runnerParameters.get(DeployerRunnerConstants.PARAM_SOURCE_PATH);
final Collection<ArtifactsPreprocessor> preprocessors = myExtensionHolder.getExtensions(ArtifactsPreprocessor.class);
final ArtifactsBuilder builder = new ArtifactsBuilder();
builder.setPreprocessors(preprocessors);
builder.setBaseDir(runningBuild.getCheckoutDirectory());
builder.setArtifactsPaths(sourcePaths);
final List<ArtifactsCollection> artifactsCollections = builder.build();
return getDeployerProcess(context, username, password, target, artifactsCollections);
}
示例13: splitCommaSeparatedValues
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
private List<String> splitCommaSeparatedValues(String values) {
List<String> result = new ArrayList<String>();
if (values == null || StringUtil.isEmptyOrSpaces(values)) {
return result;
}
String[] valueList = values.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
for (String value : valueList) {
String valueTrimmed = value.trim();
if (valueTrimmed.length() > 0) {
result.add(valueTrimmed);
}
}
return result;
}
示例14: getRunnerPropertiesProcessor
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
@Nullable
@Override
public PropertiesProcessor getRunnerPropertiesProcessor() {
return new PropertiesProcessor() {
@Override
public Collection<InvalidProperty> process(final Map<String, String> properties) {
final ArrayList<InvalidProperty> result = new ArrayList<InvalidProperty>();
final boolean useDotTrace = StringUtil.isTrue(properties.get(DotTraceBean.Shared.getUseDotTraceKey()));
if(useDotTrace && StringUtil.isEmptyOrSpaces(properties.get(DotTraceBean.Shared.getPathKey()))) {
result.add(new InvalidProperty(DotTraceBean.Shared.getPathKey(), PATH_NOT_SPECIFIED_ERROR_MESSAGE));
}
if(useDotTrace && StringUtil.isEmptyOrSpaces(properties.get(DotTraceBean.Shared.getThresholdsKey()))) {
result.add(new InvalidProperty(DotTraceBean.Shared.getThresholdsKey(), THRESHOLDS_NOT_SPECIFIED_ERROR_MESSAGE));
}
return result;
}
};
}
示例15: tagBuild
import jetbrains.buildServer.util.StringUtil; //导入依赖的package包/类
/**
* Tag the finishing build (if requested in the config) as either
* 1) triggered by SinCity
* 2) not triggered by SinCity
*/
void tagBuild() {
// tag the finished build
SettingNames settingNames = new SettingNames();
// if this is a SinCity-triggered build, we know for sure that the getSincityRangeTopBuildId() parameter is set;
// if, on the other hand, it is a non-SinCity-triggered run, it may still be set (and hopefully empty) if the
// user has set the parameter up in their build configuration; therefore, don't just test for null and accept
// empty as a sign of a non-SinCity-triggered build
final String sincityRangeTopBuildId = build.getParametersProvider().get(new ParameterNames().getSincityRangeTopBuildId());
String tagParameterName = StringUtil.isEmpty(sincityRangeTopBuildId)
? settingNames.getTagNameForBuildsNotTriggeredBySinCity()
: settingNames.getTagNameForBuildsTriggeredBySinCity();
String unresolvedTagName = sinCityParameters.get(tagParameterName);
if (StringUtil.isEmpty(unresolvedTagName))
return;
ValueResolver resolver = build.getValueResolver();
final String resolvedTagName = resolver.resolve(unresolvedTagName).getResult();
Loggers.SERVER.debug("[SinCity] tagging build with '" + resolvedTagName + "'");
final List<String> resultingTags = new ArrayList<String>(build.getTags());
resultingTags.add(resolvedTagName);
build.setTags(resultingTags);
}