diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-30 17:21:54 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-30 17:24:42 +0100 |
commit | 09c06b60675786f7d595e3800596519f92e010a7 (patch) | |
tree | d208a7e66697a579cfc659222d86a3b3c70468b0 | |
parent | c740d465f1a7621d2a570acb579a9b637835205e (diff) | |
download | sonarqube-09c06b60675786f7d595e3800596519f92e010a7.tar.gz sonarqube-09c06b60675786f7d595e3800596519f92e010a7.zip |
Minor refactorings
5 files changed, 14 insertions, 28 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/filter/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/filter/ShowAction.java index 4d1faa365e3..8319f6324a0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/filter/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/filter/ShowAction.java @@ -54,7 +54,7 @@ public class ShowAction implements RequestHandler { @Override public void handle(Request request, Response response) throws Exception { UserSession session = UserSession.get(); - DefaultIssueFilter filter = service.find(Long.parseLong(request.mandatoryParam("id")), session); + DefaultIssueFilter filter = service.find(request.mandatoryParamAsLong("id"), session); JsonWriter json = response.newJsonWriter(); json.beginObject(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java index 0fec3f77e6f..e80acf84300 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java @@ -619,12 +619,8 @@ class ServerComponents { } public void executeStartupTasks(ComponentContainer pico) { - final ComponentContainer startupContainer = pico.createChild(); - - /** Index startup Synchronization */ startupContainer.addSingleton(IndexSynchronizer.class); - startupContainer.addSingleton(RegisterMetrics.class); startupContainer.addSingleton(RegisterQualityGates.class); startupContainer.addSingleton(RegisterRules.class); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java b/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java index a179b88fbf7..e511f162f20 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java @@ -173,18 +173,11 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial @Override public IndexStat getIndexStat() { - IndexStat stat = new IndexStat(); - - /** get total document count */ CountRequestBuilder countRequest = client.prepareCount(this.getIndexName()) .setTypes(this.getIndexType()) .setQuery(QueryBuilders.matchAllQuery()); CountResponse response = client.execute(countRequest); - stat.setDocumentCount(response.getCount()); - - /** get Management information */ - stat.setLastUpdate(getLastSynchronization()); - return stat; + return new IndexStat(getLastSynchronization(), response.getCount()); } /* Synchronization methods */ diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexStat.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexStat.java index 521e5a5b9e8..fdddd34526a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexStat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexStat.java @@ -19,29 +19,26 @@ */ package org.sonar.server.search; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import java.util.Date; -/** - * @since 4.4 - */ public class IndexStat { - private Date lastUpdate; - private Long documentCount; - - public Date getLastUpdate() { - return lastUpdate; - } + private final Date lastUpdate; + private final long documentCount; - public void setLastUpdate(Date lastUpdate) { + public IndexStat(@Nullable Date lastUpdate, long documentCount) { this.lastUpdate = lastUpdate; + this.documentCount = documentCount; } - public Long getDocumentCount() { - return documentCount; + @CheckForNull + public Date getLastUpdate() { + return lastUpdate; } - public void setDocumentCount(Long documentCount) { - this.documentCount = documentCount; + public long getDocumentCount() { + return documentCount; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java index c9b5f028a3a..ea2b1ca6a0a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java @@ -63,7 +63,7 @@ public class IndexSynchronizer { } void synchronize(DbSession session, Dao dao, Index index) { - Long count = index.getIndexStat().getDocumentCount(); + long count = index.getIndexStat().getDocumentCount(); Date lastSynch = index.getLastSynchronization(); if (count <= 0) { LOG.info("Initial indexing of {} records", index.getIndexType()); |