Package org.sonar.server.exceptions

Examples of org.sonar.server.exceptions.NotFoundException


  @Override
  public void handle(Request request, Response response) {
    RuleKey key = RuleKey.parse(request.mandatoryParam(PARAM_KEY));
    Rule rule = service.getByKey(key);
    if (rule == null) {
      throw new NotFoundException("Rule not found: " + key);
    }
    JsonWriter json = response.newJsonWriter().beginObject().name("rule");
    mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);

    if (request.mandatoryParamAsBoolean(PARAM_ACTIVES)) {
View Full Code Here


  }

  private RuleUpdate createRuleUpdate(RuleKey key) {
    Rule rule = service.getByKey(key);
    if (rule == null) {
      throw new NotFoundException("This rule does not exists : " + key);
    }
    if (rule.templateKey() != null) {
      return RuleUpdate.createForCustomRule(key);
    } else if (rule.isManual()) {
      return RuleUpdate.createForManualRule(key);
View Full Code Here

  }

  public ComponentDto getById(Long id, DbSession session) {
    ComponentDto componentDto = getNullableById(id, session);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Project with id '%s' not found", id));
    }
    return componentDto;
  }
View Full Code Here

  }

  public ComponentDto getByUuid(DbSession session, String uuid) {
    ComponentDto componentDto = getNullableByUuid(session, uuid);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Project with uuid '%s' not found", uuid));
    }
    return componentDto;
  }
View Full Code Here

  }

  public ComponentDto getRootProjectByKey(String componentKey, DbSession session) {
    ComponentDto componentDto = getNullableRootProjectByKey(componentKey, session);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Root project for project '%s' not found", componentKey));
    }
    return componentDto;
  }
View Full Code Here

    int from = Math.max(request.mandatoryParamAsInt("from"), 1);
    int to = (Integer) ObjectUtils.defaultIfNull(request.paramAsInt("to"), Integer.MAX_VALUE);

    List<String> sourceHtml = sourceService.getLinesAsHtml(fileKey, from, to);
    if (sourceHtml == null) {
      throw new NotFoundException("File '" + fileKey + "' has no sources");
    }

    JsonWriter json = response.newJsonWriter().beginObject();
    writeSource(sourceHtml, from, json);
View Full Code Here

  }

  private Long validateId(String gateId) {
    QualityGateDto qualityGateDto = qualitygateDao.selectById(Long.valueOf(gateId));
    if (qualityGateDto == null) {
      throw new NotFoundException("Quality gate '" + gateId + "' does not exists.");
    }
    return qualityGateDto.getId();
  }
View Full Code Here

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

  }

  private ActionPlanDto findActionPlanDto(String actionPlanKey) {
    ActionPlanDto actionPlanDto = actionPlanDao.findByKey(actionPlanKey);
    if (actionPlanDto == null) {
      throw new NotFoundException("Action plan " + actionPlanKey + " has not been found.");
    }
    return actionPlanDto;
  }
View Full Code Here

  }

  private ComponentDto findComponent(String key, DbSession session) {
    ComponentDto componentDto = componentDao.getNullableByKey(session, key);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Component with key '%s' not found", key));
    }
    return componentDto;
  }
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.