Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: Move: Return the modified change in JSON response Elasticsearch: fix changes index type for bulk calls Change-Id: I4ecd8cb0e36dc39f376a84eaeede97651b055f83
This commit is contained in:
@@ -93,7 +93,8 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
||||
SitePaths sitePaths,
|
||||
Schema<V> schema,
|
||||
ElasticRestClientProvider client,
|
||||
String indexName) {
|
||||
String indexName,
|
||||
String indexType) {
|
||||
this.sitePaths = sitePaths;
|
||||
this.schema = schema;
|
||||
this.gson = new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
|
||||
@@ -101,7 +102,16 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
||||
this.indexName = cfg.getIndexName(indexName, schema.getVersion());
|
||||
this.indexNameRaw = indexName;
|
||||
this.client = client;
|
||||
this.type = client.adapter().getType(indexName);
|
||||
this.type = client.adapter().getType(indexType);
|
||||
}
|
||||
|
||||
AbstractElasticIndex(
|
||||
ElasticConfiguration cfg,
|
||||
SitePaths sitePaths,
|
||||
Schema<V> schema,
|
||||
ElasticRestClientProvider client,
|
||||
String indexName) {
|
||||
this(cfg, sitePaths, schema, client, indexName, indexName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,6 +99,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
||||
private static final String CHANGES = "changes";
|
||||
private static final String OPEN_CHANGES = "open_" + CHANGES;
|
||||
private static final String CLOSED_CHANGES = "closed_" + CHANGES;
|
||||
private static final String ALL_CHANGES = OPEN_CHANGES + "," + CLOSED_CHANGES;
|
||||
private final ChangeMapping mapping;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
@@ -112,7 +113,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
||||
SitePaths sitePaths,
|
||||
ElasticRestClientProvider client,
|
||||
@Assisted Schema<ChangeData> schema) {
|
||||
super(cfg, sitePaths, schema, client, CHANGES);
|
||||
super(cfg, sitePaths, schema, client, CHANGES, ALL_CHANGES);
|
||||
this.db = db;
|
||||
this.changeDataFactory = changeDataFactory;
|
||||
this.schema = schema;
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.google.gerrit.server.permissions.RefPermission.CREATE_CHANGE;
|
||||
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.extensions.api.changes.MoveInput;
|
||||
@@ -135,12 +136,13 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
|
||||
throw new AuthException("move not permitted", denied);
|
||||
}
|
||||
|
||||
Op op = new Op(input);
|
||||
try (BatchUpdate u =
|
||||
updateFactory.create(dbProvider.get(), project, caller, TimeUtil.nowTs())) {
|
||||
u.addOp(change.getId(), new Op(input));
|
||||
u.addOp(change.getId(), op);
|
||||
u.execute();
|
||||
}
|
||||
return json.noOptions().format(project, rsrc.getId());
|
||||
return json.noOptions().format(op.getChange());
|
||||
}
|
||||
|
||||
private class Op implements BatchUpdateOp {
|
||||
@@ -153,6 +155,11 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Change getChange() {
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, ResourceConflictException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user