Package org.sonar.server.exceptions

Examples of org.sonar.server.exceptions.BadRequestException


  @Override
  public void validate(String value, @Nullable List<String> options) {
    if (options != null && !options.contains(value)) {
      String optionsAsString = StringUtils.join(options, ", ");
      throw new BadRequestException("errors.type.notInOptions", value, optionsAsString);
    }
  }
View Full Code Here


      // New sub characteristic
      if (parentId != null) {
        CharacteristicDto parent = findCharacteristic(parentId, session);
        if (parent.getParentId() != null) {
          throw new BadRequestException("A sub characteristic can not have a sub characteristic as parent.");
        }
        newCharacteristic.setParentId(parent.getId());
      } else {
        // New root characteristic
        newCharacteristic.setOrder(dbClient.debtCharacteristicDao().selectMaxCharacteristicOrder(session) + 1);
View Full Code Here

    SqlSession session = dbClient.openSession(false);
    try {
      final CharacteristicDto dto = findCharacteristic(characteristicId, session);
      if (dto.getParentId() != null) {
        throw new BadRequestException("Sub characteristics can not be moved.");
      }
      int currentOrder = getOrder(dto);
      CharacteristicDto dtoToSwitchOrderWith = findCharacteristicToSwitchWith(dto, moveUpOrDown, session);

      // Do nothing when characteristic is already to the good location
View Full Code Here

    return dto;
  }

  private void checkNotAlreadyExists(String name, SqlSession session) {
    if (dbClient.debtCharacteristicDao().selectByName(name, session) != null) {
      throw new BadRequestException(Validation.IS_ALREADY_USED_MESSAGE, name);
    }
  }
View Full Code Here

    for (ProfileImporter importer : importers) {
      if (StringUtils.equals(importerKey, importer.getKey())) {
        return importer;
      }
    }
    throw new BadRequestException("No such importer : " + importerKey);
  }
View Full Code Here

    throw new BadRequestException("No such importer : " + importerKey);
  }

  private void processValidationMessages(ValidationMessages messages, QProfileResult result) {
    if (!messages.getErrors().isEmpty()) {
      throw new BadRequestException(messages);
    }
    result.addWarnings(messages.getWarnings());
    result.addInfos(messages.getInfos());
  }
View Full Code Here

      public boolean apply(TypeValidation input) {
        return input.key().equals(key);
      }
    }, null);
    if (typeValidation == null) {
      throw new BadRequestException(String.format("Type '%s' is not valid.", key));
    }
    return typeValidation;
  }
View Full Code Here

    return true;
  }

  void verifyForActivation() {
    if (RuleStatus.REMOVED == rule.getStatus()) {
      throw new BadRequestException("Rule was removed: " + rule.getKey());
    }
    if (rule.isTemplate()) {
      throw new BadRequestException("Rule template can't be activated on a Quality profile: " + rule.getKey());
    }
    if (rule.getKey().isManual()) {
      throw new BadRequestException("Manual rule can't be activated on a Quality profile: " + rule.getKey());
    }
    if (!profile.getLanguage().equals(rule.getLanguage())) {
      throw new BadRequestException(String.format("Rule %s and profile %s have different languages", rule.getKey(), profile.getKey()));
    }

  }
View Full Code Here

  abstract void doExecute(Long templateId, String permission);

  Long getUserId() {
    UserDto userDto = userDao.selectActiveUserByLogin(updatedReference);
    if (userDto == null) {
      throw new BadRequestException("Unknown user: " + updatedReference);
    }
    return userDto.getId();
  }
View Full Code Here

    if (DefaultGroups.isAnyone(updatedReference)) {
      return null;
    }
    GroupDto groupDto = userDao.selectGroupByName(updatedReference);
    if (groupDto == null) {
      throw new BadRequestException("Unknown group: " + updatedReference);
    }
    return groupDto.getId();
  }
View Full Code Here

TOP

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

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.