private static AddCommentRequest toWsRequest(Request request) { AddCommentRequest wsRequest = new AddCommentRequest(request.mandatoryParam(PARAM_ISSUE), request.mandatoryParam(PARAM_TEXT)); checkArgument(!isNullOrEmpty(wsRequest.getText()), "Cannot add empty comment to an issue"); return wsRequest; }
private static SearchHistoryRequest toWsRequest(Request request) { return SearchHistoryRequest.builder() .setComponent(request.mandatoryParam(PARAM_COMPONENT)) .setBranch(request.param(PARAM_BRANCH)) .setPullRequest(request.param(PARAM_PULL_REQUEST)) .setMetrics(request.mandatoryParamAsStrings(PARAM_METRICS)) .setFrom(request.param(PARAM_FROM)) .setTo(request.param(PARAM_TO)) .setPage(request.mandatoryParamAsInt(Param.PAGE)) .setPageSize(request.mandatoryParamAsInt(Param.PAGE_SIZE)) .build(); }
private static CreateRequest toWsRequest(Request request) { return CreateRequest.builder() .setLogin(request.mandatoryParam(PARAM_LOGIN)) .setPassword(request.param(PARAM_PASSWORD)) .setName(request.param(PARAM_NAME)) .setEmail(request.param(PARAM_EMAIL)) .setScmAccounts(getScmAccounts(request)) .setLocal(request.mandatoryParamAsBoolean(PARAM_LOCAL)) .build(); }
private static Function<Request, EditCommentRequest> toWsRequest() { return request -> { EditCommentRequest wsRequest = new EditCommentRequest(request.mandatoryParam(PARAM_COMMENT), request.mandatoryParam(PARAM_TEXT)); checkArgument(!isNullOrEmpty(wsRequest.getText()), "Cannot set empty comment to an issue"); return wsRequest; }; }
static Long parseId(Request request, String paramName) { try { return Long.valueOf(request.mandatoryParam(paramName)); } catch (NumberFormatException badFormat) { throw BadRequestException.create(paramName + " must be a valid long value"); } }
private static SearchRequest toWsRequest(Request request) { return new SearchRequest() .setP(request.mandatoryParam(Param.PAGE)) .setPs(request.mandatoryParam(Param.PAGE_SIZE)); }
@Override public void handle(Request request, Response response) throws Exception { doHandle(request.mandatoryParam(PARAM_ID)); response.noContent(); }
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); String issueKey = request.mandatoryParam(PARAM_ISSUE); String severity = request.mandatoryParam(PARAM_SEVERITY); try (DbSession session = dbClient.openSession(false)) { SearchResponseData preloadedSearchResponseData = setType(session, issueKey, severity); responseWriter.write(issueKey, preloadedSearchResponseData, request, response); } }
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); String issueKey = request.mandatoryParam(PARAM_ISSUE); RuleType ruleType = RuleType.valueOf(request.mandatoryParam(PARAM_TYPE)); try (DbSession session = dbClient.openSession(false)) { SearchResponseData preloadedSearchResponseData = setType(session, issueKey, ruleType); responseWriter.write(issueKey, preloadedSearchResponseData, request, response); } }
@Override public void handle(Request request, Response response) throws Exception { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION)); QProfileDto profile = wsSupport.getProfile(dbSession, organization, request.mandatoryParam(PARAM_QUALITY_PROFILE), request.mandatoryParam(PARAM_LANGUAGE)); wsSupport.checkCanEdit(dbSession, organization, profile); UserDto user = wsSupport.getUser(dbSession, organization, request.mandatoryParam(PARAM_LOGIN)); addUser(dbSession, profile, user); } response.noContent(); }
@Override public void handle(Request request, Response response) throws Exception { String eventP = request.mandatoryParam(PARAM_EVENT); try (DbSession dbSession = dbClient.openSession(false)) { Stream.of(getEvent(dbSession, eventP)) .peek(checkPermissions()) .peek(checkModifiable()) .forEach(event -> deleteEvent(dbSession, event)); } response.noContent(); }
@Override public void handle(Request request, Response response) throws Exception { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION)); QProfileDto profile = wsSupport.getProfile(dbSession, organization, request.mandatoryParam(PARAM_QUALITY_PROFILE), request.mandatoryParam(PARAM_LANGUAGE)); wsSupport.checkCanEdit(dbSession, organization, profile); UserDto user = wsSupport.getUser(dbSession, organization, request.mandatoryParam(PARAM_LOGIN)); removeUser(dbSession, profile, user); } response.noContent(); }
private ComponentDto loadComponent(DbSession dbSession, Request request) { String componentKey = request.mandatoryParam(PARAM_KEY); String branch = request.param(PARAM_BRANCH); if (branch != null) { return componentFinder.getByKeyAndBranch(dbSession, componentKey, branch); } return componentFinder.getByKey(dbSession, componentKey); } }
private static CreateRequest toRequest(Request request, OrganizationDto organization) { Builder builder = CreateRequest.builder() .setOrganizationKey(organization.getKey()) .setLanguage(request.mandatoryParam(PARAM_LANGUAGE)) .setName(request.mandatoryParam(PARAM_NAME)); return builder.build(); }
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); String assignee = getAssignee(request); String key = request.mandatoryParam(PARAM_ISSUE); SearchResponseData preloadedResponseData = assign(key, assignee); responseWriter.write(key, preloadedResponseData, request, response); }
private static AddUserToTemplateRequest toAddUserToTemplateWsRequest(Request request) { return new AddUserToTemplateRequest() .setLogin(request.mandatoryParam(PARAM_USER_LOGIN)) .setPermission(request.mandatoryParam(PARAM_PERMISSION)) .setTemplateId(request.param(PARAM_TEMPLATE_ID)) .setOrganization(request.param(PARAM_ORGANIZATION)) .setTemplateName(request.param(PARAM_TEMPLATE_NAME)); }
private static CreateRequest toCreateRequest(Request request) { return CreateRequest.builder() .setOrganization(request.param(PARAM_ORGANIZATION)) .setKey(request.mandatoryParam(PARAM_PROJECT)) .setName(abbreviate(request.mandatoryParam(PARAM_NAME), MAX_COMPONENT_NAME_LENGTH)) .setBranch(request.param(PARAM_BRANCH)) .setVisibility(request.param(PARAM_VISIBILITY)) .build(); }
@Override public void handle(Request request, Response response) throws Exception { String name = request.mandatoryParam(PARAM_NAME); try (DbSession dbSession = dbClient.openSession(false)) { UserDto user = userTokenSupport.getUser(dbSession, request); dbClient.userTokenDao().deleteByUserAndName(dbSession, user, name); dbSession.commit(); } response.noContent(); } }
private static UpdateRequest toWsRequest(Request request) { return UpdateRequest.builder() .setLogin(request.mandatoryParam(PARAM_LOGIN)) .setName(request.param(PARAM_NAME)) .setEmail(request.param(PARAM_EMAIL)) .setScmAccounts(getScmAccounts(request)) .build(); }
@Override public void handle(Request request, Response response) { long id = QualityGatesWs.parseId(request, PARAM_ID); try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganization(dbSession, request); QualityGateDto qualityGate = rename(dbSession, organization, id, request.mandatoryParam(PARAM_NAME)); writeProtobuf(QualityGate.newBuilder() .setId(qualityGate.getId()) .setName(qualityGate.getName()) .build(), request, response); } }