Search in sources :

Example 1 with UpdateIndexSettingsResult

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);
}
Also used : UpdateIndexSettingsResult(com.enonic.xp.index.UpdateIndexSettingsResult) UpdateIndexSettingsParams(com.enonic.xp.index.UpdateIndexSettingsParams) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateIndexSettingsResult

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();
}
Also used : UpdateIndexSettingsResult(com.enonic.xp.index.UpdateIndexSettingsResult) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 3 with UpdateIndexSettingsResult

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());
}
Also used : UpdateIndexSettingsResult(com.enonic.xp.index.UpdateIndexSettingsResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 4 with UpdateIndexSettingsResult

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);
}
Also used : UpdateIndexSettingsResult(com.enonic.xp.index.UpdateIndexSettingsResult) RepositoryIds(com.enonic.xp.repository.RepositoryIds) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

UpdateIndexSettingsResult (com.enonic.xp.index.UpdateIndexSettingsResult)4 Test (org.junit.jupiter.api.Test)2 UpdateIndexSettingsParams (com.enonic.xp.index.UpdateIndexSettingsParams)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1 RepositoryIds (com.enonic.xp.repository.RepositoryIds)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1