use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.
the class ApiAdminSchedulerAction method post$setting.
// POST /api/admin/scheduler/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final ScheduledJob entity = getScheduledJob(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
});
return null;
});
try {
scheduledJobService.store(entity);
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(false).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.
the class ApiAdminSearchlistAction method delete$doc.
// DELETE /api/admin/searchlist/doc/{id}
@Execute
public JsonResponse<ApiResult> delete$doc(final String id) {
try {
final QueryBuilder query = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), id);
fessEsClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), query);
saveInfo(messages -> messages.addSuccessDeleteDocFromIndex(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsFailedToDeleteDocInAdmin(GLOBAL));
}
return asJson(new ApiResponse().status(Status.OK).result());
}
use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.
the class ApiAdminGroupAction method put$setting.
// PUT /api/admin/group/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final Group entity = getGroup(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
});
return null;
});
try {
groupService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(true).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.response.JsonResponse in project fess by codelibs.
the class ApiAdminKeymatchAction method put$setting.
// PUT /api/admin/keymatch/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final KeyMatch keyMatch = getKeyMatch(body).map(entity -> {
try {
keyMatchService.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(keyMatch.getId()).created(true).status(Status.OK).result());
}
use of org.lastaflute.web.response.JsonResponse 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());
}
Aggregations