use of org.codelibs.fess.app.web.api.ApiResult.Status in project fess by codelibs.
the class ApiAdminFileauthAction method post$setting.
// POST /api/admin/fileauth/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final FileAuthentication fileAuth = getFileAuthentication(body).map(entity -> {
try {
fileAuthService.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(fileAuth.getId()).created(false).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.Status in project fess by codelibs.
the class ApiAdminFileconfigAction method post$setting.
// POST /api/admin/fileconfig/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final FileConfig fileConfig = getFileConfig(body).map(entity -> {
try {
fileConfigService.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(fileConfig.getId()).created(false).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.Status in project fess by codelibs.
the class ApiAdminAccesstokenAction method put$setting.
// PUT /api/admin/accesstoken/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final AccessToken accessToken = getAccessToken(body).map(entity -> {
entity.setToken(systemHelper.generateAccessToken());
try {
accessTokenService.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(accessToken.getId()).created(true).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.Status in project fess by codelibs.
the class ApiAdminBoostdocAction method post$setting.
// POST /api/admin/boostdoc/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final BoostDocumentRule boostDoc = getBoostDocumentRule(body).map(entity -> {
try {
boostDocumentRuleService.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(boostDoc.getId()).created(false).status(Status.OK).result());
}
use of org.codelibs.fess.app.web.api.ApiResult.Status in project fess by codelibs.
the class ApiAdminCrawlinginfoAction method delete$all.
// DELETE /api/admin/crawlinginfo/all
@Execute
public JsonResponse<ApiResult> delete$all() {
try {
crawlingInfoService.deleteOldSessions(processHelper.getRunningSessionIdSet());
saveInfo(messages -> messages.addSuccessCrawlingInfoDeleteAll(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResponse().status(Status.OK).result());
}
Aggregations