diff --git a/src/main/config/es/fess_config.json b/src/main/config/es/fess_config.json index 13cd8a5da..f1435622e 100644 --- a/src/main/config/es/fess_config.json +++ b/src/main/config/es/fess_config.json @@ -1,6 +1,35 @@ { ".fess_config" : { "mappings" : { + "api_token": { + "_all": { + "enabled": false + }, + "properties": { + "name": { + "type": "string", + "index": "not_analyzed" + }, + "token": { + "type": "string", + "index": "not_analyzed" + }, + "createdBy": { + "type": "string", + "index": "not_analyzed" + }, + "createdTime": { + "type": "long" + }, + "updatedBy": { + "type": "string", + "index": "not_analyzed" + }, + "updatedTime": { + "type": "long" + } + } + }, "web_config_to_label" : { "_all" : { "enabled" : false diff --git a/src/main/java/org/codelibs/fess/app/pager/ApiTokenPager.java b/src/main/java/org/codelibs/fess/app/pager/ApiTokenPager.java new file mode 100644 index 000000000..efd912ccf --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/pager/ApiTokenPager.java @@ -0,0 +1,138 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.pager; + +import java.io.Serializable; +import java.util.List; + +import org.codelibs.fess.Constants; + +public class ApiTokenPager implements Serializable { + private static final long serialVersionUID = 1L; + + public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1; + + private int allRecordCount; + + private int allPageCount; + + private boolean existPrePage; + + private boolean existNextPage; + + private List pageNumberList; + + private int pageSize; + + private int currentPageNumber; + + public String id; + + public String name; + + public String createdBy; + + public String createdTime; + + public String versionNo; + + public void clear() { + allRecordCount = 0; + allPageCount = 0; + existPrePage = false; + existNextPage = false; + pageSize = getDefaultPageSize(); + currentPageNumber = getDefaultCurrentPageNumber(); + + id = null; + name = null; + createdBy = null; + createdTime = null; + versionNo = null; + + } + + public int getAllRecordCount() { + return allRecordCount; + } + + public void setAllRecordCount(final int allRecordCount) { + this.allRecordCount = allRecordCount; + } + + public int getAllPageCount() { + return allPageCount; + } + + public void setAllPageCount(final int allPageCount) { + this.allPageCount = allPageCount; + } + + public boolean isExistPrePage() { + return existPrePage; + } + + public void setExistPrePage(final boolean existPrePage) { + this.existPrePage = existPrePage; + } + + public boolean isExistNextPage() { + return existNextPage; + } + + public void setExistNextPage(final boolean existNextPage) { + this.existNextPage = existNextPage; + } + + public int getPageSize() { + if (pageSize <= 0) { + pageSize = getDefaultPageSize(); + } + return pageSize; + } + + public void setPageSize(final int pageSize) { + this.pageSize = pageSize; + } + + public int getCurrentPageNumber() { + if (currentPageNumber <= 0) { + currentPageNumber = getDefaultCurrentPageNumber(); + } + return currentPageNumber; + } + + public void setCurrentPageNumber(final int currentPageNumber) { + this.currentPageNumber = currentPageNumber; + } + + public List getPageNumberList() { + return pageNumberList; + } + + public void setPageNumberList(final List pageNumberList) { + this.pageNumberList = pageNumberList; + } + + protected int getDefaultCurrentPageNumber() { + return Constants.DEFAULT_ADMIN_PAGE_NUMBER; + } + + protected int getDefaultPageSize() { + return Constants.DEFAULT_ADMIN_PAGE_SIZE; + } + +} diff --git a/src/main/java/org/codelibs/fess/app/service/ApiTokenService.java b/src/main/java/org/codelibs/fess/app/service/ApiTokenService.java new file mode 100644 index 000000000..bdf565af9 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/service/ApiTokenService.java @@ -0,0 +1,84 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.service; + +import java.util.List; + +import javax.annotation.Resource; + +import org.codelibs.core.beans.util.BeanUtil; +import org.codelibs.fess.Constants; +import org.codelibs.fess.app.pager.ApiTokenPager; +import org.codelibs.fess.es.config.cbean.ApiTokenCB; +import org.codelibs.fess.es.config.exbhv.ApiTokenBhv; +import org.codelibs.fess.es.config.exentity.ApiToken; +import org.codelibs.fess.mylasta.direction.FessConfig; +import org.dbflute.cbean.result.PagingResultBean; +import org.dbflute.optional.OptionalEntity; + +public class ApiTokenService { + + @Resource + protected ApiTokenBhv apiTokenBhv; + + @Resource + protected FessConfig fessConfig; + + public List getApiTokenList(final ApiTokenPager apiTokenPager) { + + final PagingResultBean apiTokenList = apiTokenBhv.selectPage(cb -> { + cb.paging(apiTokenPager.getPageSize(), apiTokenPager.getCurrentPageNumber()); + setupListCondition(cb, apiTokenPager); + }); + + // update pager + BeanUtil.copyBeanToBean(apiTokenList, apiTokenPager, option -> option.include(Constants.PAGER_CONVERSION_RULE)); + apiTokenPager.setPageNumberList(apiTokenList.pageRange(op -> op.rangeSize(5)).createPageNumberList()); + + return apiTokenList; + } + + public OptionalEntity getApiToken(final String id) { + return apiTokenBhv.selectByPK(id); + } + + public void store(final ApiToken apiToken) { + + apiTokenBhv.insertOrUpdate(apiToken, op -> op.setRefresh(true)); + + } + + public void delete(final ApiToken apiToken) { + + apiTokenBhv.delete(apiToken, op -> op.setRefresh(true)); + + } + + protected void setupListCondition(final ApiTokenCB cb, final ApiTokenPager apiTokenPager) { + if (apiTokenPager.id != null) { + cb.query().docMeta().setId_Equal(apiTokenPager.id); + } + // TODO Long, Integer, String supported only. + + // setup condition + cb.query().addOrderBy_Name_Asc(); + cb.query().addOrderBy_CreatedTime_Asc(); + + // search + + } + +} \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/app/web/admin/apitoken/AdminApitokenAction.java b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/AdminApitokenAction.java new file mode 100644 index 000000000..7a182884a --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/AdminApitokenAction.java @@ -0,0 +1,252 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.web.admin.apitoken; + +import javax.annotation.Resource; + +import org.codelibs.fess.Constants; +import org.codelibs.fess.app.pager.ApiTokenPager; +import org.codelibs.fess.app.service.ApiTokenService; +import org.codelibs.fess.app.web.CrudMode; +import org.codelibs.fess.app.web.base.FessAdminAction; +import org.codelibs.fess.es.config.exentity.ApiToken; +import org.codelibs.fess.util.RenderDataUtil; +import org.dbflute.optional.OptionalEntity; +import org.dbflute.optional.OptionalThing; +import org.lastaflute.web.Execute; +import org.lastaflute.web.response.HtmlResponse; +import org.lastaflute.web.response.render.RenderData; +import org.lastaflute.web.ruts.process.ActionRuntime; + +/** + * @author shinsuke + */ +public class AdminApitokenAction extends FessAdminAction { + + // =================================================================================== + // Attribute + // ========= + @Resource + private ApiTokenService apiTokenService; + @Resource + private ApiTokenPager apiTokenPager; + + // =================================================================================== + // Hook + // ====== + @Override + protected void setupHtmlData(final ActionRuntime runtime) { + super.setupHtmlData(runtime); + runtime.registerData("helpLink", systemHelper.getHelpLink(fessConfig.getOnlineHelpNameApitoken())); + } + + // =================================================================================== + // Search Execute + // ============== + @Execute + public HtmlResponse index() { + return asListHtml(); + } + + @Execute + public HtmlResponse list(final OptionalThing pageNumber, final SearchForm form) { + pageNumber.ifPresent(num -> { + apiTokenPager.setCurrentPageNumber(pageNumber.get()); + }).orElse(() -> { + apiTokenPager.setCurrentPageNumber(0); + }); + return asHtml(path_AdminApitoken_AdminApitokenJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse search(final SearchForm form) { + copyBeanToBean(form, apiTokenPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE)); + return asHtml(path_AdminApitoken_AdminApitokenJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse reset(final SearchForm form) { + apiTokenPager.clear(); + return asHtml(path_AdminApitoken_AdminApitokenJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + protected void searchPaging(final RenderData data, final SearchForm form) { + RenderDataUtil.register(data, "apiTokenItems", apiTokenService.getApiTokenList(apiTokenPager)); // page navi + + // restore from pager + copyBeanToBean(apiTokenPager, form, op -> op.include("id")); + } + + // =================================================================================== + // Edit Execute + // ============ + // ----------------------------------------------------- + // Entry Page + // ---------- + @Execute + public HtmlResponse createnew() { + saveToken(); + return asEditHtml().useForm(CreateForm.class, op -> { + op.setup(form -> { + form.initialize(); + form.crudMode = CrudMode.CREATE; + }); + }); + } + + // ----------------------------------------------------- + // Details + // ------- + @Execute + public HtmlResponse details(final int crudMode, final String id) { + verifyCrudMode(crudMode, CrudMode.DETAILS); + saveToken(); + return asDetailsHtml().useForm(EditForm.class, op -> { + op.setup(form -> { + apiTokenService.getApiToken(id).ifPresent(entity -> { + copyBeanToBean(entity, form, copyOp -> { + copyOp.excludeNull(); + }); + form.crudMode = crudMode; + }).orElse(() -> { + throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml()); + }); + }); + }); + } + + // ----------------------------------------------------- + // Actually Crud + // ------------- + @Execute + public HtmlResponse create(final CreateForm form) { + verifyCrudMode(form.crudMode, CrudMode.CREATE); + validate(form, messages -> {}, () -> asEditHtml()); + verifyToken(() -> asEditHtml()); + getApiToken(form).ifPresent( + entity -> { + entity.setToken(systemHelper.generateApiToken()); + try { + apiTokenService.store(entity); + saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL)); + } catch (final Exception e) { + throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)), + () -> asEditHtml()); + } + }).orElse(() -> { + throwValidationError(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL), () -> asEditHtml()); + }); + return redirect(getClass()); + } + + @Execute + public HtmlResponse delete(final EditForm form) { + verifyCrudMode(form.crudMode, CrudMode.DETAILS); + validate(form, messages -> {}, () -> asDetailsHtml()); + verifyToken(() -> asDetailsHtml()); + final String id = form.id; + apiTokenService + .getApiToken(id) + .ifPresent( + entity -> { + try { + apiTokenService.delete(entity); + saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL)); + } catch (final Exception e) { + throwValidationError( + messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)), + () -> asEditHtml()); + } + }).orElse(() -> { + throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml()); + }); + return redirect(getClass()); + } + + // =================================================================================== + // Assist Logic + // ============ + + private OptionalEntity getEntity(final CreateForm form, final String username, final long currentTime) { + switch (form.crudMode) { + case CrudMode.CREATE: + return OptionalEntity.of(new ApiToken()).map(entity -> { + entity.setCreatedBy(username); + entity.setCreatedTime(currentTime); + return entity; + }); + case CrudMode.EDIT: + if (form instanceof EditForm) { + return apiTokenService.getApiToken(((EditForm) form).id); + } + break; + default: + break; + } + return OptionalEntity.empty(); + } + + protected OptionalEntity getApiToken(final CreateForm form) { + final String username = systemHelper.getUsername(); + final long currentTime = systemHelper.getCurrentTimeAsLong(); + return getEntity(form, username, currentTime).map(entity -> { + entity.setUpdatedBy(username); + entity.setUpdatedTime(currentTime); + copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE)); + return entity; + }); + } + + // =================================================================================== + // Small Helper + // ============ + protected void verifyCrudMode(final int crudMode, final int expectedMode) { + if (crudMode != expectedMode) { + throwValidationError(messages -> { + messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode)); + }, () -> asListHtml()); + } + } + + // =================================================================================== + // JSP + // ========= + + private HtmlResponse asListHtml() { + return asHtml(path_AdminApitoken_AdminApitokenJsp).renderWith(data -> { + RenderDataUtil.register(data, "apiTokenItems", apiTokenService.getApiTokenList(apiTokenPager)); + }).useForm(SearchForm.class, setup -> { + setup.setup(form -> { + copyBeanToBean(apiTokenPager, form, op -> op.include("id")); + }); + }); + } + + private HtmlResponse asEditHtml() { + return asHtml(path_AdminApitoken_AdminApitokenEditJsp); + } + + private HtmlResponse asDetailsHtml() { + return asHtml(path_AdminApitoken_AdminApitokenDetailsJsp); + } + +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/apitoken/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/CreateForm.java new file mode 100644 index 000000000..5a42e0db8 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/CreateForm.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.web.admin.apitoken; + +import javax.validation.constraints.Size; + +import org.codelibs.fess.app.web.CrudMode; +import org.codelibs.fess.util.ComponentUtil; +import org.lastaflute.web.validation.Required; +import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure; + +public class CreateForm { + + @ValidateTypeFailure + public Integer crudMode; + + @Required + @Size(max = 10000) + public String name; + + @Size(max = 10000) + public String token; + + @Required + @Size(max = 1000) + public String createdBy; + + @Required + @ValidateTypeFailure + public Long createdTime; + + public void initialize() { + crudMode = CrudMode.CREATE; + createdBy = ComponentUtil.getSystemHelper().getUsername(); + createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong(); + } +} \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/app/web/admin/apitoken/EditForm.java b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/EditForm.java new file mode 100644 index 000000000..3a368fca4 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/EditForm.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.web.admin.apitoken; + +import javax.validation.constraints.Size; + +import org.lastaflute.web.validation.Required; +import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure; + +/** + * @author shinsuke + * @author jflute + */ +public class EditForm extends CreateForm { + + @Required + @Size(max = 1000) + public String id; + + @Size(max = 1000) + public String updatedBy; + + @ValidateTypeFailure + public Long updatedTime; + + @Required + @ValidateTypeFailure + public Integer versionNo; + +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/apitoken/SearchForm.java b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/SearchForm.java new file mode 100644 index 000000000..53119a37c --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/apitoken/SearchForm.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.app.web.admin.apitoken; + +/** + * @author codelibs + * @author jflute + */ +public class SearchForm { + + public String id; + +} diff --git a/src/main/java/org/codelibs/fess/es/config/bsbhv/BsApiTokenBhv.java b/src/main/java/org/codelibs/fess/es/config/bsbhv/BsApiTokenBhv.java new file mode 100644 index 000000000..0e6d96ed5 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsbhv/BsApiTokenBhv.java @@ -0,0 +1,258 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsbhv; + +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractBehavior; +import org.codelibs.fess.es.config.allcommon.EsAbstractEntity.RequestOptionCall; +import org.codelibs.fess.es.config.bsentity.dbmeta.ApiTokenDbm; +import org.codelibs.fess.es.config.cbean.ApiTokenCB; +import org.codelibs.fess.es.config.exentity.ApiToken; +import org.dbflute.Entity; +import org.dbflute.bhv.readable.CBCall; +import org.dbflute.bhv.readable.EntityRowHandler; +import org.dbflute.cbean.ConditionBean; +import org.dbflute.cbean.result.ListResultBean; +import org.dbflute.cbean.result.PagingResultBean; +import org.dbflute.exception.IllegalBehaviorStateException; +import org.dbflute.optional.OptionalEntity; +import org.dbflute.util.DfTypeUtil; +import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.delete.DeleteRequestBuilder; +import org.elasticsearch.action.index.IndexRequestBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public abstract class BsApiTokenBhv extends EsAbstractBehavior { + + // =================================================================================== + // Control Override + // ================ + @Override + public String asTableDbName() { + return asEsIndexType(); + } + + @Override + protected String asEsIndex() { + return ".fess_config"; + } + + @Override + public String asEsIndexType() { + return "api_token"; + } + + @Override + public String asEsSearchType() { + return "api_token"; + } + + @Override + public ApiTokenDbm asDBMeta() { + return ApiTokenDbm.getInstance(); + } + + @Override + protected RESULT createEntity(Map source, Class entityType) { + try { + final RESULT result = entityType.newInstance(); + result.setName(DfTypeUtil.toString(source.get("name"))); + result.setToken(DfTypeUtil.toString(source.get("token"))); + result.setCreatedBy(DfTypeUtil.toString(source.get("createdBy"))); + result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime"))); + result.setUpdatedBy(DfTypeUtil.toString(source.get("updatedBy"))); + result.setUpdatedTime(DfTypeUtil.toLong(source.get("updatedTime"))); + return result; + } catch (InstantiationException | IllegalAccessException e) { + final String msg = "Cannot create a new instance: " + entityType.getName(); + throw new IllegalBehaviorStateException(msg, e); + } + } + + // =================================================================================== + // Select + // ====== + public int selectCount(CBCall cbLambda) { + return facadeSelectCount(createCB(cbLambda)); + } + + public OptionalEntity selectEntity(CBCall cbLambda) { + return facadeSelectEntity(createCB(cbLambda)); + } + + protected OptionalEntity facadeSelectEntity(ApiTokenCB cb) { + return doSelectOptionalEntity(cb, typeOfSelectedEntity()); + } + + protected OptionalEntity doSelectOptionalEntity(ApiTokenCB cb, Class tp) { + return createOptionalEntity(doSelectEntity(cb, tp), cb); + } + + @Override + public ApiTokenCB newConditionBean() { + return new ApiTokenCB(); + } + + @Override + protected Entity doReadEntity(ConditionBean cb) { + return facadeSelectEntity(downcast(cb)).orElse(null); + } + + public ApiToken selectEntityWithDeletedCheck(CBCall cbLambda) { + return facadeSelectEntityWithDeletedCheck(createCB(cbLambda)); + } + + public OptionalEntity selectByPK(String id) { + return facadeSelectByPK(id); + } + + protected OptionalEntity facadeSelectByPK(String id) { + return doSelectOptionalByPK(id, typeOfSelectedEntity()); + } + + protected ENTITY doSelectByPK(String id, Class tp) { + return doSelectEntity(xprepareCBAsPK(id), tp); + } + + protected ApiTokenCB xprepareCBAsPK(String id) { + assertObjectNotNull("id", id); + return newConditionBean().acceptPK(id); + } + + protected OptionalEntity doSelectOptionalByPK(String id, Class tp) { + return createOptionalEntity(doSelectByPK(id, tp), id); + } + + @Override + protected Class typeOfSelectedEntity() { + return ApiToken.class; + } + + @Override + protected Class typeOfHandlingEntity() { + return ApiToken.class; + } + + @Override + protected Class typeOfHandlingConditionBean() { + return ApiTokenCB.class; + } + + public ListResultBean selectList(CBCall cbLambda) { + return facadeSelectList(createCB(cbLambda)); + } + + public PagingResultBean selectPage(CBCall cbLambda) { + // #pending same? + return (PagingResultBean) facadeSelectList(createCB(cbLambda)); + } + + public void selectCursor(CBCall cbLambda, EntityRowHandler entityLambda) { + facadeSelectCursor(createCB(cbLambda), entityLambda); + } + + public void selectBulk(CBCall cbLambda, EntityRowHandler> entityLambda) { + delegateSelectBulk(createCB(cbLambda), entityLambda, typeOfSelectedEntity()); + } + + // =================================================================================== + // Update + // ====== + public void insert(ApiToken entity) { + doInsert(entity, null); + } + + public void insert(ApiToken entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doInsert(entity, null); + } + + public void update(ApiToken entity) { + doUpdate(entity, null); + } + + public void update(ApiToken entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doUpdate(entity, null); + } + + public void insertOrUpdate(ApiToken entity) { + doInsertOrUpdate(entity, null, null); + } + + public void insertOrUpdate(ApiToken entity, RequestOptionCall opLambda) { + entity.asDocMeta().indexOption(opLambda); + doInsertOrUpdate(entity, null, null); + } + + public void delete(ApiToken entity) { + doDelete(entity, null); + } + + public void delete(ApiToken entity, RequestOptionCall opLambda) { + entity.asDocMeta().deleteOption(opLambda); + doDelete(entity, null); + } + + public int queryDelete(CBCall cbLambda) { + return doQueryDelete(createCB(cbLambda), null); + } + + public int[] batchInsert(List list) { + return batchInsert(list, null, null); + } + + public int[] batchInsert(List list, RequestOptionCall call) { + return batchInsert(list, call, null); + } + + public int[] batchInsert(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchInsert(new BulkList<>(list, call, entityCall), null); + } + + public int[] batchUpdate(List list) { + return batchUpdate(list, null, null); + } + + public int[] batchUpdate(List list, RequestOptionCall call) { + return batchUpdate(list, call, null); + } + + public int[] batchUpdate(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchUpdate(new BulkList<>(list, call, entityCall), null); + } + + public int[] batchDelete(List list) { + return batchDelete(list, null, null); + } + + public int[] batchDelete(List list, RequestOptionCall call) { + return batchDelete(list, call, null); + } + + public int[] batchDelete(List list, RequestOptionCall call, + RequestOptionCall entityCall) { + return doBatchDelete(new BulkList<>(list, call, entityCall), null); + } + + // #pending create, modify, remove +} diff --git a/src/main/java/org/codelibs/fess/es/config/bsentity/BsApiToken.java b/src/main/java/org/codelibs/fess/es/config/bsentity/BsApiToken.java new file mode 100644 index 000000000..a918ff55d --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsentity/BsApiToken.java @@ -0,0 +1,181 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsentity; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractEntity; +import org.codelibs.fess.es.config.bsentity.dbmeta.ApiTokenDbm; + +/** + * ${table.comment} + * @author ESFlute (using FreeGen) + */ +public class BsApiToken extends EsAbstractEntity { + + // =================================================================================== + // Definition + // ========== + private static final long serialVersionUID = 1L; + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Attribute + // ========= + /** name */ + protected String name; + + /** token */ + protected String token; + + /** createdBy */ + protected String createdBy; + + /** createdTime */ + protected Long createdTime; + + /** updatedBy */ + protected String updatedBy; + + /** updatedTime */ + protected Long updatedTime; + + // [Referrers] *comment only + + // =================================================================================== + // DB Meta + // ======= + @Override + public ApiTokenDbm asDBMeta() { + return ApiTokenDbm.getInstance(); + } + + @Override + public String asTableDbName() { + return "api_token"; + } + + // =================================================================================== + // Source + // ====== + @Override + public Map toSource() { + Map sourceMap = new HashMap<>(); + if (name != null) { + sourceMap.put("name", name); + } + if (token != null) { + sourceMap.put("token", token); + } + if (createdBy != null) { + sourceMap.put("createdBy", createdBy); + } + if (createdTime != null) { + sourceMap.put("createdTime", createdTime); + } + if (updatedBy != null) { + sourceMap.put("updatedBy", updatedBy); + } + if (updatedTime != null) { + sourceMap.put("updatedTime", updatedTime); + } + return sourceMap; + } + + // =================================================================================== + // Basic Override + // ============== + @Override + protected String doBuildColumnString(String dm) { + StringBuilder sb = new StringBuilder(); + sb.append(dm).append(name); + sb.append(dm).append(token); + sb.append(dm).append(createdBy); + sb.append(dm).append(createdTime); + sb.append(dm).append(updatedBy); + sb.append(dm).append(updatedTime); + if (sb.length() > dm.length()) { + sb.delete(0, dm.length()); + } + sb.insert(0, "{").append("}"); + return sb.toString(); + } + + // =================================================================================== + // Accessor + // ======== + public String getName() { + checkSpecifiedProperty("name"); + return convertEmptyToNull(name); + } + + public void setName(String value) { + registerModifiedProperty("name"); + this.name = value; + } + + public String getToken() { + checkSpecifiedProperty("token"); + return convertEmptyToNull(token); + } + + public void setToken(String value) { + registerModifiedProperty("token"); + this.token = value; + } + + public String getCreatedBy() { + checkSpecifiedProperty("createdBy"); + return convertEmptyToNull(createdBy); + } + + public void setCreatedBy(String value) { + registerModifiedProperty("createdBy"); + this.createdBy = value; + } + + public Long getCreatedTime() { + checkSpecifiedProperty("createdTime"); + return createdTime; + } + + public void setCreatedTime(Long value) { + registerModifiedProperty("createdTime"); + this.createdTime = value; + } + + public String getUpdatedBy() { + checkSpecifiedProperty("updatedBy"); + return convertEmptyToNull(updatedBy); + } + + public void setUpdatedBy(String value) { + registerModifiedProperty("updatedBy"); + this.updatedBy = value; + } + + public Long getUpdatedTime() { + checkSpecifiedProperty("updatedTime"); + return updatedTime; + } + + public void setUpdatedTime(Long value) { + registerModifiedProperty("updatedTime"); + this.updatedTime = value; + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ApiTokenDbm.java b/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ApiTokenDbm.java new file mode 100644 index 000000000..a7982aaa8 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/bsentity/dbmeta/ApiTokenDbm.java @@ -0,0 +1,248 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.bsentity.dbmeta; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.exentity.ApiToken; +import org.dbflute.Entity; +import org.dbflute.dbmeta.AbstractDBMeta; +import org.dbflute.dbmeta.info.ColumnInfo; +import org.dbflute.dbmeta.info.UniqueInfo; +import org.dbflute.dbmeta.name.TableSqlName; +import org.dbflute.dbmeta.property.PropertyGateway; +import org.dbflute.dbway.DBDef; +import org.dbflute.util.DfTypeUtil; + +/** + * @author ESFlute (using FreeGen) + */ +public class ApiTokenDbm extends AbstractDBMeta { + + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Singleton + // ========= + private static final ApiTokenDbm _instance = new ApiTokenDbm(); + + private ApiTokenDbm() { + } + + public static ApiTokenDbm getInstance() { + return _instance; + } + + // =================================================================================== + // Current DBDef + // ============= + @Override + public String getProjectName() { + return null; + } + + @Override + public String getProjectPrefix() { + return null; + } + + @Override + public String getGenerationGapBasePrefix() { + return null; + } + + @Override + public DBDef getCurrentDBDef() { + return null; + } + + // =================================================================================== + // Property Gateway + // ================ + // ----------------------------------------------------- + // Column Property + // --------------- + protected final Map _epgMap = newHashMap(); + { + setupEpg(_epgMap, et -> ((ApiToken) et).getName(), (et, vl) -> ((ApiToken) et).setName(DfTypeUtil.toString(vl)), "name"); + setupEpg(_epgMap, et -> ((ApiToken) et).getToken(), (et, vl) -> ((ApiToken) et).setToken(DfTypeUtil.toString(vl)), "token"); + setupEpg(_epgMap, et -> ((ApiToken) et).getCreatedBy(), (et, vl) -> ((ApiToken) et).setCreatedBy(DfTypeUtil.toString(vl)), + "createdBy"); + setupEpg(_epgMap, et -> ((ApiToken) et).getCreatedTime(), (et, vl) -> ((ApiToken) et).setCreatedTime(DfTypeUtil.toLong(vl)), + "createdTime"); + setupEpg(_epgMap, et -> ((ApiToken) et).getUpdatedBy(), (et, vl) -> ((ApiToken) et).setUpdatedBy(DfTypeUtil.toString(vl)), + "updatedBy"); + setupEpg(_epgMap, et -> ((ApiToken) et).getUpdatedTime(), (et, vl) -> ((ApiToken) et).setUpdatedTime(DfTypeUtil.toLong(vl)), + "updatedTime"); + } + + @Override + public PropertyGateway findPropertyGateway(final String prop) { + return doFindEpg(_epgMap, prop); + } + + // =================================================================================== + // Table Info + // ========== + protected final String _tableDbName = "api_token"; + protected final String _tableDispName = "api_token"; + protected final String _tablePropertyName = "ApiToken"; + + public String getTableDbName() { + return _tableDbName; + } + + @Override + public String getTableDispName() { + return _tableDispName; + } + + @Override + public String getTablePropertyName() { + return _tablePropertyName; + } + + @Override + public TableSqlName getTableSqlName() { + return null; + } + + // =================================================================================== + // Column Info + // =========== + protected final ColumnInfo _columnName = cci("name", "name", null, null, String.class, "name", null, false, false, false, "String", 0, + 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnToken = cci("token", "token", null, null, String.class, "token", null, false, false, false, "String", + 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnCreatedBy = cci("createdBy", "createdBy", null, null, String.class, "createdBy", null, false, false, + false, "String", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnCreatedTime = cci("createdTime", "createdTime", null, null, Long.class, "createdTime", null, false, + false, false, "Long", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnUpdatedBy = cci("updatedBy", "updatedBy", null, null, String.class, "updatedBy", null, false, false, + false, "String", 0, 0, null, false, null, null, null, null, null, false); + protected final ColumnInfo _columnUpdatedTime = cci("updatedTime", "updatedTime", null, null, Long.class, "updatedTime", null, false, + false, false, "Long", 0, 0, null, false, null, null, null, null, null, false); + + public ColumnInfo columnName() { + return _columnName; + } + + public ColumnInfo columnToken() { + return _columnToken; + } + + public ColumnInfo columnCreatedBy() { + return _columnCreatedBy; + } + + public ColumnInfo columnCreatedTime() { + return _columnCreatedTime; + } + + public ColumnInfo columnUpdatedBy() { + return _columnUpdatedBy; + } + + public ColumnInfo columnUpdatedTime() { + return _columnUpdatedTime; + } + + protected List ccil() { + List ls = newArrayList(); + ls.add(columnName()); + ls.add(columnToken()); + ls.add(columnCreatedBy()); + ls.add(columnCreatedTime()); + ls.add(columnUpdatedBy()); + ls.add(columnUpdatedTime()); + return ls; + } + + // =================================================================================== + // Unique Info + // =========== + @Override + public boolean hasPrimaryKey() { + return false; + } + + @Override + public boolean hasCompoundPrimaryKey() { + return false; + } + + @Override + protected UniqueInfo cpui() { + return null; + } + + // =================================================================================== + // Type Name + // ========= + @Override + public String getEntityTypeName() { + return "org.codelibs.fess.es.config.exentity.ApiToken"; + } + + @Override + public String getConditionBeanTypeName() { + return "org.codelibs.fess.es.config.cbean.ApiTokenCB"; + } + + @Override + public String getBehaviorTypeName() { + return "org.codelibs.fess.es.config.exbhv.ApiTokenBhv"; + } + + // =================================================================================== + // Object Type + // =========== + @Override + public Class getEntityType() { + return ApiToken.class; + } + + // =================================================================================== + // Object Instance + // =============== + @Override + public Entity newEntity() { + return new ApiToken(); + } + + // =================================================================================== + // Map Communication + // ================= + @Override + public void acceptPrimaryKeyMap(Entity entity, Map primaryKeyMap) { + } + + @Override + public void acceptAllColumnMap(Entity entity, Map allColumnMap) { + } + + @Override + public Map extractPrimaryKeyMap(Entity entity) { + return null; + } + + @Override + public Map extractAllColumnMap(Entity entity) { + return null; + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/ApiTokenCB.java b/src/main/java/org/codelibs/fess/es/config/cbean/ApiTokenCB.java new file mode 100644 index 000000000..cbdd961c5 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/ApiTokenCB.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean; + +import org.codelibs.fess.es.config.cbean.bs.BsApiTokenCB; + +/** + * @author ESFlute (using FreeGen) + */ +public class ApiTokenCB extends BsApiTokenCB { +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsApiTokenCB.java b/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsApiTokenCB.java new file mode 100644 index 000000000..f6d4d6920 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/bs/BsApiTokenCB.java @@ -0,0 +1,174 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.bs; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.codelibs.fess.es.config.allcommon.EsAbstractConditionBean; +import org.codelibs.fess.es.config.bsentity.dbmeta.ApiTokenDbm; +import org.codelibs.fess.es.config.cbean.ApiTokenCB; +import org.codelibs.fess.es.config.cbean.cq.ApiTokenCQ; +import org.codelibs.fess.es.config.cbean.cq.bs.BsApiTokenCQ; +import org.dbflute.cbean.ConditionQuery; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.index.query.QueryBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public class BsApiTokenCB extends EsAbstractConditionBean { + + // =================================================================================== + // Attribute + // ========= + protected BsApiTokenCQ _conditionQuery; + protected HpSpecification _specification; + + // =================================================================================== + // Control + // ======= + @Override + public ApiTokenDbm asDBMeta() { + return ApiTokenDbm.getInstance(); + } + + @Override + public String asTableDbName() { + return "api_token"; + } + + @Override + public boolean hasSpecifiedColumn() { + return _specification != null; + } + + @Override + public ConditionQuery localCQ() { + return doGetConditionQuery(); + } + + // =================================================================================== + // Primary Key + // =========== + public ApiTokenCB acceptPK(String id) { + assertObjectNotNull("id", id); + BsApiTokenCB cb = this; + cb.query().docMeta().setId_Equal(id); + return (ApiTokenCB) this; + } + + @Override + public void acceptPrimaryKeyMap(Map primaryKeyMap) { + acceptPK((String) primaryKeyMap.get("_id")); + } + + // =================================================================================== + // Build + // ===== + + @Override + public SearchRequestBuilder build(SearchRequestBuilder builder) { + if (_conditionQuery != null) { + QueryBuilder queryBuilder = _conditionQuery.getQuery(); + if (queryBuilder != null) { + builder.setQuery(queryBuilder); + } + _conditionQuery.getFieldSortBuilderList().forEach(sort -> { + builder.addSort(sort); + }); + } + + if (_specification != null) { + builder.setFetchSource(_specification.columnList.toArray(new String[_specification.columnList.size()]), null); + } + + return builder; + } + + // =================================================================================== + // Query + // ===== + public BsApiTokenCQ query() { + assertQueryPurpose(); + return doGetConditionQuery(); + } + + protected BsApiTokenCQ doGetConditionQuery() { + if (_conditionQuery == null) { + _conditionQuery = createLocalCQ(); + } + return _conditionQuery; + } + + protected BsApiTokenCQ createLocalCQ() { + return new ApiTokenCQ(); + } + + // =================================================================================== + // Specify + // ======= + public HpSpecification specify() { + assertSpecifyPurpose(); + if (_specification == null) { + _specification = new HpSpecification(); + } + return _specification; + } + + protected void assertQueryPurpose() { + } + + protected void assertSpecifyPurpose() { + } + + public static class HpSpecification { + private List columnList = new ArrayList<>(); + + private void doColumn(String name) { + columnList.add(name); + } + + public void columnId() { + doColumn("_id"); + } + + public void columnName() { + doColumn("name"); + } + + public void columnToken() { + doColumn("token"); + } + + public void columnCreatedBy() { + doColumn("createdBy"); + } + + public void columnCreatedTime() { + doColumn("createdTime"); + } + + public void columnUpdatedBy() { + doColumn("updatedBy"); + } + + public void columnUpdatedTime() { + doColumn("updatedTime"); + } + } +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/cq/ApiTokenCQ.java b/src/main/java/org/codelibs/fess/es/config/cbean/cq/ApiTokenCQ.java new file mode 100644 index 000000000..43c5d46fb --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/cq/ApiTokenCQ.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.cq; + +import org.codelibs.fess.es.config.cbean.cq.bs.BsApiTokenCQ; + +/** + * @author ESFlute (using FreeGen) + */ +public class ApiTokenCQ extends BsApiTokenCQ { +} diff --git a/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsApiTokenCQ.java b/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsApiTokenCQ.java new file mode 100644 index 000000000..d9307b84d --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/cbean/cq/bs/BsApiTokenCQ.java @@ -0,0 +1,1341 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.cbean.cq.bs; + +import java.time.LocalDateTime; +import java.util.Collection; + +import org.codelibs.fess.es.config.allcommon.EsAbstractConditionQuery; +import org.codelibs.fess.es.config.cbean.cq.ApiTokenCQ; +import org.dbflute.cbean.ckey.ConditionKey; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.CommonTermsQueryBuilder; +import org.elasticsearch.index.query.ExistsQueryBuilder; +import org.elasticsearch.index.query.FuzzyQueryBuilder; +import org.elasticsearch.index.query.IdsQueryBuilder; +import org.elasticsearch.index.query.MatchQueryBuilder; +import org.elasticsearch.index.query.PrefixQueryBuilder; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.index.query.RegexpQueryBuilder; +import org.elasticsearch.index.query.TermQueryBuilder; +import org.elasticsearch.index.query.TermsQueryBuilder; +import org.elasticsearch.index.query.WildcardQueryBuilder; + +/** + * @author ESFlute (using FreeGen) + */ +public abstract class BsApiTokenCQ extends EsAbstractConditionQuery { + + protected static final Class suppressUnusedImportLocalDateTime = LocalDateTime.class; + + // =================================================================================== + // Name Override + // ============= + @Override + public String asTableDbName() { + return "api_token"; + } + + @Override + public String xgetAliasName() { + return "api_token"; + } + + // =================================================================================== + // Query Control + // ============= + public void filtered(FilteredCall filteredLambda) { + filtered(filteredLambda, null); + } + + public void filtered(FilteredCall filteredLambda, ConditionOptionCall opLambda) { + bool((must, should, mustNot, filter) -> { + filteredLambda.callback(must, filter); + }, opLambda); + } + + public void not(OperatorCall notLambda) { + not(notLambda, null); + } + + public void not(final OperatorCall notLambda, final ConditionOptionCall opLambda) { + bool((must, should, mustNot, filter) -> notLambda.callback(mustNot), opLambda); + } + + public void bool(BoolCall boolLambda) { + bool(boolLambda, null); + } + + public void bool(BoolCall boolLambda, ConditionOptionCall opLambda) { + ApiTokenCQ mustQuery = new ApiTokenCQ(); + ApiTokenCQ shouldQuery = new ApiTokenCQ(); + ApiTokenCQ mustNotQuery = new ApiTokenCQ(); + ApiTokenCQ filterQuery = new ApiTokenCQ(); + boolLambda.callback(mustQuery, shouldQuery, mustNotQuery, filterQuery); + if (mustQuery.hasQueries() || shouldQuery.hasQueries() || mustNotQuery.hasQueries() || filterQuery.hasQueries()) { + BoolQueryBuilder builder = + regBoolCQ(mustQuery.getQueryBuilderList(), shouldQuery.getQueryBuilderList(), mustNotQuery.getQueryBuilderList(), + filterQuery.getQueryBuilderList()); + if (opLambda != null) { + opLambda.callback(builder); + } + } + } + + // =================================================================================== + // Query Set + // ========= + public void setId_Equal(String id) { + setId_Term(id, null); + } + + public void setId_Equal(String id, ConditionOptionCall opLambda) { + setId_Term(id, opLambda); + } + + public void setId_Term(String id) { + setId_Term(id, null); + } + + public void setId_Term(String id, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("_id", id); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setId_NotEqual(String id) { + setId_NotTerm(id, null); + } + + public void setId_NotTerm(String id) { + setId_NotTerm(id, null); + } + + public void setId_NotEqual(String id, ConditionOptionCall opLambda) { + setId_NotTerm(id, opLambda); + } + + public void setId_NotTerm(String id, ConditionOptionCall opLambda) { + not(not -> not.setId_Term(id), opLambda); + } + + public void setId_Terms(Collection idList) { + setId_Terms(idList, null); + } + + public void setId_Terms(Collection idList, ConditionOptionCall opLambda) { + IdsQueryBuilder builder = regIdsQ(idList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setId_InScope(Collection idList) { + setId_Terms(idList, null); + } + + public void setId_InScope(Collection idList, ConditionOptionCall opLambda) { + setId_Terms(idList, opLambda); + } + + public BsApiTokenCQ addOrderBy_Id_Asc() { + regOBA("_id"); + return this; + } + + public BsApiTokenCQ addOrderBy_Id_Desc() { + regOBD("_id"); + return this; + } + + public void setName_Equal(String name) { + setName_Term(name, null); + } + + public void setName_Equal(String name, ConditionOptionCall opLambda) { + setName_Term(name, opLambda); + } + + public void setName_Term(String name) { + setName_Term(name, null); + } + + public void setName_Term(String name, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_NotEqual(String name) { + setName_NotTerm(name, null); + } + + public void setName_NotTerm(String name) { + setName_NotTerm(name, null); + } + + public void setName_NotEqual(String name, ConditionOptionCall opLambda) { + setName_NotTerm(name, opLambda); + } + + public void setName_NotTerm(String name, ConditionOptionCall opLambda) { + not(not -> not.setName_Term(name), opLambda); + } + + public void setName_Terms(Collection nameList) { + setName_Terms(nameList, null); + } + + public void setName_Terms(Collection nameList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("name", nameList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_InScope(Collection nameList) { + setName_Terms(nameList, null); + } + + public void setName_InScope(Collection nameList, ConditionOptionCall opLambda) { + setName_Terms(nameList, opLambda); + } + + public void setName_Match(String name) { + setName_Match(name, null); + } + + public void setName_Match(String name, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_MatchPhrase(String name) { + setName_MatchPhrase(name, null); + } + + public void setName_MatchPhrase(String name, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_MatchPhrasePrefix(String name) { + setName_MatchPhrasePrefix(name, null); + } + + public void setName_MatchPhrasePrefix(String name, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_Fuzzy(String name) { + setName_Fuzzy(name, null); + } + + public void setName_Fuzzy(String name, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_Prefix(String name) { + setName_Prefix(name, null); + } + + public void setName_Prefix(String name, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_Wildcard(String name) { + setName_Wildcard(name, null); + } + + public void setName_Wildcard(String name, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_Regexp(String name) { + setName_Regexp(name, null); + } + + public void setName_Regexp(String name, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_GreaterThan(String name) { + setName_GreaterThan(name, null); + } + + public void setName_GreaterThan(String name, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("name", ConditionKey.CK_GREATER_THAN, name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_LessThan(String name) { + setName_LessThan(name, null); + } + + public void setName_LessThan(String name, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("name", ConditionKey.CK_LESS_THAN, name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_GreaterEqual(String name) { + setName_GreaterEqual(name, null); + } + + public void setName_GreaterEqual(String name, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("name", ConditionKey.CK_GREATER_EQUAL, name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_LessEqual(String name) { + setName_LessEqual(name, null); + } + + public void setName_LessEqual(String name, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("name", ConditionKey.CK_LESS_EQUAL, name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_Exists() { + setName_Exists(null); + } + + public void setName_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("name"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setName_CommonTerms(String name) { + setName_CommonTerms(name, null); + } + + public void setName_CommonTerms(String name, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("name", name); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_Name_Asc() { + regOBA("name"); + return this; + } + + public BsApiTokenCQ addOrderBy_Name_Desc() { + regOBD("name"); + return this; + } + + public void setToken_Equal(String token) { + setToken_Term(token, null); + } + + public void setToken_Equal(String token, ConditionOptionCall opLambda) { + setToken_Term(token, opLambda); + } + + public void setToken_Term(String token) { + setToken_Term(token, null); + } + + public void setToken_Term(String token, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_NotEqual(String token) { + setToken_NotTerm(token, null); + } + + public void setToken_NotTerm(String token) { + setToken_NotTerm(token, null); + } + + public void setToken_NotEqual(String token, ConditionOptionCall opLambda) { + setToken_NotTerm(token, opLambda); + } + + public void setToken_NotTerm(String token, ConditionOptionCall opLambda) { + not(not -> not.setToken_Term(token), opLambda); + } + + public void setToken_Terms(Collection tokenList) { + setToken_Terms(tokenList, null); + } + + public void setToken_Terms(Collection tokenList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("token", tokenList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_InScope(Collection tokenList) { + setToken_Terms(tokenList, null); + } + + public void setToken_InScope(Collection tokenList, ConditionOptionCall opLambda) { + setToken_Terms(tokenList, opLambda); + } + + public void setToken_Match(String token) { + setToken_Match(token, null); + } + + public void setToken_Match(String token, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_MatchPhrase(String token) { + setToken_MatchPhrase(token, null); + } + + public void setToken_MatchPhrase(String token, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_MatchPhrasePrefix(String token) { + setToken_MatchPhrasePrefix(token, null); + } + + public void setToken_MatchPhrasePrefix(String token, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_Fuzzy(String token) { + setToken_Fuzzy(token, null); + } + + public void setToken_Fuzzy(String token, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_Prefix(String token) { + setToken_Prefix(token, null); + } + + public void setToken_Prefix(String token, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_Wildcard(String token) { + setToken_Wildcard(token, null); + } + + public void setToken_Wildcard(String token, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_Regexp(String token) { + setToken_Regexp(token, null); + } + + public void setToken_Regexp(String token, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_GreaterThan(String token) { + setToken_GreaterThan(token, null); + } + + public void setToken_GreaterThan(String token, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("token", ConditionKey.CK_GREATER_THAN, token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_LessThan(String token) { + setToken_LessThan(token, null); + } + + public void setToken_LessThan(String token, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("token", ConditionKey.CK_LESS_THAN, token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_GreaterEqual(String token) { + setToken_GreaterEqual(token, null); + } + + public void setToken_GreaterEqual(String token, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("token", ConditionKey.CK_GREATER_EQUAL, token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_LessEqual(String token) { + setToken_LessEqual(token, null); + } + + public void setToken_LessEqual(String token, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("token", ConditionKey.CK_LESS_EQUAL, token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_Exists() { + setToken_Exists(null); + } + + public void setToken_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("token"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setToken_CommonTerms(String token) { + setToken_CommonTerms(token, null); + } + + public void setToken_CommonTerms(String token, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("token", token); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_Token_Asc() { + regOBA("token"); + return this; + } + + public BsApiTokenCQ addOrderBy_Token_Desc() { + regOBD("token"); + return this; + } + + public void setCreatedBy_Equal(String createdBy) { + setCreatedBy_Term(createdBy, null); + } + + public void setCreatedBy_Equal(String createdBy, ConditionOptionCall opLambda) { + setCreatedBy_Term(createdBy, opLambda); + } + + public void setCreatedBy_Term(String createdBy) { + setCreatedBy_Term(createdBy, null); + } + + public void setCreatedBy_Term(String createdBy, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_NotEqual(String createdBy) { + setCreatedBy_NotTerm(createdBy, null); + } + + public void setCreatedBy_NotTerm(String createdBy) { + setCreatedBy_NotTerm(createdBy, null); + } + + public void setCreatedBy_NotEqual(String createdBy, ConditionOptionCall opLambda) { + setCreatedBy_NotTerm(createdBy, opLambda); + } + + public void setCreatedBy_NotTerm(String createdBy, ConditionOptionCall opLambda) { + not(not -> not.setCreatedBy_Term(createdBy), opLambda); + } + + public void setCreatedBy_Terms(Collection createdByList) { + setCreatedBy_Terms(createdByList, null); + } + + public void setCreatedBy_Terms(Collection createdByList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("createdBy", createdByList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_InScope(Collection createdByList) { + setCreatedBy_Terms(createdByList, null); + } + + public void setCreatedBy_InScope(Collection createdByList, ConditionOptionCall opLambda) { + setCreatedBy_Terms(createdByList, opLambda); + } + + public void setCreatedBy_Match(String createdBy) { + setCreatedBy_Match(createdBy, null); + } + + public void setCreatedBy_Match(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_MatchPhrase(String createdBy) { + setCreatedBy_MatchPhrase(createdBy, null); + } + + public void setCreatedBy_MatchPhrase(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_MatchPhrasePrefix(String createdBy) { + setCreatedBy_MatchPhrasePrefix(createdBy, null); + } + + public void setCreatedBy_MatchPhrasePrefix(String createdBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Fuzzy(String createdBy) { + setCreatedBy_Fuzzy(createdBy, null); + } + + public void setCreatedBy_Fuzzy(String createdBy, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Prefix(String createdBy) { + setCreatedBy_Prefix(createdBy, null); + } + + public void setCreatedBy_Prefix(String createdBy, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Wildcard(String createdBy) { + setCreatedBy_Wildcard(createdBy, null); + } + + public void setCreatedBy_Wildcard(String createdBy, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Regexp(String createdBy) { + setCreatedBy_Regexp(createdBy, null); + } + + public void setCreatedBy_Regexp(String createdBy, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_GreaterThan(String createdBy) { + setCreatedBy_GreaterThan(createdBy, null); + } + + public void setCreatedBy_GreaterThan(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_GREATER_THAN, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_LessThan(String createdBy) { + setCreatedBy_LessThan(createdBy, null); + } + + public void setCreatedBy_LessThan(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_LESS_THAN, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_GreaterEqual(String createdBy) { + setCreatedBy_GreaterEqual(createdBy, null); + } + + public void setCreatedBy_GreaterEqual(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_GREATER_EQUAL, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_LessEqual(String createdBy) { + setCreatedBy_LessEqual(createdBy, null); + } + + public void setCreatedBy_LessEqual(String createdBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdBy", ConditionKey.CK_LESS_EQUAL, createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_Exists() { + setCreatedBy_Exists(null); + } + + public void setCreatedBy_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("createdBy"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedBy_CommonTerms(String createdBy) { + setCreatedBy_CommonTerms(createdBy, null); + } + + public void setCreatedBy_CommonTerms(String createdBy, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("createdBy", createdBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_CreatedBy_Asc() { + regOBA("createdBy"); + return this; + } + + public BsApiTokenCQ addOrderBy_CreatedBy_Desc() { + regOBD("createdBy"); + return this; + } + + public void setCreatedTime_Equal(Long createdTime) { + setCreatedTime_Term(createdTime, null); + } + + public void setCreatedTime_Equal(Long createdTime, ConditionOptionCall opLambda) { + setCreatedTime_Term(createdTime, opLambda); + } + + public void setCreatedTime_Term(Long createdTime) { + setCreatedTime_Term(createdTime, null); + } + + public void setCreatedTime_Term(Long createdTime, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_NotEqual(Long createdTime) { + setCreatedTime_NotTerm(createdTime, null); + } + + public void setCreatedTime_NotTerm(Long createdTime) { + setCreatedTime_NotTerm(createdTime, null); + } + + public void setCreatedTime_NotEqual(Long createdTime, ConditionOptionCall opLambda) { + setCreatedTime_NotTerm(createdTime, opLambda); + } + + public void setCreatedTime_NotTerm(Long createdTime, ConditionOptionCall opLambda) { + not(not -> not.setCreatedTime_Term(createdTime), opLambda); + } + + public void setCreatedTime_Terms(Collection createdTimeList) { + setCreatedTime_Terms(createdTimeList, null); + } + + public void setCreatedTime_Terms(Collection createdTimeList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("createdTime", createdTimeList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_InScope(Collection createdTimeList) { + setCreatedTime_Terms(createdTimeList, null); + } + + public void setCreatedTime_InScope(Collection createdTimeList, ConditionOptionCall opLambda) { + setCreatedTime_Terms(createdTimeList, opLambda); + } + + public void setCreatedTime_Match(Long createdTime) { + setCreatedTime_Match(createdTime, null); + } + + public void setCreatedTime_Match(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_MatchPhrase(Long createdTime) { + setCreatedTime_MatchPhrase(createdTime, null); + } + + public void setCreatedTime_MatchPhrase(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_MatchPhrasePrefix(Long createdTime) { + setCreatedTime_MatchPhrasePrefix(createdTime, null); + } + + public void setCreatedTime_MatchPhrasePrefix(Long createdTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_Fuzzy(Long createdTime) { + setCreatedTime_Fuzzy(createdTime, null); + } + + public void setCreatedTime_Fuzzy(Long createdTime, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_GreaterThan(Long createdTime) { + setCreatedTime_GreaterThan(createdTime, null); + } + + public void setCreatedTime_GreaterThan(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_GREATER_THAN, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_LessThan(Long createdTime) { + setCreatedTime_LessThan(createdTime, null); + } + + public void setCreatedTime_LessThan(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_LESS_THAN, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_GreaterEqual(Long createdTime) { + setCreatedTime_GreaterEqual(createdTime, null); + } + + public void setCreatedTime_GreaterEqual(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_GREATER_EQUAL, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_LessEqual(Long createdTime) { + setCreatedTime_LessEqual(createdTime, null); + } + + public void setCreatedTime_LessEqual(Long createdTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("createdTime", ConditionKey.CK_LESS_EQUAL, createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_Exists() { + setCreatedTime_Exists(null); + } + + public void setCreatedTime_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("createdTime"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setCreatedTime_CommonTerms(Long createdTime) { + setCreatedTime_CommonTerms(createdTime, null); + } + + public void setCreatedTime_CommonTerms(Long createdTime, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("createdTime", createdTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_CreatedTime_Asc() { + regOBA("createdTime"); + return this; + } + + public BsApiTokenCQ addOrderBy_CreatedTime_Desc() { + regOBD("createdTime"); + return this; + } + + public void setUpdatedBy_Equal(String updatedBy) { + setUpdatedBy_Term(updatedBy, null); + } + + public void setUpdatedBy_Equal(String updatedBy, ConditionOptionCall opLambda) { + setUpdatedBy_Term(updatedBy, opLambda); + } + + public void setUpdatedBy_Term(String updatedBy) { + setUpdatedBy_Term(updatedBy, null); + } + + public void setUpdatedBy_Term(String updatedBy, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_NotEqual(String updatedBy) { + setUpdatedBy_NotTerm(updatedBy, null); + } + + public void setUpdatedBy_NotTerm(String updatedBy) { + setUpdatedBy_NotTerm(updatedBy, null); + } + + public void setUpdatedBy_NotEqual(String updatedBy, ConditionOptionCall opLambda) { + setUpdatedBy_NotTerm(updatedBy, opLambda); + } + + public void setUpdatedBy_NotTerm(String updatedBy, ConditionOptionCall opLambda) { + not(not -> not.setUpdatedBy_Term(updatedBy), opLambda); + } + + public void setUpdatedBy_Terms(Collection updatedByList) { + setUpdatedBy_Terms(updatedByList, null); + } + + public void setUpdatedBy_Terms(Collection updatedByList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("updatedBy", updatedByList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_InScope(Collection updatedByList) { + setUpdatedBy_Terms(updatedByList, null); + } + + public void setUpdatedBy_InScope(Collection updatedByList, ConditionOptionCall opLambda) { + setUpdatedBy_Terms(updatedByList, opLambda); + } + + public void setUpdatedBy_Match(String updatedBy) { + setUpdatedBy_Match(updatedBy, null); + } + + public void setUpdatedBy_Match(String updatedBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_MatchPhrase(String updatedBy) { + setUpdatedBy_MatchPhrase(updatedBy, null); + } + + public void setUpdatedBy_MatchPhrase(String updatedBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_MatchPhrasePrefix(String updatedBy) { + setUpdatedBy_MatchPhrasePrefix(updatedBy, null); + } + + public void setUpdatedBy_MatchPhrasePrefix(String updatedBy, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_Fuzzy(String updatedBy) { + setUpdatedBy_Fuzzy(updatedBy, null); + } + + public void setUpdatedBy_Fuzzy(String updatedBy, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_Prefix(String updatedBy) { + setUpdatedBy_Prefix(updatedBy, null); + } + + public void setUpdatedBy_Prefix(String updatedBy, ConditionOptionCall opLambda) { + PrefixQueryBuilder builder = regPrefixQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_Wildcard(String updatedBy) { + setUpdatedBy_Wildcard(updatedBy, null); + } + + public void setUpdatedBy_Wildcard(String updatedBy, ConditionOptionCall opLambda) { + WildcardQueryBuilder builder = regWildcardQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_Regexp(String updatedBy) { + setUpdatedBy_Regexp(updatedBy, null); + } + + public void setUpdatedBy_Regexp(String updatedBy, ConditionOptionCall opLambda) { + RegexpQueryBuilder builder = regRegexpQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_GreaterThan(String updatedBy) { + setUpdatedBy_GreaterThan(updatedBy, null); + } + + public void setUpdatedBy_GreaterThan(String updatedBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedBy", ConditionKey.CK_GREATER_THAN, updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_LessThan(String updatedBy) { + setUpdatedBy_LessThan(updatedBy, null); + } + + public void setUpdatedBy_LessThan(String updatedBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedBy", ConditionKey.CK_LESS_THAN, updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_GreaterEqual(String updatedBy) { + setUpdatedBy_GreaterEqual(updatedBy, null); + } + + public void setUpdatedBy_GreaterEqual(String updatedBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedBy", ConditionKey.CK_GREATER_EQUAL, updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_LessEqual(String updatedBy) { + setUpdatedBy_LessEqual(updatedBy, null); + } + + public void setUpdatedBy_LessEqual(String updatedBy, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedBy", ConditionKey.CK_LESS_EQUAL, updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_Exists() { + setUpdatedBy_Exists(null); + } + + public void setUpdatedBy_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("updatedBy"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedBy_CommonTerms(String updatedBy) { + setUpdatedBy_CommonTerms(updatedBy, null); + } + + public void setUpdatedBy_CommonTerms(String updatedBy, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("updatedBy", updatedBy); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_UpdatedBy_Asc() { + regOBA("updatedBy"); + return this; + } + + public BsApiTokenCQ addOrderBy_UpdatedBy_Desc() { + regOBD("updatedBy"); + return this; + } + + public void setUpdatedTime_Equal(Long updatedTime) { + setUpdatedTime_Term(updatedTime, null); + } + + public void setUpdatedTime_Equal(Long updatedTime, ConditionOptionCall opLambda) { + setUpdatedTime_Term(updatedTime, opLambda); + } + + public void setUpdatedTime_Term(Long updatedTime) { + setUpdatedTime_Term(updatedTime, null); + } + + public void setUpdatedTime_Term(Long updatedTime, ConditionOptionCall opLambda) { + TermQueryBuilder builder = regTermQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_NotEqual(Long updatedTime) { + setUpdatedTime_NotTerm(updatedTime, null); + } + + public void setUpdatedTime_NotTerm(Long updatedTime) { + setUpdatedTime_NotTerm(updatedTime, null); + } + + public void setUpdatedTime_NotEqual(Long updatedTime, ConditionOptionCall opLambda) { + setUpdatedTime_NotTerm(updatedTime, opLambda); + } + + public void setUpdatedTime_NotTerm(Long updatedTime, ConditionOptionCall opLambda) { + not(not -> not.setUpdatedTime_Term(updatedTime), opLambda); + } + + public void setUpdatedTime_Terms(Collection updatedTimeList) { + setUpdatedTime_Terms(updatedTimeList, null); + } + + public void setUpdatedTime_Terms(Collection updatedTimeList, ConditionOptionCall opLambda) { + TermsQueryBuilder builder = regTermsQ("updatedTime", updatedTimeList); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_InScope(Collection updatedTimeList) { + setUpdatedTime_Terms(updatedTimeList, null); + } + + public void setUpdatedTime_InScope(Collection updatedTimeList, ConditionOptionCall opLambda) { + setUpdatedTime_Terms(updatedTimeList, opLambda); + } + + public void setUpdatedTime_Match(Long updatedTime) { + setUpdatedTime_Match(updatedTime, null); + } + + public void setUpdatedTime_Match(Long updatedTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_MatchPhrase(Long updatedTime) { + setUpdatedTime_MatchPhrase(updatedTime, null); + } + + public void setUpdatedTime_MatchPhrase(Long updatedTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhraseQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_MatchPhrasePrefix(Long updatedTime) { + setUpdatedTime_MatchPhrasePrefix(updatedTime, null); + } + + public void setUpdatedTime_MatchPhrasePrefix(Long updatedTime, ConditionOptionCall opLambda) { + MatchQueryBuilder builder = regMatchPhrasePrefixQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_Fuzzy(Long updatedTime) { + setUpdatedTime_Fuzzy(updatedTime, null); + } + + public void setUpdatedTime_Fuzzy(Long updatedTime, ConditionOptionCall opLambda) { + FuzzyQueryBuilder builder = regFuzzyQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_GreaterThan(Long updatedTime) { + setUpdatedTime_GreaterThan(updatedTime, null); + } + + public void setUpdatedTime_GreaterThan(Long updatedTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedTime", ConditionKey.CK_GREATER_THAN, updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_LessThan(Long updatedTime) { + setUpdatedTime_LessThan(updatedTime, null); + } + + public void setUpdatedTime_LessThan(Long updatedTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedTime", ConditionKey.CK_LESS_THAN, updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_GreaterEqual(Long updatedTime) { + setUpdatedTime_GreaterEqual(updatedTime, null); + } + + public void setUpdatedTime_GreaterEqual(Long updatedTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedTime", ConditionKey.CK_GREATER_EQUAL, updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_LessEqual(Long updatedTime) { + setUpdatedTime_LessEqual(updatedTime, null); + } + + public void setUpdatedTime_LessEqual(Long updatedTime, ConditionOptionCall opLambda) { + RangeQueryBuilder builder = regRangeQ("updatedTime", ConditionKey.CK_LESS_EQUAL, updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_Exists() { + setUpdatedTime_Exists(null); + } + + public void setUpdatedTime_Exists(ConditionOptionCall opLambda) { + ExistsQueryBuilder builder = regExistsQ("updatedTime"); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public void setUpdatedTime_CommonTerms(Long updatedTime) { + setUpdatedTime_CommonTerms(updatedTime, null); + } + + public void setUpdatedTime_CommonTerms(Long updatedTime, ConditionOptionCall opLambda) { + CommonTermsQueryBuilder builder = regCommonTermsQ("updatedTime", updatedTime); + if (opLambda != null) { + opLambda.callback(builder); + } + } + + public BsApiTokenCQ addOrderBy_UpdatedTime_Asc() { + regOBA("updatedTime"); + return this; + } + + public BsApiTokenCQ addOrderBy_UpdatedTime_Desc() { + regOBD("updatedTime"); + return this; + } + +} diff --git a/src/main/java/org/codelibs/fess/es/config/exbhv/ApiTokenBhv.java b/src/main/java/org/codelibs/fess/es/config/exbhv/ApiTokenBhv.java new file mode 100644 index 000000000..de8de6387 --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/exbhv/ApiTokenBhv.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.exbhv; + +import org.codelibs.fess.es.config.bsbhv.BsApiTokenBhv; + +/** + * @author FreeGen + */ +public class ApiTokenBhv extends BsApiTokenBhv { + +} diff --git a/src/main/java/org/codelibs/fess/es/config/exentity/ApiToken.java b/src/main/java/org/codelibs/fess/es/config/exentity/ApiToken.java new file mode 100644 index 000000000..1fe5cb26d --- /dev/null +++ b/src/main/java/org/codelibs/fess/es/config/exentity/ApiToken.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012-2016 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.es.config.exentity; + +import org.codelibs.fess.es.config.bsentity.BsApiToken; + +/** + * @author ESFlute (using FreeGen) + */ +public class ApiToken extends BsApiToken { + + private static final long serialVersionUID = 1L; + + public String getId() { + return asDocMeta().id(); + } + + public void setId(final String id) { + asDocMeta().id(id); + } + + public Long getVersionNo() { + return asDocMeta().version(); + } + + public void setVersionNo(final Long version) { + asDocMeta().version(version); + } + + @Override + public String toString() { + return "ApiToken [name=" + name + ", token=" + token + ", createdBy=" + createdBy + ", createdTime=" + createdTime + ", updatedBy=" + + updatedBy + ", updatedTime=" + updatedTime + ", docMeta=" + docMeta + "]"; + } + +} diff --git a/src/main/java/org/codelibs/fess/helper/SystemHelper.java b/src/main/java/org/codelibs/fess/helper/SystemHelper.java index 5999b7766..96ed58f24 100644 --- a/src/main/java/org/codelibs/fess/helper/SystemHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SystemHelper.java @@ -20,6 +20,7 @@ import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.URLEncoder; import java.net.UnknownHostException; +import java.security.SecureRandom; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; @@ -27,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Random; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -36,6 +38,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.apache.commons.lang3.LocaleUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.codelibs.core.lang.StringUtil; import org.codelibs.fess.Constants; @@ -70,6 +73,8 @@ public class SystemHelper { protected List shutdownHookList = new ArrayList<>(); + protected Random random = new SecureRandom(); + @PostConstruct public void init() { final FessConfig fessConfig = ComponentUtil.getFessConfig(); @@ -298,4 +303,13 @@ public class SystemHelper { ComponentUtil.getJobManager().reboot(); } + public String generateApiToken() { + return RandomStringUtils.random(ComponentUtil.getFessConfig().getApiTokenLengthAsInteger().intValue(), 0, 0, true, true, null, + random); + } + + public void setRandom(Random random) { + this.random = random; + } + } diff --git a/src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java b/src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java index 2bba37b3a..c00990ab0 100644 --- a/src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java +++ b/src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java @@ -23,6 +23,15 @@ import org.lastaflute.web.response.next.HtmlNext; */ public interface FessHtmlPath { + /** The path of the HTML: /admin/apitoken/admin_apitoken.jsp */ + HtmlNext path_AdminApitoken_AdminApitokenJsp = new HtmlNext("/admin/apitoken/admin_apitoken.jsp"); + + /** The path of the HTML: /admin/apitoken/admin_apitoken_details.jsp */ + HtmlNext path_AdminApitoken_AdminApitokenDetailsJsp = new HtmlNext("/admin/apitoken/admin_apitoken_details.jsp"); + + /** The path of the HTML: /admin/apitoken/admin_apitoken_edit.jsp */ + HtmlNext path_AdminApitoken_AdminApitokenEditJsp = new HtmlNext("/admin/apitoken/admin_apitoken_edit.jsp"); + /** The path of the HTML: /admin/backup/admin_backup.jsp */ HtmlNext path_AdminBackup_AdminBackupJsp = new HtmlNext("/admin/backup/admin_backup.jsp"); diff --git a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java index fe04243b2..893b95869 100644 --- a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java +++ b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java @@ -560,6 +560,9 @@ public class FessLabels extends UserMessages { /** The key of the message: Back Up */ public static final String LABELS_menu_backup = "{labels.menu_backup}"; + /** The key of the message: API Token */ + public static final String LABELS_menu_api_token = "{labels.menu_api_token}"; + /** The key of the message: Search... */ public static final String LABELS_SIDEBAR_placeholder_search = "{labels.sidebar.placeholder_search}"; @@ -2079,6 +2082,24 @@ public class FessLabels extends UserMessages { /** The key of the message: Sort Order */ public static final String LABELS_boost_document_rule_sort_order = "{labels.boost_document_rule_sort_order}"; + /** The key of the message: API Token */ + public static final String LABELS_api_token_configuration = "{labels.api_token_configuration}"; + + /** The key of the message: API Token */ + public static final String LABELS_api_token_title_details = "{labels.api_token_title_details}"; + + /** The key of the message: Name */ + public static final String LABELS_api_token_list_name = "{labels.api_token_list_name}"; + + /** The key of the message: Name */ + public static final String LABELS_api_token_name = "{labels.api_token_name}"; + + /** The key of the message: Token */ + public static final String LABELS_api_token_token = "{labels.api_token_token}"; + + /** The key of the message: Created */ + public static final String LABELS_api_token_updated_time = "{labels.api_token_updated_time}"; + /** The key of the message: Additional Word */ public static final String LABELS_elevate_word_configuration = "{labels.elevate_word_configuration}"; diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 44e0f15eb..8684bc465 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -116,6 +116,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. ar,bg,ca,da,de,el,en,es,eu,fa,fi,fr,ga,gl,hi,hu,hy,id,it,ja,lv,ko,nl,no,pt,ro,ru,sv,th,tr,zh_CN,zh_TW,zh */ String SUPPORTED_LANGUAGES = "supported.languages"; + /** The key of the configuration. e.g. 60 */ + String API_TOKEN_LENGTH = "api.token.length"; + /** The key of the configuration. e.g. 50 */ String CRAWLER_DOCUMENT_MAX_SITE_LENGTH = "crawler.document.max.site.length"; @@ -772,6 +775,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. esreq */ String ONLINE_HELP_NAME_ESREQ = "online.help.name.esreq"; + /** The key of the configuration. e.g. apitoken */ + String ONLINE_HELP_NAME_APITOKEN = "online.help.name.apitoken"; + /** The key of the configuration. e.g. ja */ String ONLINE_HELP_SUPPORTED_LANGS = "online.help.supported.langs"; @@ -1275,6 +1281,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ String getSupportedLanguages(); + /** + * Get the value for the key 'api.token.length'.
+ * The value is, e.g. 60
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getApiTokenLength(); + + /** + * Get the value for the key 'api.token.length' as {@link Integer}.
+ * The value is, e.g. 60
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getApiTokenLengthAsInteger(); + /** * Get the value for the key 'crawler.document.max.site.length'.
* The value is, e.g. 50
@@ -3446,6 +3467,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ String getOnlineHelpNameEsreq(); + /** + * Get the value for the key 'online.help.name.apitoken'.
+ * The value is, e.g. apitoken
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getOnlineHelpNameApitoken(); + /** * Get the value for the key 'online.help.supported.langs'.
* The value is, e.g. ja
@@ -4404,6 +4432,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return get(FessConfig.SUPPORTED_LANGUAGES); } + public String getApiTokenLength() { + return get(FessConfig.API_TOKEN_LENGTH); + } + + public Integer getApiTokenLengthAsInteger() { + return getAsInteger(FessConfig.API_TOKEN_LENGTH); + } + public String getCrawlerDocumentMaxSiteLength() { return get(FessConfig.CRAWLER_DOCUMENT_MAX_SITE_LENGTH); } @@ -5552,6 +5588,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return get(FessConfig.ONLINE_HELP_NAME_ESREQ); } + public String getOnlineHelpNameApitoken() { + return get(FessConfig.ONLINE_HELP_NAME_APITOKEN); + } + public String getOnlineHelpSupportedLangs() { return get(FessConfig.ONLINE_HELP_SUPPORTED_LANGS); } diff --git a/src/main/resources/esflute_config.xml b/src/main/resources/esflute_config.xml index e3e25407a..2bda4d402 100644 --- a/src/main/resources/esflute_config.xml +++ b/src/main/resources/esflute_config.xml @@ -8,6 +8,7 @@ + diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index 98086edd3..40270d2ec 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -71,6 +71,7 @@ supported.uploaded.css.extentions=css supported.uploaded.media.extentions=jpg,jpeg,gif,png,swf supported.uploaded.files=license.properties supported.languages=ar,bg,ca,da,de,el,en,es,eu,fa,fi,fr,ga,gl,hi,hu,hy,id,it,ja,lv,ko,nl,no,pt,ro,ru,sv,th,tr,zh_CN,zh_TW,zh +api.token.length=60 # ======================================================================================== # Index @@ -402,6 +403,7 @@ online.help.name.crawlinginfo=crawlinginfo online.help.name.backup=backup online.help.name.upgrade=upgrade online.help.name.esreq=esreq +online.help.name.apitoken=apitoken online.help.supported.langs=ja diff --git a/src/main/resources/fess_indices/.fess_config/api_token.json b/src/main/resources/fess_indices/.fess_config/api_token.json new file mode 100644 index 000000000..ab777a2ed --- /dev/null +++ b/src/main/resources/fess_indices/.fess_config/api_token.json @@ -0,0 +1,34 @@ +{ + "api_token": { + "_source": { + "enabled": true + }, + "_all": { + "enabled": false + }, + "properties": { + "name": { + "type": "string", + "index": "not_analyzed" + }, + "token": { + "type": "string", + "index": "not_analyzed" + }, + "createdBy": { + "type": "string", + "index": "not_analyzed" + }, + "createdTime": { + "type": "long" + }, + "updatedBy": { + "type": "string", + "index": "not_analyzed" + }, + "updatedTime": { + "type": "long" + } + } + } +} diff --git a/src/main/resources/fess_label.properties b/src/main/resources/fess_label.properties index f43a9ba98..6f9a72ffd 100644 --- a/src/main/resources/fess_label.properties +++ b/src/main/resources/fess_label.properties @@ -177,6 +177,7 @@ labels.menu_jobLog=Job Log labels.menu_failure_url=Failure URL labels.menu_search_list=Search labels.menu_backup=Back Up +labels.menu_api_token=API Token labels.sidebar.placeholder_search=Search... labels.sidebar.menu=MENU labels.footer.copyright=Copyright(C) 2009-2016 CodeLibs Project. All Rights Reserved. @@ -683,6 +684,12 @@ labels.boost_document_rule_list_url_expr=Condition labels.boost_document_rule_url_expr=Condition labels.boost_document_rule_boost_expr=Boost Expr labels.boost_document_rule_sort_order=Sort Order +labels.api_token_configuration=API Token +labels.api_token_title_details=API Token +labels.api_token_list_name=Name +labels.api_token_name=Name +labels.api_token_token=Token +labels.api_token_updated_time=Created labels.elevate_word_configuration=Additional Word labels.elevate_word_title_details=Additional Word labels.elevate_word_link_list=List diff --git a/src/main/resources/fess_label_en.properties b/src/main/resources/fess_label_en.properties index e4316decd..18f868506 100644 --- a/src/main/resources/fess_label_en.properties +++ b/src/main/resources/fess_label_en.properties @@ -177,6 +177,7 @@ labels.menu_jobLog=Job Log labels.menu_failure_url=Failure URL labels.menu_search_list=Search labels.menu_backup=Back Up +labels.menu_api_token=API Token labels.sidebar.placeholder_search=Search... labels.sidebar.menu=MENU labels.footer.copyright=Copyright(C) 2009-2016 CodeLibs Project. All Rights Reserved. @@ -683,6 +684,12 @@ labels.boost_document_rule_list_url_expr=Condition labels.boost_document_rule_url_expr=Condition labels.boost_document_rule_boost_expr=Boost Expr labels.boost_document_rule_sort_order=Sort Order +labels.api_token_configuration=API Token +labels.api_token_title_details=API Token +labels.api_token_list_name=Name +labels.api_token_name=Name +labels.api_token_token=Token +labels.api_token_updated_time=Created labels.elevate_word_configuration=Additional Word labels.elevate_word_title_details=Additional Word labels.elevate_word_link_list=List diff --git a/src/main/resources/fess_label_ja.properties b/src/main/resources/fess_label_ja.properties index a41077faf..0ec751223 100644 --- a/src/main/resources/fess_label_ja.properties +++ b/src/main/resources/fess_label_ja.properties @@ -173,6 +173,7 @@ labels.menu_jobLog=\u30b8\u30e7\u30d6\u30ed\u30b0 labels.menu_failure_url=\u969c\u5bb3URL labels.menu_search_list=\u691c\u7d22 labels.menu_backup=\u30d0\u30c3\u30af\u30a2\u30c3\u30d7 +labels.menu_api_token=API\u30c8\u30fc\u30af\u30f3 labels.sidebar.placeholder_search=\u691c\u7d22... labels.sidebar.menu=\u30e1\u30cb\u30e5\u30fc labels.footer.copyright=Copyright(C) 2009-2016 CodeLibs Project. All Rights Reserved. @@ -681,6 +682,12 @@ labels.boost_document_rule_list_url_expr=\u72b6\u614b labels.boost_document_rule_url_expr=\u72b6\u614b labels.boost_document_rule_boost_expr=\u30d6\u30fc\u30b9\u30c8\u5024\u5f0f labels.boost_document_rule_sort_order=\u30bd\u30fc\u30c8\u9806 +labels.api_token_configuration=API\u30c8\u30fc\u30af\u30f3 +labels.api_token_title_details=API\u30c8\u30fc\u30af\u30f3 +labels.api_token_list_name=\u540d\u524d +labels.api_token_name=\u540d\u524d +labels.api_token_token=\u30c8\u30fc\u30af\u30f3 +labels.api_token_updated_time=\u4f5c\u6210\u65e5 labels.elevate_word_configuration=\u8ffd\u52a0\u306e\u5358\u8a9e labels.elevate_word_title_details=\u8ffd\u52a0\u306e\u5358\u8a9e labels.elevate_word_link_list=\u4e00\u89a7 diff --git a/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken.jsp b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken.jsp new file mode 100644 index 000000000..a5b32cff1 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken.jsp @@ -0,0 +1,86 @@ +<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> + + + +<la:message key="labels.admin_brand_title" /> | <la:message + key="labels.api_token_configuration" /> + + + +
+ + + + + +
+
+

+ +

+ +
+
+
+
+
+
+ +
+ +
+ <%-- Message --%> +
+ +
${msg}
+
+ +
+ <%-- List --%> + +
+
+ + +
+
+
+ +
+
+ + + + + + + + + + + + + +
${f:h(data.name)}
+
+
+ + +
+
+ +
+ +
+
+
+
+ +
+ + + diff --git a/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_details.jsp b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_details.jsp new file mode 100644 index 000000000..441a67a9b --- /dev/null +++ b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_details.jsp @@ -0,0 +1,136 @@ +<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> + + + +<la:message key="labels.admin_brand_title" /> | <la:message + key="labels.api_token_configuration" /> + + + +
+ + + + + +
+
+

+ +

+ +
+
+ + + + + + + + +
+
+
box-successbox-warningbox-dangerbox-primary"> + <%-- Box Header --%> +
+ +
+ <%-- Box Body --%> +
+ <%-- Message --%> +
+ +
${msg}
+
+ +
+ <%-- Form Fields --%> + + + + + + + + + + + + + + + +
${f:h(name)}
${f:h(token)}
${fe:date(updatedTime)}
+
+ + + +
+ +
+
+
+ +
+
+ +
+ + + diff --git a/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_edit.jsp b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_edit.jsp new file mode 100644 index 000000000..4faa56ac1 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/admin/apitoken/admin_apitoken_edit.jsp @@ -0,0 +1,72 @@ +<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> + + + +<la:message key="labels.admin_brand_title" /> | <la:message + key="labels.api_token_configuration" /> + + + +
+ + + + + +
+
+

+ +

+ +
+
+ + + + + + + + +
+
+
box-successbox-warning"> +
+ +
+ +
+
+ +
${msg}
+
+ +
+
+ +
+ + +
+
+
+ + + +
+ +
+
+
+
+
+ +
+ + + diff --git a/src/main/webapp/WEB-INF/view/common/admin/sidebar.jsp b/src/main/webapp/WEB-INF/view/common/admin/sidebar.jsp index 7bc0472ea..3d239c873 100644 --- a/src/main/webapp/WEB-INF/view/common/admin/sidebar.jsp +++ b/src/main/webapp/WEB-INF/view/common/admin/sidebar.jsp @@ -70,6 +70,12 @@ +
  • class="active"> + + +
  • +
  • active">