This commit is contained in:
parent
47a160b0e0
commit
c7e9305bf5
8 changed files with 467 additions and 57 deletions
|
@ -309,4 +309,10 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final int DEFAULT_START_COUNT = 0;
|
||||
|
||||
public static final String PROCESS_TYPE_CRAWLING = "C";
|
||||
|
||||
public static final String PROCESS_TYPE_DISPLAYING = "D";
|
||||
|
||||
public static final String PROCESS_TYPE_BOTH = "B";
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,12 @@ import org.codelibs.fess.entity.SearchQuery.SortField;
|
|||
import org.codelibs.fess.solr.FessSolrQueryException;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.ActionFuture;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestBuilder;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
|
@ -34,13 +39,78 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
|||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
import org.elasticsearch.action.count.CountRequest;
|
||||
import org.elasticsearch.action.count.CountRequestBuilder;
|
||||
import org.elasticsearch.action.count.CountResponse;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteRequestBuilder;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.deletebyquery.DeleteByQueryRequest;
|
||||
import org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder;
|
||||
import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
|
||||
import org.elasticsearch.action.exists.ExistsRequest;
|
||||
import org.elasticsearch.action.exists.ExistsRequestBuilder;
|
||||
import org.elasticsearch.action.exists.ExistsResponse;
|
||||
import org.elasticsearch.action.explain.ExplainRequest;
|
||||
import org.elasticsearch.action.explain.ExplainRequestBuilder;
|
||||
import org.elasticsearch.action.explain.ExplainResponse;
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsRequest;
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsRequestBuilder;
|
||||
import org.elasticsearch.action.fieldstats.FieldStatsResponse;
|
||||
import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.GetRequestBuilder;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.get.MultiGetRequest;
|
||||
import org.elasticsearch.action.get.MultiGetRequestBuilder;
|
||||
import org.elasticsearch.action.get.MultiGetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest.OpType;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptRequest;
|
||||
import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptRequestBuilder;
|
||||
import org.elasticsearch.action.indexedscripts.delete.DeleteIndexedScriptResponse;
|
||||
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptRequest;
|
||||
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptRequestBuilder;
|
||||
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse;
|
||||
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequest;
|
||||
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequestBuilder;
|
||||
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptResponse;
|
||||
import org.elasticsearch.action.mlt.MoreLikeThisRequest;
|
||||
import org.elasticsearch.action.mlt.MoreLikeThisRequestBuilder;
|
||||
import org.elasticsearch.action.percolate.MultiPercolateRequest;
|
||||
import org.elasticsearch.action.percolate.MultiPercolateRequestBuilder;
|
||||
import org.elasticsearch.action.percolate.MultiPercolateResponse;
|
||||
import org.elasticsearch.action.percolate.PercolateRequest;
|
||||
import org.elasticsearch.action.percolate.PercolateRequestBuilder;
|
||||
import org.elasticsearch.action.percolate.PercolateResponse;
|
||||
import org.elasticsearch.action.search.ClearScrollRequest;
|
||||
import org.elasticsearch.action.search.ClearScrollRequestBuilder;
|
||||
import org.elasticsearch.action.search.ClearScrollResponse;
|
||||
import org.elasticsearch.action.search.MultiSearchRequest;
|
||||
import org.elasticsearch.action.search.MultiSearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.MultiSearchResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchScrollRequest;
|
||||
import org.elasticsearch.action.search.SearchScrollRequestBuilder;
|
||||
import org.elasticsearch.action.suggest.SuggestRequest;
|
||||
import org.elasticsearch.action.suggest.SuggestRequestBuilder;
|
||||
import org.elasticsearch.action.suggest.SuggestResponse;
|
||||
import org.elasticsearch.action.termvector.MultiTermVectorsRequest;
|
||||
import org.elasticsearch.action.termvector.MultiTermVectorsRequestBuilder;
|
||||
import org.elasticsearch.action.termvector.MultiTermVectorsResponse;
|
||||
import org.elasticsearch.action.termvector.TermVectorRequest;
|
||||
import org.elasticsearch.action.termvector.TermVectorRequestBuilder;
|
||||
import org.elasticsearch.action.termvector.TermVectorResponse;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.action.update.UpdateRequestBuilder;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.client.AdminClient;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
|
@ -64,6 +134,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
|
|||
import org.elasticsearch.search.sort.FieldSortBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.seasar.framework.container.annotation.tiger.DestroyMethod;
|
||||
import org.seasar.framework.container.annotation.tiger.InitMethod;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -71,7 +142,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
public class FessEsClient {
|
||||
public class FessEsClient implements Client {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FessEsClient.class);
|
||||
|
||||
protected ElasticsearchClusterRunner runner;
|
||||
|
@ -640,4 +711,359 @@ public class FessEsClient {
|
|||
T build(SearchResponse response, SearchHit hit);
|
||||
}
|
||||
|
||||
//
|
||||
// Elasticsearch Client
|
||||
//
|
||||
|
||||
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder, Client>> ActionFuture<Response> execute(
|
||||
Action<Request, Response, RequestBuilder, Client> action, Request request) {
|
||||
return client.execute(action, request);
|
||||
}
|
||||
|
||||
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder, Client>> void execute(
|
||||
Action<Request, Response, RequestBuilder, Client> action, Request request, ActionListener<Response> listener) {
|
||||
client.execute(action, request, listener);
|
||||
}
|
||||
|
||||
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder, Client>> RequestBuilder prepareExecute(
|
||||
Action<Request, Response, RequestBuilder, Client> action) {
|
||||
return client.prepareExecute(action);
|
||||
}
|
||||
|
||||
public ThreadPool threadPool() {
|
||||
return client.threadPool();
|
||||
}
|
||||
|
||||
public AdminClient admin() {
|
||||
return client.admin();
|
||||
}
|
||||
|
||||
public ActionFuture<IndexResponse> index(IndexRequest request) {
|
||||
return client.index(request);
|
||||
}
|
||||
|
||||
public void index(IndexRequest request, ActionListener<IndexResponse> listener) {
|
||||
client.index(request, listener);
|
||||
}
|
||||
|
||||
public IndexRequestBuilder prepareIndex() {
|
||||
return client.prepareIndex();
|
||||
}
|
||||
|
||||
public ActionFuture<UpdateResponse> update(UpdateRequest request) {
|
||||
return client.update(request);
|
||||
}
|
||||
|
||||
public void update(UpdateRequest request, ActionListener<UpdateResponse> listener) {
|
||||
client.update(request, listener);
|
||||
}
|
||||
|
||||
public UpdateRequestBuilder prepareUpdate() {
|
||||
return client.prepareUpdate();
|
||||
}
|
||||
|
||||
public UpdateRequestBuilder prepareUpdate(String index, String type, String id) {
|
||||
return client.prepareUpdate(index, type, id);
|
||||
}
|
||||
|
||||
public IndexRequestBuilder prepareIndex(String index, String type) {
|
||||
return client.prepareIndex(index, type);
|
||||
}
|
||||
|
||||
public IndexRequestBuilder prepareIndex(String index, String type, String id) {
|
||||
return client.prepareIndex(index, type, id);
|
||||
}
|
||||
|
||||
public ActionFuture<DeleteResponse> delete(DeleteRequest request) {
|
||||
return client.delete(request);
|
||||
}
|
||||
|
||||
public void delete(DeleteRequest request, ActionListener<DeleteResponse> listener) {
|
||||
client.delete(request, listener);
|
||||
}
|
||||
|
||||
public DeleteRequestBuilder prepareDelete() {
|
||||
return client.prepareDelete();
|
||||
}
|
||||
|
||||
public DeleteRequestBuilder prepareDelete(String index, String type, String id) {
|
||||
return client.prepareDelete(index, type, id);
|
||||
}
|
||||
|
||||
public ActionFuture<BulkResponse> bulk(BulkRequest request) {
|
||||
return client.bulk(request);
|
||||
}
|
||||
|
||||
public void bulk(BulkRequest request, ActionListener<BulkResponse> listener) {
|
||||
client.bulk(request, listener);
|
||||
}
|
||||
|
||||
public BulkRequestBuilder prepareBulk() {
|
||||
return client.prepareBulk();
|
||||
}
|
||||
|
||||
public ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request) {
|
||||
return client.deleteByQuery(request);
|
||||
}
|
||||
|
||||
public void deleteByQuery(DeleteByQueryRequest request, ActionListener<DeleteByQueryResponse> listener) {
|
||||
client.deleteByQuery(request, listener);
|
||||
}
|
||||
|
||||
public DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
|
||||
return client.prepareDeleteByQuery(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<GetResponse> get(GetRequest request) {
|
||||
return client.get(request);
|
||||
}
|
||||
|
||||
public void get(GetRequest request, ActionListener<GetResponse> listener) {
|
||||
client.get(request, listener);
|
||||
}
|
||||
|
||||
public GetRequestBuilder prepareGet() {
|
||||
return client.prepareGet();
|
||||
}
|
||||
|
||||
public GetRequestBuilder prepareGet(String index, String type, String id) {
|
||||
return client.prepareGet(index, type, id);
|
||||
}
|
||||
|
||||
public PutIndexedScriptRequestBuilder preparePutIndexedScript() {
|
||||
return client.preparePutIndexedScript();
|
||||
}
|
||||
|
||||
public PutIndexedScriptRequestBuilder preparePutIndexedScript(String scriptLang, String id, String source) {
|
||||
return client.preparePutIndexedScript(scriptLang, id, source);
|
||||
}
|
||||
|
||||
public void deleteIndexedScript(DeleteIndexedScriptRequest request, ActionListener<DeleteIndexedScriptResponse> listener) {
|
||||
client.deleteIndexedScript(request, listener);
|
||||
}
|
||||
|
||||
public ActionFuture<DeleteIndexedScriptResponse> deleteIndexedScript(DeleteIndexedScriptRequest request) {
|
||||
return client.deleteIndexedScript(request);
|
||||
}
|
||||
|
||||
public DeleteIndexedScriptRequestBuilder prepareDeleteIndexedScript() {
|
||||
return client.prepareDeleteIndexedScript();
|
||||
}
|
||||
|
||||
public DeleteIndexedScriptRequestBuilder prepareDeleteIndexedScript(String scriptLang, String id) {
|
||||
return client.prepareDeleteIndexedScript(scriptLang, id);
|
||||
}
|
||||
|
||||
public void putIndexedScript(PutIndexedScriptRequest request, ActionListener<PutIndexedScriptResponse> listener) {
|
||||
client.putIndexedScript(request, listener);
|
||||
}
|
||||
|
||||
public ActionFuture<PutIndexedScriptResponse> putIndexedScript(PutIndexedScriptRequest request) {
|
||||
return client.putIndexedScript(request);
|
||||
}
|
||||
|
||||
public GetIndexedScriptRequestBuilder prepareGetIndexedScript() {
|
||||
return client.prepareGetIndexedScript();
|
||||
}
|
||||
|
||||
public GetIndexedScriptRequestBuilder prepareGetIndexedScript(String scriptLang, String id) {
|
||||
return client.prepareGetIndexedScript(scriptLang, id);
|
||||
}
|
||||
|
||||
public void getIndexedScript(GetIndexedScriptRequest request, ActionListener<GetIndexedScriptResponse> listener) {
|
||||
client.getIndexedScript(request, listener);
|
||||
}
|
||||
|
||||
public ActionFuture<GetIndexedScriptResponse> getIndexedScript(GetIndexedScriptRequest request) {
|
||||
return client.getIndexedScript(request);
|
||||
}
|
||||
|
||||
public ActionFuture<MultiGetResponse> multiGet(MultiGetRequest request) {
|
||||
return client.multiGet(request);
|
||||
}
|
||||
|
||||
public void multiGet(MultiGetRequest request, ActionListener<MultiGetResponse> listener) {
|
||||
client.multiGet(request, listener);
|
||||
}
|
||||
|
||||
public MultiGetRequestBuilder prepareMultiGet() {
|
||||
return client.prepareMultiGet();
|
||||
}
|
||||
|
||||
public ActionFuture<CountResponse> count(CountRequest request) {
|
||||
return client.count(request);
|
||||
}
|
||||
|
||||
public void count(CountRequest request, ActionListener<CountResponse> listener) {
|
||||
client.count(request, listener);
|
||||
}
|
||||
|
||||
public CountRequestBuilder prepareCount(String... indices) {
|
||||
return client.prepareCount(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<ExistsResponse> exists(ExistsRequest request) {
|
||||
return client.exists(request);
|
||||
}
|
||||
|
||||
public void exists(ExistsRequest request, ActionListener<ExistsResponse> listener) {
|
||||
client.exists(request, listener);
|
||||
}
|
||||
|
||||
public ExistsRequestBuilder prepareExists(String... indices) {
|
||||
return client.prepareExists(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<SuggestResponse> suggest(SuggestRequest request) {
|
||||
return client.suggest(request);
|
||||
}
|
||||
|
||||
public void suggest(SuggestRequest request, ActionListener<SuggestResponse> listener) {
|
||||
client.suggest(request, listener);
|
||||
}
|
||||
|
||||
public SuggestRequestBuilder prepareSuggest(String... indices) {
|
||||
return client.prepareSuggest(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<SearchResponse> search(SearchRequest request) {
|
||||
return client.search(request);
|
||||
}
|
||||
|
||||
public void search(SearchRequest request, ActionListener<SearchResponse> listener) {
|
||||
client.search(request, listener);
|
||||
}
|
||||
|
||||
public SearchRequestBuilder prepareSearch(String... indices) {
|
||||
return client.prepareSearch(indices);
|
||||
}
|
||||
|
||||
public ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request) {
|
||||
return client.searchScroll(request);
|
||||
}
|
||||
|
||||
public void searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener) {
|
||||
client.searchScroll(request, listener);
|
||||
}
|
||||
|
||||
public SearchScrollRequestBuilder prepareSearchScroll(String scrollId) {
|
||||
return client.prepareSearchScroll(scrollId);
|
||||
}
|
||||
|
||||
public ActionFuture<MultiSearchResponse> multiSearch(MultiSearchRequest request) {
|
||||
return client.multiSearch(request);
|
||||
}
|
||||
|
||||
public void multiSearch(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener) {
|
||||
client.multiSearch(request, listener);
|
||||
}
|
||||
|
||||
public MultiSearchRequestBuilder prepareMultiSearch() {
|
||||
return client.prepareMultiSearch();
|
||||
}
|
||||
|
||||
public ActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request) {
|
||||
return client.moreLikeThis(request);
|
||||
}
|
||||
|
||||
public void moreLikeThis(MoreLikeThisRequest request, ActionListener<SearchResponse> listener) {
|
||||
client.moreLikeThis(request, listener);
|
||||
}
|
||||
|
||||
public MoreLikeThisRequestBuilder prepareMoreLikeThis(String index, String type, String id) {
|
||||
return client.prepareMoreLikeThis(index, type, id);
|
||||
}
|
||||
|
||||
public ActionFuture<TermVectorResponse> termVector(TermVectorRequest request) {
|
||||
return client.termVector(request);
|
||||
}
|
||||
|
||||
public void termVector(TermVectorRequest request, ActionListener<TermVectorResponse> listener) {
|
||||
client.termVector(request, listener);
|
||||
}
|
||||
|
||||
public TermVectorRequestBuilder prepareTermVector() {
|
||||
return client.prepareTermVector();
|
||||
}
|
||||
|
||||
public TermVectorRequestBuilder prepareTermVector(String index, String type, String id) {
|
||||
return client.prepareTermVector(index, type, id);
|
||||
}
|
||||
|
||||
public ActionFuture<MultiTermVectorsResponse> multiTermVectors(MultiTermVectorsRequest request) {
|
||||
return client.multiTermVectors(request);
|
||||
}
|
||||
|
||||
public void multiTermVectors(MultiTermVectorsRequest request, ActionListener<MultiTermVectorsResponse> listener) {
|
||||
client.multiTermVectors(request, listener);
|
||||
}
|
||||
|
||||
public MultiTermVectorsRequestBuilder prepareMultiTermVectors() {
|
||||
return client.prepareMultiTermVectors();
|
||||
}
|
||||
|
||||
public ActionFuture<PercolateResponse> percolate(PercolateRequest request) {
|
||||
return client.percolate(request);
|
||||
}
|
||||
|
||||
public void percolate(PercolateRequest request, ActionListener<PercolateResponse> listener) {
|
||||
client.percolate(request, listener);
|
||||
}
|
||||
|
||||
public PercolateRequestBuilder preparePercolate() {
|
||||
return client.preparePercolate();
|
||||
}
|
||||
|
||||
public ActionFuture<MultiPercolateResponse> multiPercolate(MultiPercolateRequest request) {
|
||||
return client.multiPercolate(request);
|
||||
}
|
||||
|
||||
public void multiPercolate(MultiPercolateRequest request, ActionListener<MultiPercolateResponse> listener) {
|
||||
client.multiPercolate(request, listener);
|
||||
}
|
||||
|
||||
public MultiPercolateRequestBuilder prepareMultiPercolate() {
|
||||
return client.prepareMultiPercolate();
|
||||
}
|
||||
|
||||
public ExplainRequestBuilder prepareExplain(String index, String type, String id) {
|
||||
return client.prepareExplain(index, type, id);
|
||||
}
|
||||
|
||||
public ActionFuture<ExplainResponse> explain(ExplainRequest request) {
|
||||
return client.explain(request);
|
||||
}
|
||||
|
||||
public void explain(ExplainRequest request, ActionListener<ExplainResponse> listener) {
|
||||
client.explain(request, listener);
|
||||
}
|
||||
|
||||
public ClearScrollRequestBuilder prepareClearScroll() {
|
||||
return client.prepareClearScroll();
|
||||
}
|
||||
|
||||
public ActionFuture<ClearScrollResponse> clearScroll(ClearScrollRequest request) {
|
||||
return client.clearScroll(request);
|
||||
}
|
||||
|
||||
public void clearScroll(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener) {
|
||||
client.clearScroll(request, listener);
|
||||
}
|
||||
|
||||
public FieldStatsRequestBuilder prepareFieldStats() {
|
||||
return client.prepareFieldStats();
|
||||
}
|
||||
|
||||
public ActionFuture<FieldStatsResponse> fieldStats(FieldStatsRequest request) {
|
||||
return client.fieldStats(request);
|
||||
}
|
||||
|
||||
public void fieldStats(FieldStatsRequest request, ActionListener<FieldStatsResponse> listener) {
|
||||
client.fieldStats(request, listener);
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return client.settings();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -362,9 +362,9 @@ public class Crawler implements Serializable {
|
|||
writeTimeToSessionInfo(crawlingSessionHelper, Constants.CRAWLER_START_TIME);
|
||||
|
||||
// setup path mapping
|
||||
final List<CDef.ProcessType> ptList = new ArrayList<CDef.ProcessType>();
|
||||
ptList.add(CDef.ProcessType.Crawling);
|
||||
ptList.add(CDef.ProcessType.Both);
|
||||
final List<String> ptList = new ArrayList<>();
|
||||
ptList.add(Constants.PROCESS_TYPE_CRAWLING);
|
||||
ptList.add(Constants.PROCESS_TYPE_BOTH);
|
||||
pathMappingHelper.setPathMappingList(options.sessionId, pathMappingService.getPathMappingList(ptList));
|
||||
|
||||
// overlapping host
|
||||
|
|
|
@ -23,9 +23,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.codelibs.fess.db.allcommon.CDef;
|
||||
import org.codelibs.fess.db.exbhv.PathMappingBhv;
|
||||
import org.codelibs.fess.db.exentity.PathMapping;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.es.exbhv.PathMappingBhv;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.seasar.framework.container.SingletonS2Container;
|
||||
import org.seasar.framework.container.annotation.tiger.InitMethod;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -43,16 +43,15 @@ public class PathMappingHelper implements Serializable {
|
|||
|
||||
@InitMethod
|
||||
public void init() {
|
||||
final List<CDef.ProcessType> ptList = new ArrayList<CDef.ProcessType>();
|
||||
ptList.add(CDef.ProcessType.Displaying);
|
||||
ptList.add(CDef.ProcessType.Both);
|
||||
final List<String> ptList = new ArrayList<>();
|
||||
ptList.add(Constants.PROCESS_TYPE_DISPLAYING);
|
||||
ptList.add(Constants.PROCESS_TYPE_BOTH);
|
||||
|
||||
try {
|
||||
final PathMappingBhv pathMappingBhv = SingletonS2Container.getComponent(PathMappingBhv.class);
|
||||
cachedPathMappingList = pathMappingBhv.selectList(cb -> {
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().setProcessType_InScope_AsProcessType(ptList);
|
||||
cb.query().setProcessType_InScope(ptList);
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to load path mappings.", e);
|
||||
|
|
|
@ -25,10 +25,9 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.db.allcommon.CDef;
|
||||
import org.codelibs.fess.db.cbean.PathMappingCB;
|
||||
import org.codelibs.fess.db.exbhv.PathMappingBhv;
|
||||
import org.codelibs.fess.db.exentity.PathMapping;
|
||||
import org.codelibs.fess.es.cbean.PathMappingCB;
|
||||
import org.codelibs.fess.es.exbhv.PathMappingBhv;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.codelibs.fess.pager.PathMappingPager;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
|
@ -40,10 +39,6 @@ public class PathMappingService implements Serializable {
|
|||
@Resource
|
||||
protected PathMappingBhv pathMappingBhv;
|
||||
|
||||
public PathMappingService() {
|
||||
super();
|
||||
}
|
||||
|
||||
public List<PathMapping> getPathMappingList(final PathMappingPager pathMappingPager) {
|
||||
|
||||
final PagingResultBean<PathMapping> pathMappingList = pathMappingBhv.selectPage(cb -> {
|
||||
|
@ -62,7 +57,8 @@ public class PathMappingService implements Serializable {
|
|||
|
||||
public PathMapping getPathMapping(final Map<String, String> keys) {
|
||||
final PathMapping pathMapping = pathMappingBhv.selectEntity(cb -> {
|
||||
cb.query().setId_Equal(Long.parseLong(keys.get("id")));
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
cb.request().setVersion(true);
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (pathMapping == null) {
|
||||
|
@ -76,34 +72,36 @@ public class PathMappingService implements Serializable {
|
|||
public void store(final PathMapping pathMapping) throws CrudMessageException {
|
||||
setupStoreCondition(pathMapping);
|
||||
|
||||
pathMappingBhv.insertOrUpdate(pathMapping);
|
||||
pathMappingBhv.insertOrUpdate(pathMapping, op -> {
|
||||
op.setRefresh(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void delete(final PathMapping pathMapping) throws CrudMessageException {
|
||||
setupDeleteCondition(pathMapping);
|
||||
|
||||
pathMappingBhv.delete(pathMapping);
|
||||
pathMappingBhv.delete(pathMapping, op -> {
|
||||
op.setRefresh(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public List<PathMapping> getPathMappingList(final Collection<CDef.ProcessType> cdefList) {
|
||||
public List<PathMapping> getPathMappingList(final Collection<String> processTypeList) {
|
||||
|
||||
return pathMappingBhv.selectList(cb -> {
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
cb.query().setProcessType_InScope_AsProcessType(cdefList);
|
||||
cb.query().setProcessType_InScope(processTypeList);
|
||||
});
|
||||
}
|
||||
|
||||
protected void setupListCondition(final PathMappingCB cb, final PathMappingPager pathMappingPager) {
|
||||
if (pathMappingPager.id != null) {
|
||||
cb.query().setId_Equal(Long.parseLong(pathMappingPager.id));
|
||||
cb.query().docMeta().setId_Equal(pathMappingPager.id);
|
||||
}
|
||||
// TODO Long, Integer, String supported only.
|
||||
|
||||
// setup condition
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
cb.query().addOrderBy_SortOrder_Asc();
|
||||
|
||||
// search
|
||||
|
@ -113,7 +111,6 @@ public class PathMappingService implements Serializable {
|
|||
protected void setupEntityCondition(final PathMappingCB cb, final Map<String, String> keys) {
|
||||
|
||||
// setup condition
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.codelibs.fess.web.admin;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -27,7 +26,7 @@ import org.codelibs.fess.beans.FessBeans;
|
|||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.PathMapping;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.codelibs.fess.helper.PathMappingHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.PathMappingPager;
|
||||
|
@ -285,7 +284,7 @@ public class PathMappingAction extends FessAdminAction {
|
|||
protected PathMapping createPathMapping() {
|
||||
PathMapping pathMapping;
|
||||
final String username = systemHelper.getUsername();
|
||||
final LocalDateTime currentTime = systemHelper.getCurrentTime();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (pathMappingForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
pathMapping = pathMappingService.getPathMapping(createKeyMap());
|
||||
if (pathMapping == null) {
|
||||
|
@ -318,12 +317,7 @@ public class PathMappingAction extends FessAdminAction {
|
|||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { pathMappingForm.id });
|
||||
}
|
||||
|
||||
// pathMappingService.delete(pathMapping);
|
||||
final String username = systemHelper.getUsername();
|
||||
final LocalDateTime currentTime = systemHelper.getCurrentTime();
|
||||
pathMapping.setDeletedBy(username);
|
||||
pathMapping.setDeletedTime(currentTime);
|
||||
pathMappingService.store(pathMapping);
|
||||
pathMappingService.delete(pathMapping);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
package org.codelibs.fess.web.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.seasar.struts.annotation.DateType;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.seasar.struts.annotation.IntRange;
|
||||
import org.seasar.struts.annotation.IntegerType;
|
||||
import org.seasar.struts.annotation.LongType;
|
||||
|
@ -47,7 +44,7 @@ public class PathMappingForm implements Serializable {
|
|||
}
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@LongType
|
||||
@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
|
@ -70,23 +67,17 @@ public class PathMappingForm implements Serializable {
|
|||
public String createdBy;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
@LongType
|
||||
public String createdTime;
|
||||
|
||||
@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
@LongType
|
||||
public String updatedTime;
|
||||
|
||||
@Maxbytelength(maxbytelength = 255)
|
||||
public String deletedBy;
|
||||
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
public String deletedTime;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@IntegerType
|
||||
@LongType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
|
@ -99,13 +90,10 @@ public class PathMappingForm implements Serializable {
|
|||
createdTime = null;
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
deletedBy = null;
|
||||
deletedTime = null;
|
||||
versionNo = null;
|
||||
sortOrder = "0";
|
||||
// Temporary data
|
||||
createdBy = "system";
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT);
|
||||
createdTime = sdf.format(new Date());
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.codelibs.fess.helper;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.codelibs.fess.db.exentity.PathMapping;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class PathMappingHelperTest extends S2TestCase {
|
||||
|
|
Loading…
Add table
Reference in a new issue