Package org.sonar.server.exceptions

Examples of org.sonar.server.exceptions.NotFoundException


    try {
      ActionPlan actionPlan = null;
      if (!Strings.isNullOrEmpty(actionPlanKey)) {
        actionPlan = actionPlanService.findByKey(actionPlanKey, UserSession.get());
        if (actionPlan == null) {
          throw new NotFoundException("Unknown action plan: " + actionPlanKey);
        }
      }
      DefaultIssue issue = getByKeyForUpdate(session, issueKey).toDefaultIssue();

      IssueChangeContext context = IssueChangeContext.createUser(new Date(), UserSession.get().login());
View Full Code Here


  }

  public IssueComment deleteComment(String commentKey, UserSession userSession) {
    DefaultIssueComment comment = changeDao.selectCommentByKey(commentKey);
    if (comment == null) {
      throw new NotFoundException("Comment not found: " + commentKey);
    }
    if (Strings.isNullOrEmpty(comment.userLogin()) || !Objects.equal(comment.userLogin(), userSession.login())) {
      throw new ForbiddenException("You can only delete your own comments");
    }
View Full Code Here

    DefaultIssueComment comment = changeDao.selectCommentByKey(commentKey);
    if (StringUtils.isBlank(text)) {
      throw new BadRequestException("Cannot add empty comments to an issue");
    }
    if (comment == null) {
      throw new NotFoundException("Comment not found: " + commentKey);
    }
    if (Strings.isNullOrEmpty(comment.userLogin()) || !Objects.equal(comment.userLogin(), userSession.login())) {
      throw new ForbiddenException("You can only edit your own comments");
    }
View Full Code Here

  public List<String> getSourceAsHtml(String componentKey, @Nullable Integer from, @Nullable Integer to) {
    DbSession session = mybatis.openSession(false);
    try {
      ResourceDto component = resourceDao.getResource(ResourceQuery.create().setKey(componentKey), session);
      if (component == null) {
        throw new NotFoundException("The component '" + componentKey + "' does not exists.");
      }
      String source = snapshotSourceDao.selectSnapshotSourceByComponentKey(componentKey, session);
      if (source != null) {
        return splitSourceByLine(source, component.getLanguage(), from, to);
      } else {
View Full Code Here

    try {
      Integer userId = UserSession.get().userId();
      DashboardDto dashboard = dbClient.dashboardDao().getAllowedByKey(dbSession, request.mandatoryParamAsLong(PARAM_KEY),
        userId != null ? userId.longValue() : null);
      if (dashboard == null) {
        throw new NotFoundException();
      }

      JsonWriter json = response.newJsonWriter();
      json.beginObject();
      json.prop("key", dashboard.getKey());
View Full Code Here

  }

  private Long userId(String login) {
    UserDto userDto = userDao.selectActiveUserByLogin(login);
    if (userDto == null) {
      throw new NotFoundException("User '" + login + "' does not exists.");
    }
    return userDto.getId();
  }
View Full Code Here

    checkPermission(userSession);
    DbSession session = dbClient.openSession(false);
    try {
      RuleDto ruleDto = dbClient.ruleDao().getNullableByKey(session, ruleChange.ruleKey());
      if (ruleDto == null) {
        throw new NotFoundException(String.format("Unknown rule '%s'", ruleChange.ruleKey()));
      }
      String subCharacteristicKey = ruleChange.debtCharacteristicKey();
      CharacteristicDto subCharacteristic = null;

      // A sub-characteristic is given -> update rule debt if given values are different from overridden ones and from default ones
      if (!Strings.isNullOrEmpty(subCharacteristicKey)) {
        subCharacteristic = dbClient.debtCharacteristicDao().selectByKey(subCharacteristicKey, session);
        if (subCharacteristic == null) {
          throw new NotFoundException(String.format("Unknown sub characteristic '%s'", ruleChange.debtCharacteristicKey()));
        }
      }

      boolean needUpdate = updateRule(ruleDto, subCharacteristic, ruleChange.debtRemediationFunction(), ruleChange.debtRemediationCoefficient(), ruleChange.debtRemediationOffset(),
        session);
View Full Code Here

  }

  public void updateComponent(Long id, String key, String name) {
    ResourceDto resource = resourceDao.getResource(id);
    if (resource == null) {
      throw new NotFoundException();
    }
    checkKeyFormat(resource.getQualifier(), key);

    resourceDao.insertOrUpdate(resource.setKey(key).setName(name));
  }
View Full Code Here

  protected abstract DOMAIN toDoc(Map<String, Object> fields);

  public DOMAIN getByKey(KEY key) {
    DOMAIN value = getNullableByKey(key);
    if (value == null) {
      throw new NotFoundException(String.format("Key '%s' not found", key));
    }
    return value;
  }
View Full Code Here

      public boolean apply(@Nullable CharacteristicDto input) {
        return input != null && key.equals(input.getKey());
      }
    }, null);
    if (dto == null && failIfNotFound) {
      throw new NotFoundException(String.format("Characteristic '%s' has not been found", key));
    }
    return dto;
  }
View Full Code Here

TOP

Related Classes of org.sonar.server.exceptions.NotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.