Search in sources :

Example 66 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminRoleAction method put$setting.

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

Example 67 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminRoleAction method post$setting.

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

Example 68 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class LoginAction method login.

@Execute
public HtmlResponse login(final LoginForm form) {
    validate(form, messages -> {
    }, () -> asIndexPage(form));
    verifyToken(() -> asIndexPage(form));
    final String username = form.username;
    final String password = form.password;
    form.clearSecurityInfo();
    try {
        return fessLoginAssist.loginRedirect(new UserPasswordCredential(username, password), op -> {
        }, () -> {
            activityHelper.login(getUserBean());
            userInfoHelper.deleteUserCodeFromCookie(request);
            return getHtmlResponse();
        });
    } catch (final LoginFailureException lfe) {
        throwValidationError(messages -> messages.addErrorsLoginError(GLOBAL), () -> asIndexPage(form));
    }
    return redirect(getClass());
}
Also used : FessLoginAction(org.codelibs.fess.app.web.base.FessLoginAction) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential) Execute(org.lastaflute.web.Execute) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) HtmlResponse(org.lastaflute.web.response.HtmlResponse) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) UserPasswordCredential(org.lastaflute.web.login.credential.UserPasswordCredential) Execute(org.lastaflute.web.Execute)

Example 69 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminLabeltypeAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/labeltype/settings
// POST /api/admin/labeltype/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final LabelTypePager pager = copyBeanToNewBean(body, LabelTypePager.class);
    final List<LabelType> list = labelTypeService.getLabelTypeList(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 : ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) LabelType(org.codelibs.fess.es.config.exentity.LabelType) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) Execute(org.lastaflute.web.Execute)

Example 70 with Execute

use of org.lastaflute.web.Execute in project fess by codelibs.

the class ApiAdminLabeltypeAction method put$setting.

// PUT /api/admin/labeltype/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final LabelType labelType = getLabelType(body).map(entity -> {
        try {
            labelTypeService.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(labelType.getId()).created(true).status(Status.OK).result());
}
Also used : AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) LabelType(org.codelibs.fess.es.config.exentity.LabelType) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) LabelType(org.codelibs.fess.es.config.exentity.LabelType) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Aggregations

Execute (org.lastaflute.web.Execute)125 ApiResult (org.codelibs.fess.app.web.api.ApiResult)94 Resource (javax.annotation.Resource)83 CrudMode (org.codelibs.fess.app.web.CrudMode)77 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)71 JsonResponse (org.lastaflute.web.response.JsonResponse)71 Collectors (java.util.stream.Collectors)70 List (java.util.List)51 InputStream (java.io.InputStream)39 File (java.io.File)35 StreamResponse (org.lastaflute.web.response.StreamResponse)34 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)32 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 Constants (org.codelibs.fess.Constants)26 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 StringUtil (org.codelibs.core.lang.StringUtil)24 ComponentUtil (org.codelibs.fess.util.ComponentUtil)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 HtmlResponse (org.lastaflute.web.response.HtmlResponse)20 FessAdminAction (org.codelibs.fess.app.web.base.FessAdminAction)14