use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class DeprecatedPropertiesWsTest method getProperty.
@CheckForNull
private static Properties.Property getProperty(WsClient wsClient, String key, @Nullable String componentKey, boolean useIdParameter) throws UnsupportedEncodingException {
GetRequest getRequest = useIdParameter ? new GetRequest("api/properties").setParam("id", encode(key, "UTF-8")).setParam("resource", componentKey) : new GetRequest("api/properties/" + encode(key, "UTF-8")).setParam("resource", componentKey);
WsResponse response = wsClient.wsConnector().call(getRequest).failIfNotSuccessful();
Properties.Property[] properties = Properties.parse(response.content());
return Arrays.stream(properties).findFirst().orElseGet(() -> null);
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class SettingsTest method getSetting.
@CheckForNull
private static Setting getSetting(String key, SettingsService settingsService) {
ValuesWsResponse response = settingsService.values(ValuesRequest.builder().setKeys(key).build());
List<Settings.Setting> settings = response.getSettingsList();
return settings.isEmpty() ? null : settings.get(0);
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class FileSourceDao method selectLineHashes.
@CheckForNull
public List<String> selectLineHashes(DbSession dbSession, String fileUuid) {
Connection connection = dbSession.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = connection.prepareStatement("SELECT line_hashes FROM file_sources WHERE file_uuid=? AND data_type=?");
pstmt.setString(1, fileUuid);
pstmt.setString(2, Type.SOURCE);
rs = pstmt.executeQuery();
if (rs.next()) {
String string = rs.getString(1);
if (string == null) {
return Collections.emptyList();
}
return END_OF_LINE_SPLITTER.splitToList(string);
}
return null;
} catch (SQLException e) {
throw new IllegalStateException("Fail to read FILE_SOURCES.LINE_HASHES of file " + fileUuid, e);
} finally {
DbUtils.closeQuietly(connection, pstmt, rs);
}
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class LogbackHelper method getPropertyValueAsLevel.
@CheckForNull
private static Level getPropertyValueAsLevel(Props props, String propertyKey) {
String value = props.value(propertyKey);
if (value == null) {
return null;
}
Level level = Level.toLevel(value, Level.INFO);
if (!isAllowed(level)) {
throw new IllegalArgumentException(format("log level %s in property %s is not a supported value (allowed levels are %s)", level, propertyKey, Arrays.toString(ALLOWED_ROOT_LOG_LEVELS)));
}
return level;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class ActivityAction method loadComponentUuids.
@CheckForNull
private List<String> loadComponentUuids(DbSession dbSession, ActivityWsRequest request) {
String componentUuid = request.getComponentId();
String componentQuery = request.getQuery();
if (componentUuid != null) {
return singletonList(componentUuid);
}
if (componentQuery != null) {
ComponentQuery componentDtoQuery = ComponentQuery.builder().setNameOrKeyQuery(componentQuery).setQualifiers(POSSIBLE_QUALIFIERS.toArray(new String[0])).build();
List<ComponentDto> componentDtos = dbClient.componentDao().selectByQuery(dbSession, componentDtoQuery, 0, CeTaskQuery.MAX_COMPONENT_UUIDS);
return Lists.transform(componentDtos, ComponentDto::uuid);
}
return null;
}
Aggregations