public static String normalizeArtifactPath(final String path, final File file) { if (StringUtil.isEmpty(path)) { return file.getName(); } else { return FileUtil.normalizeRelativePath(String.format("%s/%s", path, file.getName())); } }
public boolean hasSlackUserId(){ return StringUtil.isNotEmpty(slackUserId); } }
@NotNull public static Map<String, String> validateParameters(@NotNull Map<String, String> params, boolean acceptReferences) { final Map<String, String> invalids = new HashMap<String, String>(); if (StringUtil.isEmptyOrSpaces(getBucketName(params))) { invalids.put(S3_BUCKET_NAME, "S3 bucket name must not be empty"); } invalids.putAll(AWSCommonParams.validate(params, acceptReferences)); return invalids; }
public static String getContentType(File file) { String contentType = URLConnection.guessContentTypeFromName(file.getName()); if (StringUtil.isNotEmpty(contentType)) { return contentType; } if (PROBE_CONTENT_TYPE_METHOD != null && FILE_TO_PATH_METHOD != null) { try { Object result = PROBE_CONTENT_TYPE_METHOD.invoke(null, FILE_TO_PATH_METHOD.invoke(file)); if (result instanceof String) { contentType = (String)result; } } catch (Exception ignored) { } } return StringUtil.notEmpty(contentType, DEFAULT_CONTENT_TYPE); }
@NotNull private String getPathPrefix(@NotNull AgentRunningBuild build) { final List<String> pathSegments = new ArrayList<String>(); pathSegments.add(build.getSharedConfigParameters().get(ServerProvidedProperties.TEAMCITY_PROJECT_ID_PARAM)); pathSegments.add(build.getBuildTypeExternalId()); pathSegments.add(Long.toString(build.getBuildId())); return StringUtil.join("/", pathSegments) + "/"; }
public static boolean isCommonExternalError(@Nullable Throwable e) { if (e == null) return false; final String message = jetbrains.buildServer.util.StringUtil.emptyIfNull(e.getMessage()); if (e.getClass().getName().endsWith(".IllegalStateException") && message.equals("Cannot call sendError() after the response has been committed")){ //Jersey 1.19 (as opposed to Jersey 1.16) reports this error in case of ClientAbortException return true; } if (e.getClass().getName().endsWith(".IllegalStateException") && message.equals("getOutputStream() has already been called for this response")){ //this is thrown on attempt to report error in already written response in APIController.reportRestErrorResponse() return true; } while (true) { if (e.getClass().getName().endsWith(".ClientAbortException")) return true; final Throwable cause = e.getCause(); if (cause == null || cause == e) break; e = cause; } return false; }
public String getParameterAsStringOrNull(HttpServletRequest request, String paramName, String errorMessage) throws MissingPathException { String returnValue = StringUtil.nullIfEmpty(request.getParameter(paramName)); if (returnValue == null || "".equals(returnValue.trim())) { throw new MissingPathException(errorMessage); } return returnValue; }
attachment.addField(this.payload.getBuildName(), StringUtil.join(firstDetailLines, "\n"), false); attachment.addField("Reason", StringUtil.join(", ", payload.getFailedBuildMessages()), false); attachment.addField("Failed Tests", StringUtil.join(", ", failedTestNames) + truncated, false); String committersString = StringUtil.join(", ", committers); mentionContent += StringUtil.join(" ", slackUsers);
@NotNull private String getPatternsForBuild(@NotNull final BuildCleanupContext cleanupContext, @NotNull final SBuild build) { if (cleanupContext.getCleanupLevel().isCleanHistoryEntry()) return StringUtil.EMPTY; final CleanupPolicy policy = cleanupContext.getCleanupPolicyForBuild(build.getBuildId()); return StringUtil.emptyIfNull(policy.getParameters().get(HistoryRetentionPolicy.ARTIFACT_PATTERNS_PARAM)); }
@NotNull public static String writeS3ObjectKeys(@NotNull Collection<String> s3ObjectKeys) throws IOException { Element rootElement = new Element(S3_OBJECT_KEYS); for (String s3ObjectKey : s3ObjectKeys){ if(StringUtil.isEmpty(s3ObjectKey)) continue; Element xmlElement = new Element(S3_OBJECT_KEY); xmlElement.addContent(s3ObjectKey); rootElement.addContent(xmlElement); } return JDOMUtil.writeDocument(new Document(rootElement), System.getProperty("line.separator")); } }
private boolean userHasSlackIdConfigured(SUser sUser) { String userName = sUser.getPropertyValue(USERID_KEY); return StringUtil.isNotEmpty(userName); }
public PathPatternFilter(@NotNull String patterns) { if (StringUtil.isEmptyOrSpaces(patterns)) { patterns = "+:" + DEFAULT_INCLUDE_RULE; } final IncludeExcludeRules rules = new IncludeExcludeRules(patterns); for (IncludeExcludeRules.Rule r : rules.getRules()) { if (r.isInclude()) { myIncludePatterns.add(r.getRule()); } else { myExcludePatterns.add(r.getRule()); } } }
final Map<String, String> settings = build.getArtifactStorageSettings(); final String bucketName = S3Util.getBucketName(settings); if (StringUtil.isEmpty(bucketName)) { throw new IllegalArgumentException("S3 bucket name must not be empty");
final AWSException awsException = new AWSException(t); final String details = awsException.getDetails(); if (StringUtil.isNotEmpty(details)) { final String message = awsException.getMessage() + details; LOG.warn(message);
public Collection<InvalidProperty> process(final Map<String, String> properties) { List<InvalidProperty> errors = new ArrayList<InvalidProperty>(); AnsibleRunConfig config = new AnsibleRunConfig(properties); if (AnsibleCommand.EXECUTABLE.equals(config.getCommandType())) { if (StringUtil.isEmptyOrSpaces(config.getExecutable())) { errors.add(new InvalidProperty(AnsibleRunnerConstants.EXECUTABLE_KEY, "Cannot be empty")); } if (StringUtil.isEmptyOrSpaces(config.getPlaybook())) { errors.add(new InvalidProperty(AnsibleRunnerConstants.PLAYBOOK_FILE_KEY, "Cannot be empty")); } } else if (AnsibleCommand.CUSTOM_SCRIPT.equals(config.getCommandType())) { if (StringUtil.isEmptyOrSpaces(config.getSourceCode())) { errors.add(new InvalidProperty(AnsibleRunnerConstants.SOURCE_CODE_KEY, "Cannot be empty")); } } return errors; } };
public ProjectWebhook findWebHookById(String projectExternalId, String webHookLocator, final @NotNull Fields fields, @NotNull final BeanContext beanContext) { if (StringUtil.isEmpty(webHookLocator)) { throw new BadRequestException("Empty webhook locator is not supported."); } final Locator locator = new Locator(webHookLocator, "id", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { // no dimensions found, assume it's a name or internal id or // external id @NotNull final String singleValue = locator.getSingleValue(); return getWebHookConfigById(projectExternalId, fields, beanContext, singleValue); } else if (locator.getSingleDimensionValue("id") != null){ @NotNull final String webHookId = locator.getSingleDimensionValue("id"); return getWebHookConfigById(projectExternalId, fields, beanContext, webHookId); } throw new BadRequestException("Sorry: Searching for multiple template is not supported."); }
final String details = awsException.getDetails(); if (StringUtil.isNotEmpty(details)) { final String message = awsException.getMessage() + details; LOG.warn(message);
public WebHookTemplateItemConfigWrapper findTemplateByIdAndTemplateContentById(String templateLocator, String templateContentLocator) { WebHookTemplateConfigWrapper templateConfigWrapper = findTemplateById(templateLocator); if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported."); } final Locator locator = new Locator(templateContentLocator, "id", "name", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME); if (locator.isSingleValue()) { // no dimensions found, assume it's a name or id without "id:" @NotNull final String templateId = locator.getSingleValue(); return buildWebHookTemplateItemConfigWrapper(templateConfigWrapper, templateId); } else if (locator.getSingleDimensionValue("id") != null){ @NotNull final String templateId = locator.getSingleDimensionValue("id"); return buildWebHookTemplateItemConfigWrapper(templateConfigWrapper, templateId); } else { throw new BadRequestException("Sorry: Searching for multiple templates is not supported."); } }
public WebHookTemplateConfigWrapper findTemplateById(String templateLocator) { if (StringUtil.isEmpty(templateLocator)) { throw new BadRequestException("Empty template locator is not supported.");
public void getFromConfig(SlackNotification slackNotification, SlackNotificationConfig slackNotificationConfig){ slackNotification.setChannel(StringUtil.isEmpty(slackNotificationConfig.getChannel()) ? myMainSettings.getDefaultChannel() : slackNotificationConfig.getChannel()); slackNotification.setTeamName(myMainSettings.getTeamName()); slackNotification.setToken(StringUtil.isEmpty(slackNotificationConfig.getToken()) ? myMainSettings.getToken() : slackNotificationConfig.getToken()); slackNotification.setIconUrl(myMainSettings.getIconUrl()); slackNotification.setBotName(myMainSettings.getBotName());