#738 api token management
This commit is contained in:
parent
a94d15d0ca
commit
816f30ca3c
30 changed files with 3388 additions and 0 deletions
|
@ -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
|
||||
|
|
138
src/main/java/org/codelibs/fess/app/pager/ApiTokenPager.java
Normal file
138
src/main/java/org/codelibs/fess/app/pager/ApiTokenPager.java
Normal file
|
@ -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<Integer> 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<Integer> getPageNumberList() {
|
||||
return pageNumberList;
|
||||
}
|
||||
|
||||
public void setPageNumberList(final List<Integer> pageNumberList) {
|
||||
this.pageNumberList = pageNumberList;
|
||||
}
|
||||
|
||||
protected int getDefaultCurrentPageNumber() {
|
||||
return Constants.DEFAULT_ADMIN_PAGE_NUMBER;
|
||||
}
|
||||
|
||||
protected int getDefaultPageSize() {
|
||||
return Constants.DEFAULT_ADMIN_PAGE_SIZE;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<ApiToken> getApiTokenList(final ApiTokenPager apiTokenPager) {
|
||||
|
||||
final PagingResultBean<ApiToken> 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<ApiToken> 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
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Integer> 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<ApiToken> 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<ApiToken> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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<ApiToken, ApiTokenCB> {
|
||||
|
||||
// ===================================================================================
|
||||
// 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 extends ApiToken> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> 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<ApiTokenCB> cbLambda) {
|
||||
return facadeSelectCount(createCB(cbLambda));
|
||||
}
|
||||
|
||||
public OptionalEntity<ApiToken> selectEntity(CBCall<ApiTokenCB> cbLambda) {
|
||||
return facadeSelectEntity(createCB(cbLambda));
|
||||
}
|
||||
|
||||
protected OptionalEntity<ApiToken> facadeSelectEntity(ApiTokenCB cb) {
|
||||
return doSelectOptionalEntity(cb, typeOfSelectedEntity());
|
||||
}
|
||||
|
||||
protected <ENTITY extends ApiToken> OptionalEntity<ENTITY> doSelectOptionalEntity(ApiTokenCB cb, Class<? extends ENTITY> 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<ApiTokenCB> cbLambda) {
|
||||
return facadeSelectEntityWithDeletedCheck(createCB(cbLambda));
|
||||
}
|
||||
|
||||
public OptionalEntity<ApiToken> selectByPK(String id) {
|
||||
return facadeSelectByPK(id);
|
||||
}
|
||||
|
||||
protected OptionalEntity<ApiToken> facadeSelectByPK(String id) {
|
||||
return doSelectOptionalByPK(id, typeOfSelectedEntity());
|
||||
}
|
||||
|
||||
protected <ENTITY extends ApiToken> ENTITY doSelectByPK(String id, Class<? extends ENTITY> tp) {
|
||||
return doSelectEntity(xprepareCBAsPK(id), tp);
|
||||
}
|
||||
|
||||
protected ApiTokenCB xprepareCBAsPK(String id) {
|
||||
assertObjectNotNull("id", id);
|
||||
return newConditionBean().acceptPK(id);
|
||||
}
|
||||
|
||||
protected <ENTITY extends ApiToken> OptionalEntity<ENTITY> doSelectOptionalByPK(String id, Class<? extends ENTITY> tp) {
|
||||
return createOptionalEntity(doSelectByPK(id, tp), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ApiToken> typeOfSelectedEntity() {
|
||||
return ApiToken.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ApiToken> typeOfHandlingEntity() {
|
||||
return ApiToken.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ApiTokenCB> typeOfHandlingConditionBean() {
|
||||
return ApiTokenCB.class;
|
||||
}
|
||||
|
||||
public ListResultBean<ApiToken> selectList(CBCall<ApiTokenCB> cbLambda) {
|
||||
return facadeSelectList(createCB(cbLambda));
|
||||
}
|
||||
|
||||
public PagingResultBean<ApiToken> selectPage(CBCall<ApiTokenCB> cbLambda) {
|
||||
// #pending same?
|
||||
return (PagingResultBean<ApiToken>) facadeSelectList(createCB(cbLambda));
|
||||
}
|
||||
|
||||
public void selectCursor(CBCall<ApiTokenCB> cbLambda, EntityRowHandler<ApiToken> entityLambda) {
|
||||
facadeSelectCursor(createCB(cbLambda), entityLambda);
|
||||
}
|
||||
|
||||
public void selectBulk(CBCall<ApiTokenCB> cbLambda, EntityRowHandler<List<ApiToken>> entityLambda) {
|
||||
delegateSelectBulk(createCB(cbLambda), entityLambda, typeOfSelectedEntity());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Update
|
||||
// ======
|
||||
public void insert(ApiToken entity) {
|
||||
doInsert(entity, null);
|
||||
}
|
||||
|
||||
public void insert(ApiToken entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
|
||||
entity.asDocMeta().indexOption(opLambda);
|
||||
doInsert(entity, null);
|
||||
}
|
||||
|
||||
public void update(ApiToken entity) {
|
||||
doUpdate(entity, null);
|
||||
}
|
||||
|
||||
public void update(ApiToken entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
|
||||
entity.asDocMeta().indexOption(opLambda);
|
||||
doUpdate(entity, null);
|
||||
}
|
||||
|
||||
public void insertOrUpdate(ApiToken entity) {
|
||||
doInsertOrUpdate(entity, null, null);
|
||||
}
|
||||
|
||||
public void insertOrUpdate(ApiToken entity, RequestOptionCall<IndexRequestBuilder> opLambda) {
|
||||
entity.asDocMeta().indexOption(opLambda);
|
||||
doInsertOrUpdate(entity, null, null);
|
||||
}
|
||||
|
||||
public void delete(ApiToken entity) {
|
||||
doDelete(entity, null);
|
||||
}
|
||||
|
||||
public void delete(ApiToken entity, RequestOptionCall<DeleteRequestBuilder> opLambda) {
|
||||
entity.asDocMeta().deleteOption(opLambda);
|
||||
doDelete(entity, null);
|
||||
}
|
||||
|
||||
public int queryDelete(CBCall<ApiTokenCB> cbLambda) {
|
||||
return doQueryDelete(createCB(cbLambda), null);
|
||||
}
|
||||
|
||||
public int[] batchInsert(List<ApiToken> list) {
|
||||
return batchInsert(list, null, null);
|
||||
}
|
||||
|
||||
public int[] batchInsert(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call) {
|
||||
return batchInsert(list, call, null);
|
||||
}
|
||||
|
||||
public int[] batchInsert(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call,
|
||||
RequestOptionCall<IndexRequestBuilder> entityCall) {
|
||||
return doBatchInsert(new BulkList<>(list, call, entityCall), null);
|
||||
}
|
||||
|
||||
public int[] batchUpdate(List<ApiToken> list) {
|
||||
return batchUpdate(list, null, null);
|
||||
}
|
||||
|
||||
public int[] batchUpdate(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call) {
|
||||
return batchUpdate(list, call, null);
|
||||
}
|
||||
|
||||
public int[] batchUpdate(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call,
|
||||
RequestOptionCall<IndexRequestBuilder> entityCall) {
|
||||
return doBatchUpdate(new BulkList<>(list, call, entityCall), null);
|
||||
}
|
||||
|
||||
public int[] batchDelete(List<ApiToken> list) {
|
||||
return batchDelete(list, null, null);
|
||||
}
|
||||
|
||||
public int[] batchDelete(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call) {
|
||||
return batchDelete(list, call, null);
|
||||
}
|
||||
|
||||
public int[] batchDelete(List<ApiToken> list, RequestOptionCall<BulkRequestBuilder> call,
|
||||
RequestOptionCall<IndexRequestBuilder> entityCall) {
|
||||
return doBatchDelete(new BulkList<>(list, call, entityCall), null);
|
||||
}
|
||||
|
||||
// #pending create, modify, remove
|
||||
}
|
|
@ -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<String, Object> toSource() {
|
||||
Map<String, Object> 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;
|
||||
}
|
||||
}
|
|
@ -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<String, PropertyGateway> _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<ColumnInfo> ccil() {
|
||||
List<ColumnInfo> 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<? extends Entity> getEntityType() {
|
||||
return ApiToken.class;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Object Instance
|
||||
// ===============
|
||||
@Override
|
||||
public Entity newEntity() {
|
||||
return new ApiToken();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Map Communication
|
||||
// =================
|
||||
@Override
|
||||
public void acceptPrimaryKeyMap(Entity entity, Map<String, ? extends Object> primaryKeyMap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptAllColumnMap(Entity entity, Map<String, ? extends Object> allColumnMap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> extractPrimaryKeyMap(Entity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> extractAllColumnMap(Entity entity) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
}
|
|
@ -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<String, ? extends Object> 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<String> 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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Runnable> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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}";
|
||||
|
||||
|
|
|
@ -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'. <br>
|
||||
* The value is, e.g. 60 <br>
|
||||
* @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}. <br>
|
||||
* The value is, e.g. 60 <br>
|
||||
* @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'. <br>
|
||||
* The value is, e.g. 50 <br>
|
||||
|
@ -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'. <br>
|
||||
* The value is, e.g. apitoken <br>
|
||||
* @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'. <br>
|
||||
* The value is, e.g. ja <br>
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<component name="behaviorCommandInvoker" class="org.dbflute.bhv.core.BehaviorCommandInvoker"/>
|
||||
|
||||
<!-- The components of Behavior. -->
|
||||
<component name="apiTokenBhv" class="org.codelibs.fess.es.config.exbhv.ApiTokenBhv"/>
|
||||
<component name="boostDocumentRuleBhv" class="org.codelibs.fess.es.config.exbhv.BoostDocumentRuleBhv"/>
|
||||
<component name="crawlingInfoBhv" class="org.codelibs.fess.es.config.exbhv.CrawlingInfoBhv"/>
|
||||
<component name="crawlingInfoParamBhv" class="org.codelibs.fess.es.config.exbhv.CrawlingInfoParamBhv"/>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
34
src/main/resources/fess_indices/.fess_config/api_token.json
Normal file
34
src/main/resources/fess_indices/.fess_config/api_token.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <a href="https://github.com/codelibs">CodeLibs Project</a>. <span class="br-phone"></span>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
|
||||
|
|
|
@ -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 <a href="https://github.com/codelibs">CodeLibs Project</a>. <span class="br-phone"></span>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
|
||||
|
|
|
@ -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 <a href="https://github.com/codelibs">CodeLibs Project</a>. <span class="br-phone"></span>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
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><la:message key="labels.admin_brand_title" /> | <la:message
|
||||
key="labels.api_token_configuration" /></title>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/head.jsp"></jsp:include>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/header.jsp"></jsp:include>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/sidebar.jsp">
|
||||
<jsp:param name="menuCategoryType" value="crawl" />
|
||||
<jsp:param name="menuType" value="apiToken" />
|
||||
</jsp:include>
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<la:message key="labels.api_token_configuration" />
|
||||
</h1>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/breadcrumb.jsp"></jsp:include>
|
||||
</section>
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/header.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<%-- Message --%>
|
||||
<div>
|
||||
<la:info id="msg" message="true">
|
||||
<div class="alert alert-info">${msg}</div>
|
||||
</la:info>
|
||||
<la:errors />
|
||||
</div>
|
||||
<%-- List --%>
|
||||
<c:if test="${apiTokenPager.allRecordCount == 0}">
|
||||
<div class="row top10">
|
||||
<div class="col-sm-12">
|
||||
<i class="fa fa-info-circle text-light-blue"></i>
|
||||
<la:message key="labels.list_could_not_find_crud_table" />
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
<c:if test="${apiTokenPager.allRecordCount > 0}">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><la:message
|
||||
key="labels.api_token_list_name" /></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="data" varStatus="s"
|
||||
items="${apiTokenItems}">
|
||||
<tr
|
||||
data-href="${contextPath}/admin/apitoken/details/4/${f:u(data.id)}">
|
||||
<td>${f:h(data.name)}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<c:set var="pager" value="${apiTokenPager}"
|
||||
scope="request" />
|
||||
<c:import url="/WEB-INF/view/common/admin/crud/pagination.jsp" />
|
||||
</c:if>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/footer.jsp"></jsp:include>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/foot.jsp"></jsp:include>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,136 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><la:message key="labels.admin_brand_title" /> | <la:message
|
||||
key="labels.api_token_configuration" /></title>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/head.jsp"></jsp:include>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/header.jsp"></jsp:include>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/sidebar.jsp">
|
||||
<jsp:param name="menuCategoryType" value="crawl" />
|
||||
<jsp:param name="menuType" value="apiToken" />
|
||||
</jsp:include>
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<la:message key="labels.api_token_title_details" />
|
||||
</h1>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/breadcrumb.jsp"></jsp:include>
|
||||
</section>
|
||||
<section class="content">
|
||||
<la:form action="/admin/apitoken/">
|
||||
<la:hidden property="crudMode" />
|
||||
<c:if test="${crudMode==2 || crudMode==3 || crudMode==4}">
|
||||
<la:hidden property="id" />
|
||||
<la:hidden property="versionNo" />
|
||||
</c:if>
|
||||
<la:hidden property="createdBy" />
|
||||
<la:hidden property="createdTime" />
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div
|
||||
class="box <c:if test="${crudMode == 1}">box-success</c:if><c:if test="${crudMode == 2}">box-warning</c:if><c:if test="${crudMode == 3}">box-danger</c:if><c:if test="${crudMode == 4}">box-primary</c:if>">
|
||||
<%-- Box Header --%>
|
||||
<div class="box-header with-border">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/header.jsp"></jsp:include>
|
||||
</div>
|
||||
<%-- Box Body --%>
|
||||
<div class="box-body">
|
||||
<%-- Message --%>
|
||||
<div>
|
||||
<la:info id="msg" message="true">
|
||||
<div class="alert alert-info">${msg}</div>
|
||||
</la:info>
|
||||
<la:errors />
|
||||
</div>
|
||||
<%-- Form Fields --%>
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-xs-2"><la:message
|
||||
key="labels.api_token_name" /></th>
|
||||
<td>${f:h(name)}<la:hidden property="name" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><la:message
|
||||
key="labels.api_token_token" /></th>
|
||||
<td>${f:h(token)}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><la:message
|
||||
key="labels.api_token_updated_time" /></th>
|
||||
<td>${fe:date(updatedTime)}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn btn-default" name="list" value="back">
|
||||
<i class="fa fa-arrow-circle-left"></i>
|
||||
<la:message key="labels.crud_button_back" />
|
||||
</button>
|
||||
<%--
|
||||
<button type="submit" class="btn btn-warning" name="edit"
|
||||
value="<la:message key="labels.crud_button_edit" />">
|
||||
<i class="fa fa-pencil"></i>
|
||||
<la:message key="labels.crud_button_edit" />
|
||||
</button>
|
||||
--%>
|
||||
<button type="button" class="btn btn-danger" name="delete"
|
||||
data-toggle="modal" data-target="#confirmToDelete"
|
||||
value="<la:message key="labels.crud_button_delete" />">
|
||||
<i class="fa fa-trash"></i>
|
||||
<la:message key="labels.crud_button_delete" />
|
||||
</button>
|
||||
<div class="modal modal-danger fade" id="confirmToDelete" tabindex="-1"
|
||||
role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">
|
||||
<la:message key="labels.crud_title_delete" />
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<la:message key="labels.crud_delete_confirmation" />
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline pull-left"
|
||||
data-dismiss="modal">
|
||||
<la:message key="labels.crud_button_cancel" />
|
||||
</button>
|
||||
<button type="submit" class="btn btn-outline btn-danger"
|
||||
name="delete"
|
||||
value="<la:message key="labels.crud_button_delete" />">
|
||||
<i class="fa fa-trash"></i>
|
||||
<la:message key="labels.crud_button_delete" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
</div>
|
||||
</la:form>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/footer.jsp"></jsp:include>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/foot.jsp"></jsp:include>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><la:message key="labels.admin_brand_title" /> | <la:message
|
||||
key="labels.api_token_configuration" /></title>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/head.jsp"></jsp:include>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/header.jsp"></jsp:include>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/sidebar.jsp">
|
||||
<jsp:param name="menuCategoryType" value="crawl" />
|
||||
<jsp:param name="menuType" value="apiToken" />
|
||||
</jsp:include>
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<la:message key="labels.api_token_title_details" />
|
||||
</h1>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/breadcrumb.jsp"></jsp:include>
|
||||
</section>
|
||||
<section class="content">
|
||||
<la:form action="/admin/apitoken/" styleClass="form-horizontal">
|
||||
<la:hidden property="crudMode" />
|
||||
<c:if test="${crudMode==2}">
|
||||
<la:hidden property="id" />
|
||||
<la:hidden property="versionNo" />
|
||||
</c:if>
|
||||
<la:hidden property="createdBy" />
|
||||
<la:hidden property="createdTime" />
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div
|
||||
class="box <c:if test="${crudMode == 1}">box-success</c:if><c:if test="${crudMode == 2}">box-warning</c:if>">
|
||||
<div class="box-header with-border">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/header.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<div>
|
||||
<la:info id="msg" message="true">
|
||||
<div class="alert alert-info">${msg}</div>
|
||||
</la:info>
|
||||
<la:errors property="_global" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-3 control-label"><la:message
|
||||
key="labels.api_token_name" /></label>
|
||||
<div class="col-sm-9">
|
||||
<la:errors property="name" />
|
||||
<la:text property="name" styleClass="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/buttons.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
</div>
|
||||
</la:form>
|
||||
</section>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/footer.jsp"></jsp:include>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/foot.jsp"></jsp:include>
|
||||
</body>
|
||||
</html>
|
|
@ -70,6 +70,12 @@
|
|||
<span><la:message key="labels.menu_dict" /></span>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='apiToken'}">class="active"</c:if>><la:link
|
||||
href="/admin/apitoken/">
|
||||
<i class='fa fa-circle-o'></i>
|
||||
<span><la:message key="labels.menu_api_token" /></span>
|
||||
</la:link></li>
|
||||
|
||||
</ul></li>
|
||||
<li
|
||||
class="treeview <c:if test="${param.menuCategoryType=='crawl'}">active</c:if>"><a
|
||||
|
|
Loading…
Add table
Reference in a new issue