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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations