Search in sources :

Example 11 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminGroupAction method settings.

// GET /api/admin/group
// POST /api/admin/group
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final GroupPager pager = copyBeanToNewBean(body, GroupPager.class);
    final List<Group> list = groupService.getGroupList(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 : AdminGroupAction.getGroup(org.codelibs.fess.app.web.admin.group.AdminGroupAction.getGroup) Group(org.codelibs.fess.es.user.exentity.Group) GroupPager(org.codelibs.fess.app.pager.GroupPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 12 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminGroupAction method post$setting.

// POST /api/admin/group/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final Group entity = getGroup(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
        });
        return null;
    });
    try {
        groupService.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());
}
Also used : GroupService(org.codelibs.fess.app.service.GroupService) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) GroupPager(org.codelibs.fess.app.pager.GroupPager) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminGroupAction.getGroup(org.codelibs.fess.app.web.admin.group.AdminGroupAction.getGroup) Execute(org.lastaflute.web.Execute) Group(org.codelibs.fess.es.user.exentity.Group) AdminGroupAction.getGroup(org.codelibs.fess.app.web.admin.group.AdminGroupAction.getGroup) Group(org.codelibs.fess.es.user.exentity.Group) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 13 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult 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());
}
Also used : GroupService(org.codelibs.fess.app.service.GroupService) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) GroupPager(org.codelibs.fess.app.pager.GroupPager) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminGroupAction.getGroup(org.codelibs.fess.app.web.admin.group.AdminGroupAction.getGroup) Execute(org.lastaflute.web.Execute) Group(org.codelibs.fess.es.user.exentity.Group) AdminGroupAction.getGroup(org.codelibs.fess.app.web.admin.group.AdminGroupAction.getGroup) Group(org.codelibs.fess.es.user.exentity.Group) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 14 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult 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());
}
Also used : ApiResult(org.codelibs.fess.app.web.api.ApiResult) JobLogPager(org.codelibs.fess.app.pager.JobLogPager) JobLog(org.codelibs.fess.es.config.exentity.JobLog) Execute(org.lastaflute.web.Execute)

Example 15 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult 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());
}
Also used : SeunjeonItem(org.codelibs.fess.dict.seunjeon.SeunjeonItem) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) SeunjeonService(org.codelibs.fess.app.service.SeunjeonService) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) UploadForm(org.codelibs.fess.app.web.admin.dict.seunjeon.UploadForm) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) SeunjeonFile(org.codelibs.fess.dict.seunjeon.SeunjeonFile) AdminDictSeunjeonAction(org.codelibs.fess.app.web.admin.dict.seunjeon.AdminDictSeunjeonAction) Execute(org.lastaflute.web.Execute) InputStream(java.io.InputStream) SeunjeonPager(org.codelibs.fess.app.pager.SeunjeonPager) SeunjeonPager(org.codelibs.fess.app.pager.SeunjeonPager) Execute(org.lastaflute.web.Execute)

Aggregations

ApiResult (org.codelibs.fess.app.web.api.ApiResult)88 Execute (org.lastaflute.web.Execute)88 Resource (javax.annotation.Resource)65 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)65 JsonResponse (org.lastaflute.web.response.JsonResponse)65 CrudMode (org.codelibs.fess.app.web.CrudMode)63 Collectors (java.util.stream.Collectors)61 List (java.util.List)43 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)31 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 InputStream (java.io.InputStream)23 StreamResponse (org.lastaflute.web.response.StreamResponse)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 File (java.io.File)18 Constants (org.codelibs.fess.Constants)12 StringUtil (org.codelibs.core.lang.StringUtil)9 ComponentUtil (org.codelibs.fess.util.ComponentUtil)9 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7