Search in sources :

Example 56 with Execute

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

the class ApiAdminReqheaderAction method settings.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/reqheader/settings
// POST /api/admin/reqheader/settings
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final ReqHeaderPager pager = copyBeanToNewBean(body, ReqHeaderPager.class);
    final List<RequestHeader> list = reqHeaderService.getRequestHeaderList(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 : ReqHeaderPager(org.codelibs.fess.app.pager.ReqHeaderPager) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminReqheaderAction.getRequestHeader(org.codelibs.fess.app.web.admin.reqheader.AdminReqheaderAction.getRequestHeader) RequestHeader(org.codelibs.fess.es.config.exentity.RequestHeader) Execute(org.lastaflute.web.Execute)

Example 57 with Execute

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

the class ApiAdminKeymatchAction method post$setting.

// POST /api/admin/keymatch/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final KeyMatch keyMatch = getKeyMatch(body).map(entity -> {
        try {
            keyMatchService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(keyMatch.getId()).created(false).status(Status.OK).result());
}
Also used : 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) KeyMatchService(org.codelibs.fess.app.service.KeyMatchService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) KeyMatch(org.codelibs.fess.es.config.exentity.KeyMatch) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminKeymatchAction.getKeyMatch(org.codelibs.fess.app.web.admin.keymatch.AdminKeymatchAction.getKeyMatch) KeyMatchPager(org.codelibs.fess.app.pager.KeyMatchPager) KeyMatch(org.codelibs.fess.es.config.exentity.KeyMatch) AdminKeymatchAction.getKeyMatch(org.codelibs.fess.app.web.admin.keymatch.AdminKeymatchAction.getKeyMatch) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 58 with Execute

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

the class ApiAdminLabeltypeAction method post$setting.

// POST /api/admin/labeltype/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final LabelType labelType = getLabelType(body).map(entity -> {
        try {
            labelTypeService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(labelType.getId()).created(false).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)

Example 59 with Execute

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

the class ApiAdminPathmapAction method delete$setting.

// DELETE /api/admin/pathmap/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
    final PathMapping entity = pathMappingService.getPathMapping(id).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
        return null;
    });
    try {
        pathMappingService.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 : PathMapPager(org.codelibs.fess.app.pager.PathMapPager) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) PathMappingService(org.codelibs.fess.app.service.PathMappingService) ApiResult(org.codelibs.fess.app.web.api.ApiResult) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) Execute(org.lastaflute.web.Execute)

Example 60 with Execute

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

the class SsoAction method index.

// ===================================================================================
//                                                                       Login Execute
//                                                                      ==============
@Execute
public ActionResponse index() {
    final SsoManager ssoManager = ComponentUtil.getSsoManager();
    final LoginCredential loginCredential = ssoManager.getLoginCredential();
    if (loginCredential == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("No user in SSO request.");
        }
        if (ssoManager.available()) {
            saveError(messages -> messages.addErrorsSsoLoginError(GLOBAL));
        }
        return redirect(LoginAction.class);
    } else if (loginCredential instanceof ActionResponseCredential) {
        return ((ActionResponseCredential) loginCredential).execute();
    }
    try {
        return fessLoginAssist.loginRedirect(loginCredential, op -> {
        }, () -> {
            activityHelper.login(getUserBean());
            userInfoHelper.deleteUserCodeFromCookie(request);
            return getHtmlResponse();
        });
    } catch (final LoginFailureException lfe) {
        if (logger.isDebugEnabled()) {
            logger.debug("SSO login failure.", lfe);
        }
        if (ssoManager.available()) {
            saveError(messages -> messages.addErrorsSsoLoginError(GLOBAL));
        }
        return redirect(LoginAction.class);
    }
}
Also used : FessLoginAction(org.codelibs.fess.app.web.base.FessLoginAction) ActionResponse(org.lastaflute.web.response.ActionResponse) Logger(org.slf4j.Logger) ActionResponseCredential(org.codelibs.fess.app.web.base.login.ActionResponseCredential) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SsoManager(org.codelibs.fess.sso.SsoManager) Execute(org.lastaflute.web.Execute) LoggerFactory(org.slf4j.LoggerFactory) LoginCredential(org.lastaflute.web.login.credential.LoginCredential) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) LoginAction(org.codelibs.fess.app.web.login.LoginAction) LoginFailureException(org.lastaflute.web.login.exception.LoginFailureException) LoginCredential(org.lastaflute.web.login.credential.LoginCredential) FessLoginAction(org.codelibs.fess.app.web.base.FessLoginAction) LoginAction(org.codelibs.fess.app.web.login.LoginAction) ActionResponseCredential(org.codelibs.fess.app.web.base.login.ActionResponseCredential) SsoManager(org.codelibs.fess.sso.SsoManager) 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