public List<String> mandatoryMultiParam(String key) { List<String> values = multiParam(key); checkArgument(!values.isEmpty(), MSG_PARAMETER_MISSING, key); return values; }
private static Map<String, String> parseTaskCharacteristics(Request wsRequest) { Map<String, String> characteristics = new LinkedHashMap<>(); for (String param : wsRequest.multiParam(PARAM_ANALYSIS_CHARACTERISTIC)) { String[] pair = StringUtils.split(param, "=", 2); checkRequest(pair.length == 2, "Parameter '%s' must be a key-value pair with the format 'key=value'.", PARAM_ANALYSIS_CHARACTERISTIC); checkRequest(!characteristics.containsKey(pair[0]), "Key '%s' was provided twice with parameters '%s'", pair[0], PARAM_ANALYSIS_CHARACTERISTIC); if (CeTaskCharacteristicDto.SUPPORTED_KEYS.contains(pair[0])) { characteristics.put(pair[0], pair[1]); } } return characteristics; }
private static List<String> getScmAccounts(Request request) { if (request.hasParam(PARAM_SCM_ACCOUNT)) { return request.multiParam(PARAM_SCM_ACCOUNT); } List<String> oldScmAccounts = request.paramAsStrings(PARAM_SCM_ACCOUNTS); return oldScmAccounts != null ? oldScmAccounts : Collections.emptyList(); }
private static List<String> getScmAccounts(Request request) { if (request.hasParam(PARAM_SCM_ACCOUNT)) { return new ArrayList<>(request.multiParam(PARAM_SCM_ACCOUNT)); } List<String> oldScmAccounts = request.paramAsStrings(PARAM_SCM_ACCOUNTS); return oldScmAccounts != null ? oldScmAccounts : new ArrayList<>(); }
private static SetRequest toWsRequest(Request request) { SetRequest set = new SetRequest() .setKey(request.mandatoryParam(PARAM_KEY)) .setValue(request.param(PARAM_VALUE)) .setValues(request.multiParam(PARAM_VALUES)) .setFieldValues(request.multiParam(PARAM_FIELD_VALUES)) .setComponent(request.param(PARAM_COMPONENT)) .setBranch(request.param(PARAM_BRANCH)) .setPullRequest(request.param(PARAM_PULL_REQUEST)); checkArgument(isNotEmpty(set.getKey()), "Setting key is mandatory and must not be empty"); checkArgument(set.getValues() != null, "Setting values must not be null"); checkArgument(set.getFieldValues() != null, "Setting fields values must not be null"); return set; }
public List<String> mandatoryMultiParam(String key) { List<String> values = multiParam(key); checkArgument(!values.isEmpty(), MSG_PARAMETER_MISSING, key); return values; }
private static Map<String, String> parseTaskCharacteristics(Request wsRequest) { Map<String, String> characteristics = new LinkedHashMap<>(); for (String param : wsRequest.multiParam(PARAM_ANALYSIS_CHARACTERISTIC)) { String[] pair = StringUtils.split(param, "=", 2); checkRequest(pair.length == 2, "Parameter '%s' must be a key-value pair with the format 'key=value'.", PARAM_ANALYSIS_CHARACTERISTIC); checkRequest(!characteristics.containsKey(pair[0]), "Key '%s' was provided twice with parameters '%s'", pair[0], PARAM_ANALYSIS_CHARACTERISTIC); characteristics.put(pair[0], pair[1]); } return characteristics; }
private static List<String> getScmAccounts(Request request) { if (request.hasParam(PARAM_SCM_ACCOUNT)) { return new ArrayList<>(request.multiParam(PARAM_SCM_ACCOUNT)); } List<String> oldScmAccounts = request.paramAsStrings(PARAM_SCM_ACCOUNTS); return oldScmAccounts != null ? oldScmAccounts : new ArrayList<>(); }
private static List<String> getScmAccounts(Request request) { if (request.hasParam(PARAM_SCM_ACCOUNT)) { return request.multiParam(PARAM_SCM_ACCOUNT); } List<String> oldScmAccounts = request.paramAsStrings(PARAM_SCM_ACCOUNTS); return oldScmAccounts != null ? oldScmAccounts : Collections.emptyList(); }
private static SetRequest toWsRequest(Request request) { SetRequest set = new SetRequest() .setKey(request.mandatoryParam(PARAM_KEY)) .setValue(request.param(PARAM_VALUE)) .setValues(request.multiParam(PARAM_VALUES)) .setFieldValues(request.multiParam(PARAM_FIELD_VALUES)) .setComponent(request.param(PARAM_COMPONENT)) .setBranch(request.param(PARAM_BRANCH)) .setPullRequest(request.param(PARAM_PULL_REQUEST)); checkArgument(isNotEmpty(set.getKey()), "Setting key is mandatory and must not be empty"); checkArgument(set.getValues() != null, "Setting values must not be null"); checkArgument(set.getFieldValues() != null, "Setting fields values must not be null"); return set; }