Search in sources :

Example 1 with User

use of org.codelibs.fess.es.user.exentity.User 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 2 with User

use of org.codelibs.fess.es.user.exentity.User in project fess by codelibs.

the class ApiAdminUserAction method delete$setting.

// DELETE /api/admin/user/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
    final User entity = userService.getUser(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 {
        userService.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 : List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) UserPager(org.codelibs.fess.app.pager.UserPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) UserService(org.codelibs.fess.app.service.UserService) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 3 with User

use of org.codelibs.fess.es.user.exentity.User in project fess by codelibs.

the class ApiAdminUserAction method settings.

// GET /api/admin/user
// POST /api/admin/user
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final UserPager pager = copyBeanToNewBean(body, UserPager.class);
    final List<User> list = userService.getUserList(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 : AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) UserPager(org.codelibs.fess.app.pager.UserPager) Execute(org.lastaflute.web.Execute)

Example 4 with User

use of org.codelibs.fess.es.user.exentity.User in project fess by codelibs.

the class ApiAdminUserAction method post$setting.

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

Example 5 with User

use of org.codelibs.fess.es.user.exentity.User in project fess by codelibs.

the class ApiAdminUserAction method put$setting.

// PUT /api/admin/user/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final User entity = getUser(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        userService.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());
}
Also used : List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) UserPager(org.codelibs.fess.app.pager.UserPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) Execute(org.lastaflute.web.Execute) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) UserService(org.codelibs.fess.app.service.UserService) User(org.codelibs.fess.es.user.exentity.User) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminUserAction.getUser(org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser) User(org.codelibs.fess.es.user.exentity.User) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Aggregations

User (org.codelibs.fess.es.user.exentity.User)9 Collectors (java.util.stream.Collectors)8 List (java.util.List)7 ApiResult (org.codelibs.fess.app.web.api.ApiResult)5 Execute (org.lastaflute.web.Execute)5 Resource (javax.annotation.Resource)4 UserPager (org.codelibs.fess.app.pager.UserPager)4 CrudMode (org.codelibs.fess.app.web.CrudMode)4 AdminUserAction.getUser (org.codelibs.fess.app.web.admin.user.AdminUserAction.getUser)4 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)4 Group (org.codelibs.fess.es.user.exentity.Group)4 JsonResponse (org.lastaflute.web.response.JsonResponse)4 ArrayList (java.util.ArrayList)3 Base64 (java.util.Base64)3 Collections (java.util.Collections)3 Hashtable (java.util.Hashtable)3 Locale (java.util.Locale)3 BiConsumer (java.util.function.BiConsumer)3 Consumer (java.util.function.Consumer)3 Supplier (java.util.function.Supplier)3