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());
}
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());
}
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());
}
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);
}
Aggregations