SynchronizeProjectPermissionsStep synchronizeProjectPermissionsStep,
IndexProjectIssuesStep indexProjectIssuesStep,
SwitchSnapshotStep switchSnapshotStep,
- DataCleanerStep dataCleanerStep) {
- steps = ImmutableList.of(synchronizeProjectPermissionsStep, switchSnapshotStep, dataCleanerStep, indexProjectIssuesStep);
+ DataCleanerStep dataCleanerStep,
+ InvalidatePreviewCacheStep invalidatePreviewCacheStep) {
+ steps = ImmutableList.of(synchronizeProjectPermissionsStep, switchSnapshotStep, invalidatePreviewCacheStep, dataCleanerStep, indexProjectIssuesStep);
}
public List<ComputationStep> steps() {
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation;
+
+import org.sonar.core.component.ComponentDto;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.preview.PreviewCache;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.core.properties.PropertyDto;
+
+
+public class InvalidatePreviewCacheStep implements ComputationStep {
+ private final PropertiesDao propertiesDao;
+
+ public InvalidatePreviewCacheStep(PropertiesDao propertiesDao) {
+ this.propertiesDao = propertiesDao;
+ }
+
+ @Override
+ public void execute(DbSession session, AnalysisReportDto analysisReportDto, ComponentDto project) {
+ propertiesDao.setProperty(updatedProjectPreviewCacheProperty(project));
+ }
+
+ private PropertyDto updatedProjectPreviewCacheProperty(ComponentDto project) {
+ return new PropertyDto().setKey(PreviewCache.SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY).setResourceId(project.getId())
+ .setValue(String.valueOf(System.currentTimeMillis()));
+ }
+
+ @Override
+ public String description() {
+ return "Invalidate preview cache";
+ }
+}
import org.sonar.server.issue.filter.IssueFilterService;
import org.sonar.server.issue.filter.IssueFilterWriter;
import org.sonar.server.issue.filter.IssueFilterWs;
-import org.sonar.server.issue.index.*;
+import org.sonar.server.issue.index.IssueAuthorizationIndex;
+import org.sonar.server.issue.index.IssueAuthorizationNormalizer;
+import org.sonar.server.issue.index.IssueIndex;
+import org.sonar.server.issue.index.IssueNormalizer;
import org.sonar.server.issue.ws.IssueActionsWriter;
import org.sonar.server.issue.ws.IssueShowAction;
import org.sonar.server.issue.ws.IssuesWs;
ActivityNormalizer.class,
ActivityIndex.class,
ActivityDao.class
- ));
+ ));
components.addAll(CorePropertyDefinitions.all());
components.addAll(DatabaseMigrations.CLASSES);
components.addAll(DaoUtils.getDaoClasses());
// ws
RestartHandler.class,
SystemWs.class
- );
+ );
}
/**
HttpDownloader.class,
UriReader.class,
ServerIdGenerator.class
- );
+ );
}
void startLevel4Components(ComponentContainer pico) {
// Compute engine
pico.addSingleton(ComputationService.class);
pico.addSingleton(ComputationStepRegistry.class);
- pico.addSingleton(SynchronizeProjectPermissionsStep.class);
- pico.addSingleton(IndexProjectIssuesStep.class);
- pico.addSingleton(SwitchSnapshotStep.class);
- pico.addSingleton(DataCleanerStep.class);
- pico.add(AnalysisReportQueue.class);
+ pico.addSingletons(Lists.newArrayList(
+ SynchronizeProjectPermissionsStep.class,
+ IndexProjectIssuesStep.class,
+ SwitchSnapshotStep.class,
+ InvalidatePreviewCacheStep.class,
+ DataCleanerStep.class));
+ pico.addSingleton(AnalysisReportQueue.class);
pico.addSingleton(AnalysisReportTaskLauncher.class);
pico.addSingleton(AnalysisReportWebService.class);
pico.addSingleton(ActiveAnalysisReportsAction.class);
private IndexProjectIssuesStep indexProjectIssuesStep;
private SwitchSnapshotStep switchSnapshotStep;
private DataCleanerStep dataCleanerStep;
+ private InvalidatePreviewCacheStep invalidatePreviewCacheStep;
@Before
public void before() {
indexProjectIssuesStep = mock(IndexProjectIssuesStep.class);
switchSnapshotStep = mock(SwitchSnapshotStep.class);
dataCleanerStep = mock(DataCleanerStep.class);
+ invalidatePreviewCacheStep = mock(InvalidatePreviewCacheStep.class);
- sut = new ComputationStepRegistry(synchronizeProjectPermissionsStep, indexProjectIssuesStep, switchSnapshotStep, dataCleanerStep);
+ sut = new ComputationStepRegistry(synchronizeProjectPermissionsStep, indexProjectIssuesStep, switchSnapshotStep, dataCleanerStep, invalidatePreviewCacheStep);
}
@Test
public void steps_returned_in_the_right_order() throws Exception {
- assertThat(sut.steps()).containsExactly(synchronizeProjectPermissionsStep, switchSnapshotStep, dataCleanerStep, indexProjectIssuesStep);
+ assertThat(sut.steps()).containsExactly(synchronizeProjectPermissionsStep, switchSnapshotStep, invalidatePreviewCacheStep, dataCleanerStep, indexProjectIssuesStep);
}
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.core.component.ComponentDto;
+import org.sonar.core.computation.db.AnalysisReportDto;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.properties.PropertiesDao;
+import org.sonar.core.properties.PropertyDto;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class InvalidatePreviewCacheStepTest {
+ private InvalidatePreviewCacheStep sut;
+ private PropertiesDao propertiesDao;
+
+ @Before
+ public void before() {
+ this.propertiesDao = mock(PropertiesDao.class);
+ this.sut = new InvalidatePreviewCacheStep(propertiesDao);
+ }
+
+ @Test
+ public void update_property_calling_propertiesDao() {
+ sut.execute(mock(DbSession.class), mock(AnalysisReportDto.class), mock(ComponentDto.class));
+
+ verify(propertiesDao).setProperty(any(PropertyDto.class));
+ }
+}
\ No newline at end of file
send_data String.from_java_bytes(db_content)
end
- # PUT /batch_bootstrap/evict?project=<key or id>
- def evict
- has_scan_role = has_role?('scan')
- return render_unauthorized("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator.") if !has_scan_role
-
- project = load_project()
- return render_unauthorized("You're not authorized to access to project '" + project.name + "', please contact your SonarQube administrator") if project && !has_scan_role && !has_role?(:user, project)
-
- if project
- Property.set(Java::OrgSonarCorePreview::PreviewCache::SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY, java.lang.System.currentTimeMillis, project.root_project.id)
- render_success('dryRun DB evicted')
- else
- render_bad_request('missing projectId')
- end
- end
-
private
private AnalysisMode analysisMode;
public UpdateStatusJob(Settings settings, ServerClient server,
- Project project, Snapshot snapshot, AnalysisMode analysisMode) {
+ Project project, Snapshot snapshot, AnalysisMode analysisMode) {
this.server = server;
this.project = project;
this.snapshot = snapshot;
// If this is a preview analysis then we should not upload reports
return;
}
- String url = "/batch_bootstrap/evict?project=" + project.getId();
- try {
- LOG.debug("Upload report");
- server.request(url, "POST");
- } catch (Exception e) {
- throw new IllegalStateException("Unable to evict preview database: " + url, e);
- }
- url = "/batch/upload_report?project=" + project.getEffectiveKey() + "&snapshot=" + snapshot.getId();
+ String url = "/batch/upload_report?project=" + project.getEffectiveKey() + "&snapshot=" + snapshot.getId();
try {
LOG.debug("Publish results");
server.request(url, "POST", true, 0);
UpdateStatusJob job = new UpdateStatusJob(settings, serverClient, project, mock(Snapshot.class), mode);
job.uploadReport();
- verify(serverClient).request(contains("/batch_bootstrap/evict"), eq("POST"));
verify(serverClient).request(contains("/batch/upload_report"), eq("POST"), eq(true), eq(0));
}