Search in sources :

Example 16 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class IssueQueryService method findCreatedAfterFromComponentUuid.

@CheckForNull
private Date findCreatedAfterFromComponentUuid(DbSession dbSession, String uuid) {
    ComponentDto component = checkFoundWithOptional(dbClient.componentDao().selectByUuid(dbSession, uuid), "Component with id '%s' not found", uuid);
    Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid());
    if (snapshot.isPresent()) {
        return longToDate(snapshot.get().getPeriodDate());
    }
    return null;
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) CheckForNull(javax.annotation.CheckForNull)

Example 17 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class RuleCreator method validateParam.

@CheckForNull
private void validateParam(RuleParamDto ruleParam, @Nullable String value) {
    if (value != null) {
        RuleParamType ruleParamType = RuleParamType.parse(ruleParam.getType());
        if (ruleParamType.multiple()) {
            List<String> values = newArrayList(Splitter.on(",").split(value));
            typeValidations.validate(values, ruleParamType.type(), ruleParamType.values());
        } else {
            typeValidations.validate(value, ruleParamType.type(), ruleParamType.values());
        }
    }
}
Also used : RuleParamType(org.sonar.api.server.rule.RuleParamType) CheckForNull(javax.annotation.CheckForNull)

Example 18 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class UserIndex method getNullableByLogin.

@CheckForNull
public UserDoc getNullableByLogin(String login) {
    GetRequestBuilder request = esClient.prepareGet(UserIndexDefinition.INDEX_TYPE_USER, login).setFetchSource(true).setRouting(login);
    GetResponse response = request.get();
    if (response.isExists()) {
        return DOC_CONVERTER.apply(response.getSource());
    }
    return null;
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder) CheckForNull(javax.annotation.CheckForNull)

Example 19 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class DefaultIssue method truncateToSeconds.

@CheckForNull
private static Date truncateToSeconds(@Nullable Date d) {
    if (d == null) {
        return null;
    }
    Instant instant = d.toInstant();
    instant = instant.truncatedTo(ChronoUnit.SECONDS);
    return Date.from(instant);
}
Also used : Instant(java.time.Instant) CheckForNull(javax.annotation.CheckForNull)

Example 20 with CheckForNull

use of javax.annotation.CheckForNull in project sonarqube by SonarSource.

the class PathResolver method relativePath.

/**
   * @deprecated since 6.0 was used when component keys were relative to source dirs
   */
@Deprecated
@CheckForNull
public RelativePath relativePath(Collection<File> dirs, File file) {
    List<String> stack = new ArrayList<>();
    File cursor = file;
    while (cursor != null) {
        File parentDir = parentDir(dirs, cursor);
        if (parentDir != null) {
            return new RelativePath(parentDir, Joiner.on("/").join(stack));
        }
        stack.add(0, cursor.getName());
        cursor = cursor.getParentFile();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) CheckForNull(javax.annotation.CheckForNull)

Aggregations

CheckForNull (javax.annotation.CheckForNull)149 IOException (java.io.IOException)18 Tree (org.apache.jackrabbit.oak.api.Tree)16 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)12 ArrayList (java.util.ArrayList)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)9 Stopwatch (com.google.common.base.Stopwatch)8 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)8 Date (java.util.Date)7 SnapshotDto (org.sonar.db.component.SnapshotDto)7 Period (org.sonar.server.computation.task.projectanalysis.period.Period)7 File (java.io.File)6 SQLException (java.sql.SQLException)6 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)6 ExecutionException (java.util.concurrent.ExecutionException)5 ValidationModel (org.apache.sling.validation.model.ValidationModel)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4 Root (org.apache.jackrabbit.oak.api.Root)4 Utils.resolveCommitRevision (org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4