Search in sources :

Example 11 with CheckForNull

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

the class PeriodResolver method resolve.

@CheckForNull
public Period resolve(Settings settings) {
    String propertyValue = getPropertyValue(settings);
    if (StringUtils.isBlank(propertyValue)) {
        return null;
    }
    Period period = resolve(propertyValue);
    if (period == null && StringUtils.isNotBlank(propertyValue)) {
        LOG.debug("Property " + LEAK_PERIOD + " is not valid: " + propertyValue);
    }
    return period;
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) CheckForNull(javax.annotation.CheckForNull)

Example 12 with CheckForNull

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

the class PeriodResolver method findByDays.

@CheckForNull
private Period findByDays(int days) {
    List<SnapshotDto> snapshots = dbClient.snapshotDao().selectAnalysesByQuery(session, createCommonQuery(projectUuid).setCreatedBefore(analysisDate).setSort(BY_DATE, ASC));
    long targetDate = DateUtils.addDays(new Date(analysisDate), -days).getTime();
    SnapshotDto snapshot = findNearestSnapshotToTargetDate(snapshots, targetDate);
    if (snapshot == null) {
        return null;
    }
    LOG.debug("Compare over {} days ({}, analysis of {})", String.valueOf(days), formatDate(targetDate), formatDate(snapshot.getCreatedAt()));
    return new Period(LEAK_PERIOD_MODE_DAYS, String.valueOf(days), snapshot.getCreatedAt(), snapshot.getUuid());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) Period(org.sonar.server.computation.task.projectanalysis.period.Period) Date(java.util.Date) CheckForNull(javax.annotation.CheckForNull)

Example 13 with CheckForNull

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

the class PeriodResolver method findByVersion.

@CheckForNull
private Period findByVersion(String version) {
    SnapshotDto snapshot = findFirstSnapshot(session, createCommonQuery(projectUuid).setVersion(version).setSort(BY_DATE, DESC));
    if (snapshot == null) {
        return null;
    }
    LOG.debug("Compare to version ({}) ({})", version, formatDate(snapshot.getCreatedAt()));
    return new Period(LEAK_PERIOD_MODE_VERSION, version, snapshot.getCreatedAt(), snapshot.getUuid());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) Period(org.sonar.server.computation.task.projectanalysis.period.Period) CheckForNull(javax.annotation.CheckForNull)

Example 14 with CheckForNull

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

the class ShowAction method findDataFromComponent.

@CheckForNull
private String findDataFromComponent(DbSession dbSession, ComponentDto component) {
    MeasureQuery query = MeasureQuery.builder().setComponentUuid(component.uuid()).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).build();
    Optional<MeasureDto> measure = dbClient.measureDao().selectSingle(dbSession, query);
    return measure.isPresent() ? measure.get().getData() : null;
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) MeasureQuery(org.sonar.db.measure.MeasureQuery) CheckForNull(javax.annotation.CheckForNull)

Example 15 with CheckForNull

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

the class IssueQueryService method buildCreatedAfterFromDates.

@CheckForNull
private Date buildCreatedAfterFromDates(@Nullable Date createdAfter, @Nullable String createdInLast) {
    checkArgument(createdAfter == null || createdInLast == null, format("%s and %s cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_CREATED_IN_LAST));
    Date actualCreatedAfter = createdAfter;
    if (createdInLast != null) {
        actualCreatedAfter = new DateTime(system.now()).minus(ISOPeriodFormat.standard().parsePeriod("P" + createdInLast.toUpperCase(Locale.ENGLISH))).toDate();
    }
    return actualCreatedAfter;
}
Also used : Date(java.util.Date) DateUtils.longToDate(org.sonar.api.utils.DateUtils.longToDate) DateTime(org.joda.time.DateTime) DateUtils.parseDateOrDateTime(org.sonar.api.utils.DateUtils.parseDateOrDateTime) DateUtils.parseStartingDateOrDateTime(org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime) DateUtils.parseEndingDateOrDateTime(org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime) 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