use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminGroupAction method delete$setting.
// DELETE /api/admin/group/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
final Group entity = groupService.getGroup(id).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
return null;
});
getUserBean().ifPresent(u -> {
if (u.getFessUser() instanceof User && entity.getName().equals(u.getUserId())) {
throwValidationErrorApi(messages -> messages.addErrorsCouldNotDeleteLoggedInUser(GLOBAL));
}
});
try {
groupService.delete(entity);
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(id).created(false).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminJoblogAction method logs.
// ===================================================================================
// Search Execute
// ==============
// GET /api/admin/joblog/logs
@Execute
public JsonResponse<ApiResult> logs(final SearchBody body) {
validateApi(body, messages -> {
});
final JobLogPager pager = copyBeanToNewBean(body, JobLogPager.class);
final List<JobLog> list = jobLogService.getJobLogList(pager);
return asJson(new ApiResult.ApiLogsResponse<EditBody>().logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminDictSeunjeonAction method get$settings.
// GET /api/admin/dict/seunjeon/settings/{dictId}
@Execute
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
body.dictId = dictId;
validateApi(body, messages -> {
});
final SeunjeonPager pager = copyBeanToNewBean(body, SeunjeonPager.class);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(seunjeonService.getSeunjeonList(body.dictId, pager).stream().map(protwordsItem -> createEditBody(protwordsItem, dictId)).collect(Collectors.toList())).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminDictSynonymAction method post$setting.
// POST /api/admin/dict/synonym/setting/{dictId}
@Execute
public JsonResponse<ApiResult> post$setting(final String dictId, final EditBody body) {
body.dictId = dictId;
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final SynonymItem entity = new AdminDictSynonymAction().createSynonymItem(body, () -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, String.valueOf(body.id)));
return null;
}).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, String.valueOf(body.id)));
return null;
});
synonymService.store(body.dictId, entity);
return asJson(new ApiResult.ApiUpdateResponse().id(String.valueOf(entity.getId())).created(false).status(ApiResult.Status.OK).result());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class ApiAdminDictSynonymAction method get$download.
// GET /api/admin/dict/synonym/download/{dictId}
@Execute
public StreamResponse get$download(final String dictId, final DownloadBody body) {
body.dictId = dictId;
validateApi(body, messages -> {
});
return synonymService.getSynonymFile(body.dictId).map(file -> {
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
try (InputStream inputStream = file.getInputStream()) {
out.write(inputStream);
}
});
}).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL));
return null;
});
}
Aggregations