Search in sources :

Example 1 with PathMapping

use of org.codelibs.fess.es.config.exentity.PathMapping in project fess by codelibs.

the class ApiAdminPathmapAction method post$setting.

// POST /api/admin/pathmap/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final PathMapping entity = getPathMapping(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
        });
        return null;
    });
    try {
        pathMappingService.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 : 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 2 with PathMapping

use of org.codelibs.fess.es.config.exentity.PathMapping in project fess by codelibs.

the class ApiAdminPathmapAction method settings.

// GET /api/admin/pathmap
// POST /api/admin/pathmap
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final PathMapPager pager = copyBeanToNewBean(body, PathMapPager.class);
    final List<PathMapping> list = pathMappingService.getPathMappingList(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) PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) AdminPathmapAction.getPathMapping(org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping) PathMapPager(org.codelibs.fess.app.pager.PathMapPager) Execute(org.lastaflute.web.Execute)

Example 3 with PathMapping

use of org.codelibs.fess.es.config.exentity.PathMapping 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 4 with PathMapping

use of org.codelibs.fess.es.config.exentity.PathMapping in project fess by codelibs.

the class PathMappingHelperTest method test_replaceUrls.

public void test_replaceUrls() {
    final List<PathMapping> pathMappingList = new ArrayList<PathMapping>();
    final PathMapping pathMapping = new PathMapping();
    pathMapping.setRegex("file:///home/");
    pathMapping.setReplacement("http://localhost/");
    pathMappingList.add(pathMapping);
    pathMappingHelper.cachedPathMappingList = pathMappingList;
    String text = "\"file:///home/\"";
    assertEquals("\"http://localhost/\"", pathMappingHelper.replaceUrls(text));
    text = "\"file:///home/user/\"";
    assertEquals("\"http://localhost/user/\"", pathMappingHelper.replaceUrls(text));
    text = "\"aaafile:///home/user/\"";
    assertEquals("\"aaahttp://localhost/user/\"", pathMappingHelper.replaceUrls(text));
    text = "aaa\"file:///home/user/\"bbb";
    assertEquals("aaa\"http://localhost/user/\"bbb", pathMappingHelper.replaceUrls(text));
}
Also used : PathMapping(org.codelibs.fess.es.config.exentity.PathMapping) ArrayList(java.util.ArrayList)

Example 5 with PathMapping

use of org.codelibs.fess.es.config.exentity.PathMapping in project fess by codelibs.

the class ApiAdminPathmapAction method put$setting.

// PUT /api/admin/pathmap/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final PathMapping entity = getPathMapping(body).orElseGet(() -> {
        throwValidationErrorApi(messages -> {
            messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
        });
        return null;
    });
    try {
        pathMappingService.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 : 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)

Aggregations

PathMapping (org.codelibs.fess.es.config.exentity.PathMapping)6 PathMapPager (org.codelibs.fess.app.pager.PathMapPager)4 AdminPathmapAction.getPathMapping (org.codelibs.fess.app.web.admin.pathmap.AdminPathmapAction.getPathMapping)4 ApiResult (org.codelibs.fess.app.web.api.ApiResult)4 Execute (org.lastaflute.web.Execute)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Resource (javax.annotation.Resource)3 Constants (org.codelibs.fess.Constants)3 PathMappingService (org.codelibs.fess.app.service.PathMappingService)3 CrudMode (org.codelibs.fess.app.web.CrudMode)3 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)3 JsonResponse (org.lastaflute.web.response.JsonResponse)3 ArrayList (java.util.ArrayList)2