]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 4 Nov 2014 15:57:04 +0000 (16:57 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 4 Nov 2014 15:57:13 +0000 (16:57 +0100)
20 files changed:
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyBulkRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCountRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyFlushRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyGetRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyRefreshRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java
server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java [new file with mode: 0644]

index 1880e3e098e769669ae7e8127f37f9bb6efb5d4d..a2bd856d303885abccd60dc860f6c1d208172445 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.sonar.server.issue.index;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import org.elasticsearch.action.update.UpdateRequest;
@@ -54,7 +55,7 @@ public class IssueAuthorizationNormalizer extends BaseNormalizer<IssueAuthorizat
   public List<UpdateRequest> normalize(IssueAuthorizationDto dto) {
     Map<String, Object> update = new HashMap<String, Object>();
 
-//    Preconditions.checkNotNull(dto.getProjectUuid(), "Project uuid is null");
+    Preconditions.checkNotNull(dto.getProjectUuid(), "Project uuid is null");
 
     update.put(IssueAuthorizationField.PROJECT.field(), dto.getProjectUuid());
     update.put(IssueAuthorizationField.USERS.field(), dto.getUsers());
index c322c0ae488dddd10e889f674ea4360ea1175d93..e6e94fa6cbfb583d367c58f641a7ac3ffed832ce 100644 (file)
@@ -38,13 +38,7 @@ import org.sonar.server.search.BaseNormalizer;
 import org.sonar.server.search.IndexField;
 import org.sonar.server.search.Indexable;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
 
index 821ed4526ad3d72a20051735def879f157a4e604..5947bfb33eb91a51e9654830ff0be733376e3455 100644 (file)
@@ -44,7 +44,7 @@ public class IndexDefinition {
   public static final IndexDefinition LOG = new IndexDefinition("logs", "sonarLog");
 
   // Only used for test
-  public static IndexDefinition TEST = new IndexDefinition("test", "test");
+  static final IndexDefinition TEST = new IndexDefinition("test", "test");
 
   public static IndexDefinition createFor(String indexName, String indexType) {
     return new IndexDefinition(indexName, indexType);
index b0e2d19cb577998de4bc4e6bb7f3003ed5baed6d..d99a2c35772850fcbe6816f37fde06bfde8b81e4 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -28,22 +27,22 @@ import org.elasticsearch.action.bulk.BulkResponse;
 import org.elasticsearch.action.delete.DeleteRequest;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.update.UpdateRequest;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyBulkRequestBuilder extends BulkRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyBulkRequestBuilder(Client client, Profiling profiling) {
+  public ProxyBulkRequestBuilder(SearchClient client, Profiling profiling) {
     super(client);
     this.profiling = profiling;
   }
 
   @Override
-  public BulkResponse get() throws ElasticsearchException {
+  public BulkResponse get() {
     StopWatch fullProfile = profiling.start("bulk", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -57,12 +56,12 @@ public class ProxyBulkRequestBuilder extends BulkRequestBuilder {
   }
 
   @Override
-  public BulkResponse get(TimeValue timeout) throws ElasticsearchException {
+  public BulkResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public BulkResponse get(String timeout) throws ElasticsearchException {
+  public BulkResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -71,6 +70,7 @@ public class ProxyBulkRequestBuilder extends BulkRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES bulk request for ");
index ffb4115b1a8359265bc4808f533294439820fd15..68699d0de416d50bf2dce75059c11f3ced11517f 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyClusterHealthRequestBuilder extends ClusterHealthRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyClusterHealthRequestBuilder(Client client, Profiling profiling) {
+  public ProxyClusterHealthRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().cluster());
     this.profiling = profiling;
   }
 
   @Override
-  public ClusterHealthResponse get() throws ElasticsearchException {
+  public ClusterHealthResponse get() {
     StopWatch fullProfile = profiling.start("cluster health", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyClusterHealthRequestBuilder extends ClusterHealthRequestBuilde
   }
 
   @Override
-  public ClusterHealthResponse get(TimeValue timeout) throws ElasticsearchException {
+  public ClusterHealthResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public ClusterHealthResponse get(String timeout) throws ElasticsearchException {
+  public ClusterHealthResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyClusterHealthRequestBuilder extends ClusterHealthRequestBuilde
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES cluster health request");
index dee688924418e012805caf437002bb5947959c3e..1c3610e1d2a714d63d08e141e7e7c45b23557bef 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
 import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyClusterStateRequestBuilder extends ClusterStateRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyClusterStateRequestBuilder(Client client, Profiling profiling) {
+  public ProxyClusterStateRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().cluster());
     this.profiling = profiling;
   }
 
   @Override
-  public ClusterStateResponse get() throws ElasticsearchException {
+  public ClusterStateResponse get() {
     StopWatch fullProfile = profiling.start("cluster state", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyClusterStateRequestBuilder extends ClusterStateRequestBuilder
   }
 
   @Override
-  public ClusterStateResponse get(TimeValue timeout) throws ElasticsearchException {
+  public ClusterStateResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public ClusterStateResponse get(String timeout) throws ElasticsearchException {
+  public ClusterStateResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyClusterStateRequestBuilder extends ClusterStateRequestBuilder
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES cluster state request");
index ec47c0aa25486a35d9ee097bd1fe808c1457720b..6a76aac7ce40ec00a6342ec304c57ab3bc392899 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder;
 import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyClusterStatsRequestBuilder extends ClusterStatsRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyClusterStatsRequestBuilder(Client client, Profiling profiling) {
+  public ProxyClusterStatsRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().cluster());
     this.profiling = profiling;
   }
 
   @Override
-  public ClusterStatsResponse get() throws ElasticsearchException {
+  public ClusterStatsResponse get() {
     StopWatch fullProfile = profiling.start("cluster stats", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyClusterStatsRequestBuilder extends ClusterStatsRequestBuilder
   }
 
   @Override
-  public ClusterStatsResponse get(TimeValue timeout) throws ElasticsearchException {
+  public ClusterStatsResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public ClusterStatsResponse get(String timeout) throws ElasticsearchException {
+  public ClusterStatsResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyClusterStatsRequestBuilder extends ClusterStatsRequestBuilder
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES cluster stats request");
index ad55ef19f0a372053c7d9db545972233c50dca00..7af342d9dd75d2f11542334508e087b9c7228029 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.count.CountRequestBuilder;
 import org.elasticsearch.action.count.CountResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyCountRequestBuilder extends CountRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyCountRequestBuilder(Client client, Profiling profiling) {
+  public ProxyCountRequestBuilder(SearchClient client, Profiling profiling) {
     super(client);
     this.profiling = profiling;
   }
 
   @Override
-  public CountResponse get() throws ElasticsearchException {
+  public CountResponse get() {
     StopWatch fullProfile = profiling.start("count", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyCountRequestBuilder extends CountRequestBuilder {
   }
 
   @Override
-  public CountResponse get(TimeValue timeout) throws ElasticsearchException {
+  public CountResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public CountResponse get(String timeout) throws ElasticsearchException {
+  public CountResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyCountRequestBuilder extends CountRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES count request");
index 886088a0a53c5915a299141958c143beef9126c5..fdc47425319c3709ad5e89c9bd6e402b5f373b53 100644 (file)
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyCreateIndexRequestBuilder extends CreateIndexRequestBuilder {
 
   private final Profiling profiling;
   private final String index;
 
-  public ProxyCreateIndexRequestBuilder(Client client, Profiling profiling, String index) {
+  public ProxyCreateIndexRequestBuilder(SearchClient client, Profiling profiling, String index) {
     super(client.admin().indices(), index);
     this.profiling = profiling;
     this.index = index;
   }
 
   @Override
-  public CreateIndexResponse get() throws ElasticsearchException {
+  public CreateIndexResponse get() {
     StopWatch fullProfile = profiling.start("create index", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -55,12 +54,12 @@ public class ProxyCreateIndexRequestBuilder extends CreateIndexRequestBuilder {
   }
 
   @Override
-  public CreateIndexResponse get(TimeValue timeout) throws ElasticsearchException {
+  public CreateIndexResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public CreateIndexResponse get(String timeout) throws ElasticsearchException {
+  public CreateIndexResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -69,6 +68,7 @@ public class ProxyCreateIndexRequestBuilder extends CreateIndexRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     return String.format("ES create index '%s'", index);
   }
index 3a846bacf8c07b85135ff4613136c652d863defd..803843235051b740065b6e8f496ebf472df8cf72 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
 import org.elasticsearch.action.admin.indices.flush.FlushResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyFlushRequestBuilder extends FlushRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyFlushRequestBuilder(Client client, Profiling profiling) {
+  public ProxyFlushRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().indices());
     this.profiling = profiling;
   }
 
   @Override
-  public FlushResponse get() throws ElasticsearchException {
+  public FlushResponse get() {
     StopWatch fullProfile = profiling.start("flush", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyFlushRequestBuilder extends FlushRequestBuilder {
   }
 
   @Override
-  public FlushResponse get(TimeValue timeout) throws ElasticsearchException {
+  public FlushResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public FlushResponse get(String timeout) throws ElasticsearchException {
+  public FlushResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyFlushRequestBuilder extends FlushRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES flush request");
index 596b3bf5275be50f665b4039e3c865373179cbe9..ea764d3649096825b312d707512129b6507470c6 100644 (file)
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.get.GetRequestBuilder;
 import org.elasticsearch.action.get.GetResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyGetRequestBuilder extends GetRequestBuilder {
 
-  private static final Logger LOGGER = LoggerFactory.getLogger(ProxyGetRequestBuilder.class);
-
   private final Profiling profiling;
 
-  public ProxyGetRequestBuilder(Client client, Profiling profiling) {
+  public ProxyGetRequestBuilder(SearchClient client, Profiling profiling) {
     super(client);
     this.profiling = profiling;
   }
@@ -57,12 +52,12 @@ public class ProxyGetRequestBuilder extends GetRequestBuilder {
   }
 
   @Override
-  public GetResponse get(TimeValue timeout) throws ElasticsearchException {
+  public GetResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public GetResponse get(String timeout) throws ElasticsearchException {
+  public GetResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -71,6 +66,7 @@ public class ProxyGetRequestBuilder extends GetRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder().append("ES get request");
     message.append(String.format(" for key '%s'", request.id()));
index b77ff5b02cfd7162d63c9a545dc0461da734ace2..a4bc27c0cf45db7252f9ad3349035c0e69b07d61 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyIndicesExistsRequestBuilder extends IndicesExistsRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyIndicesExistsRequestBuilder(Client client, Profiling profiling, String... indices) {
+  public ProxyIndicesExistsRequestBuilder(SearchClient client, Profiling profiling, String... indices) {
     super(client.admin().indices(), indices);
     this.profiling = profiling;
   }
 
   @Override
-  public IndicesExistsResponse get() throws ElasticsearchException {
+  public IndicesExistsResponse get() {
     StopWatch fullProfile = profiling.start("indices exists", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyIndicesExistsRequestBuilder extends IndicesExistsRequestBuilde
   }
 
   @Override
-  public IndicesExistsResponse get(TimeValue timeout) throws ElasticsearchException {
+  public IndicesExistsResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public IndicesExistsResponse get(String timeout) throws ElasticsearchException {
+  public IndicesExistsResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyIndicesExistsRequestBuilder extends IndicesExistsRequestBuilde
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES indices exists request");
index b4f6889df05bc9ae9b3f86d5a7cc4f4053164e34..8b02e3f25e05e42f050e43f0d4167e87ab710b34 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
 import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyIndicesStatsRequestBuilder extends IndicesStatsRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyIndicesStatsRequestBuilder(Client client, Profiling profiling) {
+  public ProxyIndicesStatsRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().indices());
     this.profiling = profiling;
   }
 
   @Override
-  public IndicesStatsResponse get() throws ElasticsearchException {
+  public IndicesStatsResponse get() {
     StopWatch fullProfile = profiling.start("indices stats", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyIndicesStatsRequestBuilder extends IndicesStatsRequestBuilder
   }
 
   @Override
-  public IndicesStatsResponse get(TimeValue timeout) throws ElasticsearchException {
+  public IndicesStatsResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public IndicesStatsResponse get(String timeout) throws ElasticsearchException {
+  public IndicesStatsResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyIndicesStatsRequestBuilder extends IndicesStatsRequestBuilder
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES indices stats request");
index 41bb0ae60779811dd7f58881cf08fc54d8c0007c..627d8ea5a5e33cbf9651384e4261124f64b2f163 100644 (file)
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.get.MultiGetRequest;
 import org.elasticsearch.action.get.MultiGetRequestBuilder;
 import org.elasticsearch.action.get.MultiGetResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyMultiGetRequestBuilder(Client client, Profiling profiling) {
+  public ProxyMultiGetRequestBuilder(SearchClient client, Profiling profiling) {
     super(client);
     this.profiling = profiling;
   }
 
   @Override
-  public MultiGetResponse get() throws ElasticsearchException {
+  public MultiGetResponse get() {
     StopWatch fullProfile = profiling.start("get", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
   }
 
   @Override
-  public MultiGetResponse get(TimeValue timeout) throws ElasticsearchException {
+  public MultiGetResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public MultiGetResponse get(String timeout) throws ElasticsearchException {
+  public MultiGetResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES multi get request");
index d2742a795aacd945d20c5bab55a57c1cae01991f..6f921ce7960964f2b8aea0b682c6b3f72fecb0b2 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilder;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyNodesStatsRequestBuilder extends NodesStatsRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyNodesStatsRequestBuilder(Client client, Profiling profiling) {
+  public ProxyNodesStatsRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().cluster());
     this.profiling = profiling;
   }
 
   @Override
-  public NodesStatsResponse get() throws ElasticsearchException {
+  public NodesStatsResponse get() {
     StopWatch fullProfile = profiling.start("nodes stats", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyNodesStatsRequestBuilder extends NodesStatsRequestBuilder {
   }
 
   @Override
-  public NodesStatsResponse get(TimeValue timeout) throws ElasticsearchException {
+  public NodesStatsResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public NodesStatsResponse get(String timeout) throws ElasticsearchException {
+  public NodesStatsResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyNodesStatsRequestBuilder extends NodesStatsRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES nodes stats request");
index 6bca83a075cd7592fc605fcd2c2315bf0252a249..69459171ff7aad7a91dad3ca95c9041267203369 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyPutMappingRequestBuilder extends PutMappingRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyPutMappingRequestBuilder(Client client, Profiling profiling) {
+  public ProxyPutMappingRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().indices());
     this.profiling = profiling;
   }
 
   @Override
-  public PutMappingResponse get() throws ElasticsearchException {
+  public PutMappingResponse get() {
     StopWatch fullProfile = profiling.start("put mapping", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyPutMappingRequestBuilder extends PutMappingRequestBuilder {
   }
 
   @Override
-  public PutMappingResponse get(TimeValue timeout) throws ElasticsearchException {
+  public PutMappingResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public PutMappingResponse get(String timeout) throws ElasticsearchException {
+  public PutMappingResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyPutMappingRequestBuilder extends PutMappingRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES put mapping request");
index fd2dca107c522702fb97a06cbcdc128c132a794a..cc76ea6fb66162dff40d91e07f8674f3398ee9c1 100644 (file)
 package org.sonar.server.search.request;
 
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder;
 import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxyRefreshRequestBuilder extends RefreshRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxyRefreshRequestBuilder(Client client, Profiling profiling) {
+  public ProxyRefreshRequestBuilder(SearchClient client, Profiling profiling) {
     super(client.admin().indices());
     this.profiling = profiling;
   }
 
   @Override
-  public RefreshResponse get() throws ElasticsearchException {
+  public RefreshResponse get() {
     StopWatch fullProfile = profiling.start("refresh", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -54,12 +53,12 @@ public class ProxyRefreshRequestBuilder extends RefreshRequestBuilder {
   }
 
   @Override
-  public RefreshResponse get(TimeValue timeout) throws ElasticsearchException {
+  public RefreshResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public RefreshResponse get(String timeout) throws ElasticsearchException {
+  public RefreshResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -68,6 +67,7 @@ public class ProxyRefreshRequestBuilder extends RefreshRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append("ES refresh request");
index 08b68a81ce7bf47cc6d96fc6661e54a51ae53346..66a61f22b0ef94d0e80dd22edbd422cb1179fb92 100644 (file)
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.common.xcontent.ToXContent;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -39,13 +38,13 @@ public class ProxySearchRequestBuilder extends SearchRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxySearchRequestBuilder(Client client, Profiling profiling) {
+  public ProxySearchRequestBuilder(SearchClient client, Profiling profiling) {
     super(client);
     this.profiling = profiling;
   }
 
   @Override
-  public SearchResponse get() throws ElasticsearchException {
+  public SearchResponse get() {
     StopWatch fullProfile = profiling.start("search", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -59,12 +58,12 @@ public class ProxySearchRequestBuilder extends SearchRequestBuilder {
   }
 
   @Override
-  public SearchResponse get(TimeValue timeout) throws ElasticsearchException {
+  public SearchResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public SearchResponse get(String timeout) throws ElasticsearchException {
+  public SearchResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -73,6 +72,7 @@ public class ProxySearchRequestBuilder extends SearchRequestBuilder {
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     StringBuilder message = new StringBuilder();
     message.append(String.format("ES search request '%s'", xContentToString(super.internalBuilder())));
index 214832bf6480e338d3b92abf5446cd0048c9ccc6..0cb21e8e2926af23c7264a52dbdcf3223998aae0 100644 (file)
 
 package org.sonar.server.search.request;
 
-import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.ListenableActionFuture;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.search.SearchScrollRequestBuilder;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.StopWatch;
+import org.sonar.server.search.SearchClient;
 
 public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder {
 
   private final Profiling profiling;
 
-  public ProxySearchScrollRequestBuilder(String scrollId, Client client, Profiling profiling) {
+  public ProxySearchScrollRequestBuilder(String scrollId, SearchClient client, Profiling profiling) {
     super(client, scrollId);
     this.profiling = profiling;
   }
 
   @Override
-  public SearchResponse get() throws ElasticsearchException {
+  public SearchResponse get() {
     StopWatch fullProfile = profiling.start("search", Profiling.Level.FULL);
     try {
       return super.execute().actionGet();
@@ -53,12 +52,12 @@ public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder
   }
 
   @Override
-  public SearchResponse get(TimeValue timeout) throws ElasticsearchException {
+  public SearchResponse get(TimeValue timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
   @Override
-  public SearchResponse get(String timeout) throws ElasticsearchException {
+  public SearchResponse get(String timeout) {
     throw new IllegalStateException("Not yet implemented");
   }
 
@@ -67,6 +66,7 @@ public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder
     throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
   }
 
+  @Override
   public String toString() {
     return String.format("ES search scroll request for scroll id '%s'", super.request().scroll());
   }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java
new file mode 100644 (file)
index 0000000..50f8a08
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.search.request;
+
+import javax.annotation.ParametersAreNonnullByDefault;