Search in sources :

Example 1 with DuplicateHost

use of org.codelibs.fess.es.config.exentity.DuplicateHost in project fess by codelibs.

the class ApiAdminDuplicatehostAction method post$setting.

// POST /api/admin/duplicatehost/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final DuplicateHost duplicateHost = getDuplicateHost(body).map(entity -> {
        try {
            duplicateHostService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(duplicateHost.getId()).created(false).status(Status.OK).result());
}
Also used : DuplicateHostPager(org.codelibs.fess.app.pager.DuplicateHostPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) DuplicateHostService(org.codelibs.fess.app.service.DuplicateHostService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) Execute(org.lastaflute.web.Execute)

Example 2 with DuplicateHost

use of org.codelibs.fess.es.config.exentity.DuplicateHost in project fess by codelibs.

the class ApiAdminDuplicatehostAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/duplicatehost/settings
// POST /api/admin/duplicatehost/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final DuplicateHostPager pager = copyBeanToNewBean(body, DuplicateHostPager.class);
    final List<DuplicateHost> list = duplicateHostService.getDuplicateHostList(pager);
    return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
Also used : ApiResult(org.codelibs.fess.app.web.api.ApiResult) DuplicateHostPager(org.codelibs.fess.app.pager.DuplicateHostPager) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) Execute(org.lastaflute.web.Execute)

Example 3 with DuplicateHost

use of org.codelibs.fess.es.config.exentity.DuplicateHost in project fess by codelibs.

the class ApiAdminDuplicatehostAction method put$setting.

// PUT /api/admin/duplicatehost/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final DuplicateHost duplicateHost = getDuplicateHost(body).map(entity -> {
        try {
            duplicateHostService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(duplicateHost.getId()).created(true).status(Status.OK).result());
}
Also used : DuplicateHostPager(org.codelibs.fess.app.pager.DuplicateHostPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) DuplicateHostService(org.codelibs.fess.app.service.DuplicateHostService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) Execute(org.lastaflute.web.Execute)

Example 4 with DuplicateHost

use of org.codelibs.fess.es.config.exentity.DuplicateHost in project fess by codelibs.

the class DuplicateHostHelperTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    duplicateHostHelper = new DuplicateHostHelper();
    duplicateHostHelper.duplicateHostList = new ArrayList<DuplicateHost>();
    DuplicateHost foo = new DuplicateHost();
    foo.setRegularName("www.foo.com");
    foo.setDuplicateHostName("foo.com");
    duplicateHostHelper.duplicateHostList.add(foo);
    DuplicateHost bar = new DuplicateHost();
    bar.setRegularName("www.bar.com");
    bar.setDuplicateHostName("mail.bar.com");
    duplicateHostHelper.duplicateHostList.add(bar);
}
Also used : DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost)

Aggregations

DuplicateHost (org.codelibs.fess.es.config.exentity.DuplicateHost)4 DuplicateHostPager (org.codelibs.fess.app.pager.DuplicateHostPager)3 AdminDuplicatehostAction.getDuplicateHost (org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost)3 ApiResult (org.codelibs.fess.app.web.api.ApiResult)3 Execute (org.lastaflute.web.Execute)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 DuplicateHostService (org.codelibs.fess.app.service.DuplicateHostService)2 CrudMode (org.codelibs.fess.app.web.CrudMode)2 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)2 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)2 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)2 Status (org.codelibs.fess.app.web.api.ApiResult.Status)2 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)2 JsonResponse (org.lastaflute.web.response.JsonResponse)2