use of com.enonic.xp.index.UpdateIndexSettingsResult in project xp by enonic.
the class JsonIndexResourceTest method updateSettings.
@Test
public void updateSettings() throws Exception {
final UpdateIndexSettingsResult indexSettingsResult = UpdateIndexSettingsResult.create().addUpdatedIndex("index1").addUpdatedIndex("index2").build();
Mockito.when(this.indexService.updateIndexSettings(isA(UpdateIndexSettingsParams.class))).thenReturn(indexSettingsResult);
Mockito.when(this.repositoryService.list()).thenReturn(Repositories.from(Repository.create().id(RepositoryId.from("my-repo")).branches(Branch.from("master")).build()));
final String result = request().path("repo/index/updateSettings").entity(readFromFile("update_index_settings_params.json"), MediaType.APPLICATION_JSON_TYPE).post().getAsString();
assertJson("update_index_settings.json", result);
}
use of com.enonic.xp.index.UpdateIndexSettingsResult in project xp by enonic.
the class IndexServiceImpl method updateIndexSettings.
@Override
public UpdateIndexSettingsResult updateIndexSettings(final UpdateIndexSettingsParams params) {
final UpdateIndexSettingsResult.Builder result = UpdateIndexSettingsResult.create();
final UpdateIndexSettings updateIndexSettings = UpdateIndexSettings.from(params.getSettings());
for (final RepositoryId repositoryId : params.getRepositoryIds()) {
updateIndexSettings(repositoryId, updateIndexSettings, params.isRequireClosedIndex(), result);
}
return result.build();
}
use of com.enonic.xp.index.UpdateIndexSettingsResult in project xp by enonic.
the class IndexServiceImplTest method updateIndexSettings.
@Test
public void updateIndexSettings() throws Exception {
final UpdateIndexSettingsResult result = this.indexService.updateIndexSettings(UpdateIndexSettingsParams.create().repository(TEST_REPO_ID).settings("{\"index\": {\"number_of_replicas\": 2}}").build());
assertEquals(2, result.getUpdatedIndexes().size());
}
use of com.enonic.xp.index.UpdateIndexSettingsResult in project xp by enonic.
the class IndexResource method updateSettings.
@POST
@Path("updateSettings")
public UpdateIndexSettingsResultJson updateSettings(final UpdateIndexSettingsRequestJson request) {
final RepositoryIds.Builder repositoryIds = RepositoryIds.create();
if (!isNullOrEmpty(request.repositoryId)) {
repositoryIds.add(RepositoryId.from(request.repositoryId));
} else {
repositoryIds.addAll(this.repositoryService.list().getIds());
}
final UpdateIndexSettingsResult result = this.indexService.updateIndexSettings(UpdateIndexSettingsParams.create().repositories(repositoryIds.build()).settings(request.settings.toString()).requireClosedIndex(request.requireClosedIndex).build());
return UpdateIndexSettingsResultJson.create(result);
}
Aggregations