merge
This commit is contained in:
commit
9ea9caf1f1
60 changed files with 2999 additions and 146 deletions
|
@ -28,6 +28,9 @@ public class Constants extends CoreLibConstants {
|
|||
public static final String FESS_VERSION = String.valueOf(MAJOR_VERSION)
|
||||
+ "." + String.valueOf(MINOR_VERSION);
|
||||
|
||||
public static final String LINE_SEPARATOR = System
|
||||
.getProperty("line.separator");
|
||||
|
||||
public static final int DEFAULT_ADMIN_PAGE_SIZE = 25;
|
||||
|
||||
public static final String WEB_API_VERSION = "4";
|
||||
|
@ -36,6 +39,8 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final String EMPTY_STRING = "";
|
||||
|
||||
public static final String[] EMPTY_STRINGS = new String[0];
|
||||
|
||||
public static final String TRUE = "true";
|
||||
|
||||
public static final String FALSE = "false";
|
||||
|
@ -320,4 +325,6 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final String DOC_ID = "docId";
|
||||
|
||||
public static final String DCF = "dcf";
|
||||
|
||||
}
|
||||
|
|
|
@ -53,12 +53,14 @@ import jp.sf.fess.entity.SuggestResponse;
|
|||
import jp.sf.fess.form.IndexForm;
|
||||
import jp.sf.fess.helper.BrowserTypeHelper;
|
||||
import jp.sf.fess.helper.CrawlingConfigHelper;
|
||||
import jp.sf.fess.helper.DocumentHelper;
|
||||
import jp.sf.fess.helper.HotSearchWordHelper;
|
||||
import jp.sf.fess.helper.HotSearchWordHelper.Range;
|
||||
import jp.sf.fess.helper.LabelTypeHelper;
|
||||
import jp.sf.fess.helper.OpenSearchHelper;
|
||||
import jp.sf.fess.helper.QueryHelper;
|
||||
import jp.sf.fess.helper.SearchLogHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.helper.UserInfoHelper;
|
||||
import jp.sf.fess.helper.ViewHelper;
|
||||
import jp.sf.fess.screenshot.ScreenShotManager;
|
||||
|
@ -144,6 +146,9 @@ public class IndexAction {
|
|||
@Resource
|
||||
protected OpenSearchHelper openSearchHelper;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected Suggester suggester;
|
||||
|
||||
|
@ -590,7 +595,8 @@ public class IndexAction {
|
|||
|
||||
try {
|
||||
final Map<String, Object> doc = indexForm.docId == null ? null
|
||||
: searchService.getDocument("docId:" + indexForm.docId);
|
||||
: searchService.getDocument("docId:" + indexForm.docId,
|
||||
new String[] { systemHelper.favoriteCountField });
|
||||
final String userCode = userInfoHelper.getUserCode();
|
||||
final String favoriteUrl = doc == null ? null : (String) doc
|
||||
.get("url");
|
||||
|
@ -626,6 +632,19 @@ public class IndexAction {
|
|||
WebApiUtil.setError(4, "Failed to add url: " + favoriteUrl);
|
||||
return null;
|
||||
}
|
||||
|
||||
final DocumentHelper documentHelper = SingletonS2Container
|
||||
.getComponent("documentHelper");
|
||||
final Object count = doc.get(systemHelper.favoriteCountField);
|
||||
if (count instanceof Long) {
|
||||
documentHelper.update(indexForm.docId,
|
||||
systemHelper.favoriteCountField,
|
||||
((Long) count).longValue() + 1);
|
||||
} else {
|
||||
WebApiUtil
|
||||
.setError(7, "Failed to update count: " + favoriteUrl);
|
||||
return null;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
WebApiUtil.setError(1, e);
|
||||
}
|
||||
|
@ -655,7 +674,9 @@ public class IndexAction {
|
|||
final String[] docIds = userInfoHelper
|
||||
.getResultDocIds(indexForm.queryId);
|
||||
final List<Map<String, Object>> docList = searchService
|
||||
.getDocumentListByDocIds(docIds, MAX_PAGE_SIZE);
|
||||
.getDocumentListByDocIds(docIds,
|
||||
new String[] { systemHelper.favoriteCountField },
|
||||
MAX_PAGE_SIZE);
|
||||
List<String> urlList = new ArrayList<String>(docList.size());
|
||||
for (final Map<String, Object> doc : docList) {
|
||||
final Object urlObj = doc.get("url");
|
||||
|
@ -775,7 +796,8 @@ public class IndexAction {
|
|||
final int pageNum = Integer.parseInt(indexForm.num);
|
||||
try {
|
||||
documentItems = searchService.getDocumentList(query, pageStart,
|
||||
pageNum, indexForm.facet, indexForm.geo, indexForm.mlt);
|
||||
pageNum, indexForm.facet, indexForm.geo, indexForm.mlt,
|
||||
queryHelper.getResponseDocValuesFields());
|
||||
} catch (final SolrLibQueryException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(e.getMessage(), e);
|
||||
|
|
|
@ -32,6 +32,7 @@ import jp.sf.fess.db.allcommon.CDef;
|
|||
import jp.sf.fess.db.exentity.SearchLog;
|
||||
import jp.sf.fess.db.exentity.UserInfo;
|
||||
import jp.sf.fess.form.MobileForm;
|
||||
import jp.sf.fess.helper.QueryHelper;
|
||||
import jp.sf.fess.helper.SearchLogHelper;
|
||||
import jp.sf.fess.helper.UserInfoHelper;
|
||||
import jp.sf.fess.service.SearchService;
|
||||
|
@ -69,6 +70,9 @@ public class MobileAction {
|
|||
@Resource
|
||||
protected UserInfoHelper userInfoHelper;
|
||||
|
||||
@Resource
|
||||
protected QueryHelper queryHelper;
|
||||
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
|
@ -145,7 +149,8 @@ public class MobileAction {
|
|||
// TODO add GeoInfo if needed...
|
||||
try {
|
||||
documentItems = searchService.getDocumentList(mobileForm.query,
|
||||
pageStart, pageNum, null, null, null);
|
||||
pageStart, pageNum, null, null, null,
|
||||
queryHelper.getResponseDocValuesFields());
|
||||
} catch (final InvalidQueryException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(e.getMessage(), e);
|
||||
|
|
59
src/main/java/jp/sf/fess/action/admin/DictAction.java
Normal file
59
src/main/java/jp/sf/fess/action/admin/DictAction.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import jp.sf.fess.dict.DictionaryFile;
|
||||
import jp.sf.fess.dict.DictionaryManager;
|
||||
import jp.sf.fess.form.admin.DictForm;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.seasar.struts.annotation.ActionForm;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
|
||||
public class DictAction implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(DictAction.class);
|
||||
|
||||
@Resource
|
||||
@ActionForm
|
||||
protected DictForm dictForm;
|
||||
|
||||
@Resource
|
||||
protected DictionaryManager dictionaryManager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
public DictionaryFile[] dictFiles;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("dict");
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
dictFiles = dictionaryManager.getDictionaryFiles();
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
|
@ -178,7 +178,7 @@ public class DocumentAction implements Serializable {
|
|||
final long execTime = System.currentTimeMillis();
|
||||
try {
|
||||
systemHelper.updateStatus(solrGroup, QueryType.ADD);
|
||||
solrGroup.commit();
|
||||
solrGroup.commit(true, true, false, true);
|
||||
systemHelper.updateStatus(solrGroup,
|
||||
QueryType.COMMIT);
|
||||
|
||||
|
@ -297,7 +297,7 @@ public class DocumentAction implements Serializable {
|
|||
systemHelper.updateStatus(solrGroup,
|
||||
QueryType.DELETE);
|
||||
solrGroup.deleteByQuery(deleteQuery);
|
||||
solrGroup.commit();
|
||||
solrGroup.commit(true, true, false, true);
|
||||
systemHelper.updateStatus(solrGroup,
|
||||
QueryType.OPTIMIZE);
|
||||
if (logger.isInfoEnabled()) {
|
||||
|
|
|
@ -155,7 +155,9 @@ public class SearchListAction implements Serializable {
|
|||
final int size = Integer.parseInt(searchListForm.num);
|
||||
try {
|
||||
documentItems = searchService.getDocumentList(query, offset, size,
|
||||
null, null, null, false);
|
||||
null, null, null, new String[] {
|
||||
systemHelper.clickCountField,
|
||||
systemHelper.favoriteCountField }, false);
|
||||
} catch (final InvalidQueryException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(e.getMessage(), e);
|
||||
|
|
|
@ -74,6 +74,8 @@ public class SystemAction implements Serializable {
|
|||
@Resource
|
||||
protected JobHelper jobHelper;
|
||||
|
||||
private boolean executed = false;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("system");
|
||||
}
|
||||
|
@ -227,6 +229,7 @@ public class SystemAction implements Serializable {
|
|||
scheduledJob.start();
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.start_crawl_process");
|
||||
executed = true;
|
||||
} else {
|
||||
SAStrutsUtil
|
||||
.addSessionMessage("success.failed_to_start_crawl_process");
|
||||
|
@ -316,7 +319,7 @@ public class SystemAction implements Serializable {
|
|||
}
|
||||
|
||||
public boolean isCrawlerRunning() {
|
||||
return jobHelper.isCrawlProcessRunning();
|
||||
return executed || jobHelper.isCrawlProcessRunning();
|
||||
}
|
||||
|
||||
public String[] getRunningSessionIds() {
|
||||
|
|
361
src/main/java/jp/sf/fess/action/admin/dict/SynonymAction.java
Normal file
361
src/main/java/jp/sf/fess/action/admin/dict/SynonymAction.java
Normal file
|
@ -0,0 +1,361 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.action.admin.dict;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.crud.CommonConstants;
|
||||
import jp.sf.fess.crud.CrudMessageException;
|
||||
import jp.sf.fess.crud.util.SAStrutsUtil;
|
||||
import jp.sf.fess.dict.synonym.SynonymItem;
|
||||
import jp.sf.fess.form.admin.dict.SynonymForm;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.pager.SynonymPager;
|
||||
import jp.sf.fess.service.SynonymService;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
import org.seasar.struts.annotation.ActionForm;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
|
||||
public class SynonymAction {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SynonymAction.class);
|
||||
|
||||
@Resource
|
||||
@ActionForm
|
||||
protected SynonymForm synonymForm;
|
||||
|
||||
@Resource
|
||||
protected SynonymService synonymService;
|
||||
|
||||
@Resource
|
||||
protected SynonymPager synonymPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
public List<SynonymItem> synonymItemItems;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("dict");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
synonymItemItems = synonymService.getSynonymList(synonymForm.dictId,
|
||||
synonymPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(synonymPager, synonymForm.searchParams)
|
||||
.excludes(CommonConstants.PAGER_CONVERSION_RULE).execute();
|
||||
|
||||
if (redirect) {
|
||||
return "index?dictId=" + synonymForm.dictId + "&redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "list/{dictId}/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(synonymForm.pageNumber)) {
|
||||
try {
|
||||
synonymPager.setCurrentPageNumber(Integer
|
||||
.parseInt(synonymForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + synonymForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(synonymForm.searchParams, synonymPager)
|
||||
.excludes(CommonConstants.PAGER_CONVERSION_RULE).execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
synonymPager.clear();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String back() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editagain() {
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{dictId}/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (synonymForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
synonymForm.initialize();
|
||||
synonymForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{dictId}/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (synonymForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.EDIT_MODE,
|
||||
synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
synonymForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{dictId}/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (synonymForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE,
|
||||
synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
synonymForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SynonymItem synonymItem = createSynonym();
|
||||
synonymService.store(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
try {
|
||||
final SynonymItem synonymItem = createSynonym();
|
||||
synonymService.store(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (synonymForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE,
|
||||
synonymForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SynonymItem synonymItem = synonymService.getSynonym(
|
||||
synonymForm.dictId, createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
|
||||
synonymService.delete(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadSynonym() {
|
||||
|
||||
final SynonymItem synonymItem = synonymService.getSynonym(
|
||||
synonymForm.dictId, createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_could_not_find_crud_table",
|
||||
new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
|
||||
synonymForm.id = Long.toString(synonymItem.getId());
|
||||
synonymForm.inputs = StringUtils.join(synonymItem.getInputs(), "\n");
|
||||
synonymForm.outputs = StringUtils.join(synonymItem.getOutputs(), "\n");
|
||||
}
|
||||
|
||||
protected SynonymItem createSynonym() {
|
||||
SynonymItem synonymItem;
|
||||
if (synonymForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
synonymItem = synonymService.getSynonym(synonymForm.dictId,
|
||||
createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException(
|
||||
"errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
synonymItem = new SynonymItem(0, Constants.EMPTY_STRINGS,
|
||||
Constants.EMPTY_STRINGS);
|
||||
}
|
||||
|
||||
final String[] newInputs = splitLine(synonymForm.inputs);
|
||||
synonymItem.setNewInputs(newInputs);
|
||||
final String[] newOutputs = splitLine(synonymForm.outputs);
|
||||
synonymItem.setNewOutputs(newOutputs);
|
||||
|
||||
return synonymItem;
|
||||
}
|
||||
|
||||
private String[] splitLine(final String value) {
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return Constants.EMPTY_STRINGS;
|
||||
}
|
||||
final String[] values = value.split("[\r\n]");
|
||||
final List<String> list = new ArrayList<String>(values.length);
|
||||
for (final String line : values) {
|
||||
if (StringUtil.isNotBlank(line)) {
|
||||
list.add(line.trim());
|
||||
}
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", synonymForm.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
}
|
17
src/main/java/jp/sf/fess/dict/DictionaryException.java
Normal file
17
src/main/java/jp/sf/fess/dict/DictionaryException.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package jp.sf.fess.dict;
|
||||
|
||||
import jp.sf.fess.FessSystemException;
|
||||
|
||||
public class DictionaryException extends FessSystemException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DictionaryException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DictionaryException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
217
src/main/java/jp/sf/fess/dict/DictionaryFile.java
Normal file
217
src/main/java/jp/sf/fess/dict/DictionaryFile.java
Normal file
|
@ -0,0 +1,217 @@
|
|||
package jp.sf.fess.dict;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public abstract class DictionaryFile<T extends DictionaryItem> {
|
||||
protected String id;
|
||||
|
||||
public abstract String getType();
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract PagingList<T> selectList(int offset, int size);
|
||||
|
||||
public abstract T get(long id);
|
||||
|
||||
public abstract void insert(T item);
|
||||
|
||||
public abstract void update(T item);
|
||||
|
||||
public abstract void delete(T item);
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static class PagingList<E> implements List<E> {
|
||||
private final List<E> parent;
|
||||
|
||||
protected int allPageCount;
|
||||
|
||||
protected int allRecordCount;
|
||||
|
||||
protected int pageSize;
|
||||
|
||||
protected int currentPageNumber;
|
||||
|
||||
protected int pageRangeSize;
|
||||
|
||||
public PagingList(final List<E> list, final int offset, final int size,
|
||||
final int allRecordCount) {
|
||||
this.parent = list;
|
||||
this.allRecordCount = allRecordCount;
|
||||
pageSize = size;
|
||||
currentPageNumber = offset / size + 1;
|
||||
allPageCount = (allRecordCount - 1) / size + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return parent.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(final Object o) {
|
||||
return parent.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return parent.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return parent.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(final T[] a) {
|
||||
return parent.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(final E e) {
|
||||
return parent.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(final Object o) {
|
||||
return parent.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(final Collection<?> c) {
|
||||
return parent.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final Collection<? extends E> c) {
|
||||
return parent.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final int index, final Collection<? extends E> c) {
|
||||
return parent.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(final Collection<?> c) {
|
||||
return parent.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(final Collection<?> c) {
|
||||
return parent.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(final int index) {
|
||||
return parent.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(final int index, final E element) {
|
||||
return parent.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final int index, final E element) {
|
||||
parent.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(final int index) {
|
||||
return parent.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(final Object o) {
|
||||
return parent.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(final Object o) {
|
||||
return parent.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return parent.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(final int index) {
|
||||
return parent.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(final int fromIndex, final int toIndex) {
|
||||
return parent.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
public int getAllRecordCount() {
|
||||
return allRecordCount;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public int getCurrentPageNumber() {
|
||||
return currentPageNumber;
|
||||
}
|
||||
|
||||
public int getAllPageCount() {
|
||||
return allPageCount;
|
||||
}
|
||||
|
||||
public boolean isExistPrePage() {
|
||||
return currentPageNumber != 1;
|
||||
}
|
||||
|
||||
public boolean isExistNextPage() {
|
||||
return currentPageNumber != allPageCount;
|
||||
}
|
||||
|
||||
public void setPageRangeSize(final int pageRangeSize) {
|
||||
this.pageRangeSize = pageRangeSize;
|
||||
}
|
||||
|
||||
public List<Integer> createPageNumberList() {
|
||||
int startPage = currentPageNumber - pageRangeSize;
|
||||
if (startPage < 1) {
|
||||
startPage = 1;
|
||||
}
|
||||
int endPage = currentPageNumber + pageRangeSize;
|
||||
if (endPage > allPageCount) {
|
||||
endPage = allPageCount;
|
||||
}
|
||||
final List<Integer> pageNumberList = new ArrayList<Integer>();
|
||||
for (int i = startPage; i <= endPage; i++) {
|
||||
pageNumberList.add(i);
|
||||
}
|
||||
return pageNumberList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
5
src/main/java/jp/sf/fess/dict/DictionaryItem.java
Normal file
5
src/main/java/jp/sf/fess/dict/DictionaryItem.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package jp.sf.fess.dict;
|
||||
|
||||
public abstract class DictionaryItem {
|
||||
|
||||
}
|
40
src/main/java/jp/sf/fess/dict/DictionaryLocator.java
Normal file
40
src/main/java/jp/sf/fess/dict/DictionaryLocator.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package jp.sf.fess.dict;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import jp.sf.fess.util.ResourceUtil;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.AbstractFileFilter;
|
||||
|
||||
public abstract class DictionaryLocator {
|
||||
protected List<String> searchPathList = new ArrayList<String>();
|
||||
|
||||
public abstract List<DictionaryFile<? extends DictionaryItem>> find();
|
||||
|
||||
protected File[] findFiles(final String path, final String filenamePrefix,
|
||||
final List<String> excludedSet) {
|
||||
final Collection<File> files = FileUtils.listFiles(new File(path),
|
||||
new AbstractFileFilter() {
|
||||
@Override
|
||||
public boolean accept(final File dir, final String name) {
|
||||
return name.startsWith(filenamePrefix);
|
||||
}
|
||||
}, new AbstractFileFilter() {
|
||||
@Override
|
||||
public boolean accept(final File dir, final String name) {
|
||||
return excludedSet == null
|
||||
|| !excludedSet.contains(name);
|
||||
}
|
||||
});
|
||||
|
||||
return files.toArray(new File[files.size()]);
|
||||
}
|
||||
|
||||
public void addSearchPath(final String path) {
|
||||
searchPathList.add(ResourceUtil.resolve(path));
|
||||
}
|
||||
}
|
110
src/main/java/jp/sf/fess/dict/DictionaryManager.java
Normal file
110
src/main/java/jp/sf/fess/dict/DictionaryManager.java
Normal file
|
@ -0,0 +1,110 @@
|
|||
package jp.sf.fess.dict;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import jp.sf.fess.dict.synonym.SynonymFile;
|
||||
|
||||
import org.seasar.extension.timer.TimeoutManager;
|
||||
import org.seasar.extension.timer.TimeoutTarget;
|
||||
import org.seasar.extension.timer.TimeoutTask;
|
||||
import org.seasar.framework.container.annotation.tiger.DestroyMethod;
|
||||
import org.seasar.framework.container.annotation.tiger.InitMethod;
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DictionaryManager {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(DictionaryManager.class);
|
||||
|
||||
protected Map<String, DictionaryFile<? extends DictionaryItem>> dicFileMap;
|
||||
|
||||
public long keepAlive = 5 * 60 * 1000; // 5min
|
||||
|
||||
public int watcherTimeout = 60; // 1min
|
||||
|
||||
protected volatile long lifetime = 0;
|
||||
|
||||
protected TimeoutTask watcherTargetTask;
|
||||
|
||||
protected List<DictionaryLocator> locatorList = new ArrayList<DictionaryLocator>();
|
||||
|
||||
@InitMethod
|
||||
public void init() {
|
||||
// start
|
||||
final WatcherTarget watcherTarget = new WatcherTarget();
|
||||
watcherTargetTask = TimeoutManager.getInstance().addTimeoutTarget(
|
||||
watcherTarget, watcherTimeout, true);
|
||||
}
|
||||
|
||||
@DestroyMethod
|
||||
public void destroy() {
|
||||
if (watcherTargetTask != null && !watcherTargetTask.isStopped()) {
|
||||
watcherTargetTask.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public DictionaryFile<? extends DictionaryItem>[] getDictionaryFiles() {
|
||||
final Map<String, DictionaryFile<? extends DictionaryItem>> fileMap = getDictionaryFileMap();
|
||||
|
||||
final Collection<DictionaryFile<? extends DictionaryItem>> values = fileMap
|
||||
.values();
|
||||
return values.toArray(new SynonymFile[values.size()]);
|
||||
}
|
||||
|
||||
public DictionaryFile<? extends DictionaryItem> getDictionaryFile(
|
||||
final String id) {
|
||||
if (StringUtil.isBlank(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Map<String, DictionaryFile<? extends DictionaryItem>> fileMap = getDictionaryFileMap();
|
||||
return fileMap.get(id);
|
||||
}
|
||||
|
||||
protected Map<String, DictionaryFile<? extends DictionaryItem>> getDictionaryFileMap() {
|
||||
synchronized (this) {
|
||||
if (lifetime > System.currentTimeMillis() && dicFileMap != null) {
|
||||
lifetime = System.currentTimeMillis() + keepAlive;
|
||||
return dicFileMap;
|
||||
}
|
||||
|
||||
final Map<String, DictionaryFile<? extends DictionaryItem>> newFileMap = new HashMap<String, DictionaryFile<? extends DictionaryItem>>();
|
||||
for (final DictionaryLocator locator : locatorList) {
|
||||
for (final DictionaryFile<? extends DictionaryItem> dictFile : locator
|
||||
.find()) {
|
||||
final String id = UUID.randomUUID().toString();
|
||||
dictFile.setId(id);
|
||||
newFileMap.put(id, dictFile);
|
||||
}
|
||||
}
|
||||
dicFileMap = newFileMap;
|
||||
lifetime = System.currentTimeMillis() + keepAlive;
|
||||
return dicFileMap;
|
||||
}
|
||||
}
|
||||
|
||||
public void addLocator(final DictionaryLocator locator) {
|
||||
locatorList.add(locator);
|
||||
}
|
||||
|
||||
protected class WatcherTarget implements TimeoutTarget {
|
||||
@Override
|
||||
public void expired() {
|
||||
synchronized (DictionaryManager.this) {
|
||||
if (lifetime <= System.currentTimeMillis()
|
||||
&& dicFileMap != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Cleaning synonym files: " + dicFileMap);
|
||||
}
|
||||
dicFileMap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
355
src/main/java/jp/sf/fess/dict/synonym/SynonymFile.java
Normal file
355
src/main/java/jp/sf/fess/dict/synonym/SynonymFile.java
Normal file
|
@ -0,0 +1,355 @@
|
|||
package jp.sf.fess.dict.synonym;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.dict.DictionaryException;
|
||||
import jp.sf.fess.dict.DictionaryFile;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public class SynonymFile extends DictionaryFile<SynonymItem> {
|
||||
private static final String SYNONYM = "synonym";
|
||||
|
||||
private final File file;
|
||||
|
||||
List<SynonymItem> synonymItemList;
|
||||
|
||||
public SynonymFile(final File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return SYNONYM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynonymItem get(final long id) {
|
||||
for (final SynonymItem synonymItem : synonymItemList) {
|
||||
if (id == synonymItem.getId()) {
|
||||
return synonymItem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PagingList<SynonymItem> selectList(final int offset,
|
||||
final int size) {
|
||||
if (synonymItemList == null) {
|
||||
reload(null);
|
||||
}
|
||||
|
||||
if (offset >= synonymItemList.size() || offset < 0) {
|
||||
return new PagingList<SynonymItem>(
|
||||
Collections.<SynonymItem> emptyList(), offset, size,
|
||||
synonymItemList.size());
|
||||
}
|
||||
|
||||
int toIndex = offset + size;
|
||||
if (toIndex > synonymItemList.size()) {
|
||||
toIndex = synonymItemList.size();
|
||||
}
|
||||
|
||||
return new PagingList<SynonymItem>(synonymItemList.subList(offset,
|
||||
toIndex), offset, size, synonymItemList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void insert(final SynonymItem item) {
|
||||
final SynonymItem synonymItem = item;
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
bw = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(file, true), Constants.UTF_8));
|
||||
bw.newLine();
|
||||
bw.write(synonymItem.toLineString());
|
||||
bw.flush();
|
||||
|
||||
long nextId = 1;
|
||||
if (!synonymItemList.isEmpty()) {
|
||||
final SynonymItem lastItem = synonymItemList
|
||||
.get(synonymItemList.size() - 1);
|
||||
nextId = lastItem.getId() + 1;
|
||||
}
|
||||
synonymItemList.add(new SynonymItem(nextId, synonymItem
|
||||
.getNewInputs(), synonymItem.getNewOutputs()));
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + item, e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(bw);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void update(final SynonymItem item) {
|
||||
reload(new SynonymUpdater(file, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void delete(final SynonymItem item) {
|
||||
final SynonymItem synonymItem = item;
|
||||
synonymItem.setNewInputs(new String[0]);
|
||||
synonymItem.setNewOutputs(new String[0]);
|
||||
reload(new SynonymUpdater(file, synonymItem));
|
||||
}
|
||||
|
||||
protected void reload(final SynonymUpdater updater) {
|
||||
final List<SynonymItem> itemList = new ArrayList<SynonymItem>();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(file), Constants.UTF_8));
|
||||
long id = 0;
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.length() == 0 || line.charAt(0) == '#') {
|
||||
if (updater != null) {
|
||||
updater.write(line);
|
||||
}
|
||||
continue; // ignore empty lines and comments
|
||||
}
|
||||
|
||||
String inputs[];
|
||||
String outputs[];
|
||||
|
||||
final List<String> sides = split(line, "=>");
|
||||
if (sides.size() > 1) { // explicit mapping
|
||||
if (sides.size() != 2) {
|
||||
throw new DictionaryException(
|
||||
"more than one explicit mapping specified on the same line");
|
||||
}
|
||||
final List<String> inputStrings = split(sides.get(0), ",");
|
||||
inputs = new String[inputStrings.size()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = unescape(inputStrings.get(i)).trim();
|
||||
}
|
||||
|
||||
final List<String> outputStrings = split(sides.get(1), ",");
|
||||
outputs = new String[outputStrings.size()];
|
||||
for (int i = 0; i < outputs.length; i++) {
|
||||
outputs[i] = unescape(outputStrings.get(i)).trim();
|
||||
}
|
||||
|
||||
if (inputs.length > 0 && outputs.length > 0) {
|
||||
id++;
|
||||
final SynonymItem item = new SynonymItem(id, inputs,
|
||||
outputs);
|
||||
if (updater != null) {
|
||||
final SynonymItem newItem = updater.write(item);
|
||||
if (newItem != null) {
|
||||
itemList.add(newItem);
|
||||
} else {
|
||||
id--;
|
||||
}
|
||||
} else {
|
||||
itemList.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final List<String> inputStrings = split(line, ",");
|
||||
inputs = new String[inputStrings.size()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = unescape(inputStrings.get(i)).trim();
|
||||
}
|
||||
|
||||
if (inputs.length > 0) {
|
||||
id++;
|
||||
final SynonymItem item = new SynonymItem(id, inputs,
|
||||
inputs);
|
||||
if (updater != null) {
|
||||
final SynonymItem newItem = updater.write(item);
|
||||
if (newItem != null) {
|
||||
itemList.add(newItem);
|
||||
} else {
|
||||
id--;
|
||||
}
|
||||
} else {
|
||||
itemList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updater != null) {
|
||||
updater.commit();
|
||||
}
|
||||
synonymItemList = itemList;
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to parse "
|
||||
+ file.getAbsolutePath(), e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader);
|
||||
if (updater != null) {
|
||||
updater.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> split(final String s, final String separator) {
|
||||
final List<String> list = new ArrayList<String>(2);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int pos = 0;
|
||||
final int end = s.length();
|
||||
while (pos < end) {
|
||||
if (s.startsWith(separator, pos)) {
|
||||
if (sb.length() > 0) {
|
||||
list.add(sb.toString());
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
pos += separator.length();
|
||||
continue;
|
||||
}
|
||||
|
||||
char ch = s.charAt(pos++);
|
||||
if (ch == '\\') {
|
||||
sb.append(ch);
|
||||
if (pos >= end) {
|
||||
break; // ERROR, or let it go?
|
||||
}
|
||||
ch = s.charAt(pos++);
|
||||
}
|
||||
|
||||
sb.append(ch);
|
||||
}
|
||||
|
||||
if (sb.length() > 0) {
|
||||
list.add(sb.toString());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private String unescape(final String s) {
|
||||
if (s.indexOf("\\") >= 0) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
final char ch = s.charAt(i);
|
||||
if (ch == '\\' && i < s.length() - 1) {
|
||||
sb.append(s.charAt(++i));
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
protected static class SynonymUpdater {
|
||||
|
||||
protected boolean isCommit = false;
|
||||
|
||||
protected File oldFile;
|
||||
|
||||
protected File newFile;
|
||||
|
||||
protected Writer writer;
|
||||
|
||||
protected SynonymItem item;
|
||||
|
||||
protected SynonymUpdater(final File file, final SynonymItem newItem) {
|
||||
try {
|
||||
newFile = File.createTempFile(SYNONYM, ".txt");
|
||||
writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(newFile), Constants.UTF_8));
|
||||
} catch (final IOException e) {
|
||||
if (newFile != null) {
|
||||
newFile.delete();
|
||||
}
|
||||
throw new DictionaryException(
|
||||
"Failed to write a synonym file.", e);
|
||||
}
|
||||
oldFile = file;
|
||||
item = newItem;
|
||||
}
|
||||
|
||||
public SynonymItem write(final SynonymItem oldItem) {
|
||||
try {
|
||||
if (item.getId() == oldItem.getId() && item.isUpdated()) {
|
||||
if (item.equals(oldItem)) {
|
||||
try {
|
||||
if (!item.isDeleted()) {
|
||||
// update
|
||||
writer.write(item.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return new SynonymItem(item.getId(),
|
||||
item.getNewInputs(),
|
||||
item.getNewOutputs());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
item.setNewInputs(null);
|
||||
item.setNewOutputs(null);
|
||||
}
|
||||
} else {
|
||||
throw new DictionaryException(
|
||||
"Synonym file was updated: old=" + oldItem
|
||||
+ " : new=" + item);
|
||||
}
|
||||
} else {
|
||||
writer.write(oldItem.toLineString());
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
return oldItem;
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + oldItem
|
||||
+ " -> " + item, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(final String line) {
|
||||
try {
|
||||
writer.write(line);
|
||||
writer.write(Constants.LINE_SEPARATOR);
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to write: " + line, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void commit() {
|
||||
isCommit = true;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
writer.flush();
|
||||
} catch (final IOException e) {
|
||||
// ignore
|
||||
}
|
||||
IOUtils.closeQuietly(writer);
|
||||
|
||||
if (isCommit) {
|
||||
try {
|
||||
FileUtils.copyFile(newFile, oldFile);
|
||||
newFile.delete();
|
||||
} catch (final IOException e) {
|
||||
throw new DictionaryException("Failed to replace "
|
||||
+ oldFile.getAbsolutePath() + " with "
|
||||
+ newFile.getAbsolutePath(), e);
|
||||
}
|
||||
} else {
|
||||
newFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
146
src/main/java/jp/sf/fess/dict/synonym/SynonymItem.java
Normal file
146
src/main/java/jp/sf/fess/dict/synonym/SynonymItem.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
package jp.sf.fess.dict.synonym;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import jp.sf.fess.dict.DictionaryItem;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class SynonymItem extends DictionaryItem {
|
||||
private final String[] inputs;
|
||||
|
||||
private final String[] outputs;
|
||||
|
||||
private String[] newInputs;
|
||||
|
||||
private String[] newOutputs;
|
||||
|
||||
private final long id;
|
||||
|
||||
public SynonymItem(final long id, final String[] inputs,
|
||||
final String[] outputs) {
|
||||
this.id = id;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
Arrays.sort(inputs);
|
||||
if (inputs != outputs) {
|
||||
Arrays.sort(outputs);
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
// create
|
||||
newInputs = inputs;
|
||||
newOutputs = outputs;
|
||||
}
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String[] getNewInputs() {
|
||||
return newInputs;
|
||||
}
|
||||
|
||||
public void setNewInputs(final String[] newInputs) {
|
||||
this.newInputs = newInputs;
|
||||
}
|
||||
|
||||
public String[] getNewOutputs() {
|
||||
return newOutputs;
|
||||
}
|
||||
|
||||
public void setNewOutputs(final String[] newOutputs) {
|
||||
this.newOutputs = newOutputs;
|
||||
}
|
||||
|
||||
public String[] getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public String[] getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
public boolean isUpdated() {
|
||||
return newInputs != null && newOutputs != null;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return isUpdated() && newInputs.length == 0;
|
||||
}
|
||||
|
||||
public void sort() {
|
||||
if (inputs != null) {
|
||||
Arrays.sort(inputs);
|
||||
}
|
||||
if (outputs != null) {
|
||||
Arrays.sort(outputs);
|
||||
}
|
||||
if (newInputs != null) {
|
||||
Arrays.sort(newInputs);
|
||||
}
|
||||
if (newOutputs != null) {
|
||||
Arrays.sort(newOutputs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + Arrays.hashCode(inputs);
|
||||
result = prime * result + Arrays.hashCode(outputs);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final SynonymItem other = (SynonymItem) obj;
|
||||
sort();
|
||||
other.sort();
|
||||
if (!Arrays.equals(inputs, other.inputs)) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.equals(outputs, other.outputs)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SynonymItem [id=" + id + ", inputs=" + Arrays.toString(inputs)
|
||||
+ ", outputs=" + Arrays.toString(outputs) + ", newInputs="
|
||||
+ Arrays.toString(newInputs) + ", newOutputs="
|
||||
+ Arrays.toString(newOutputs) + "]";
|
||||
}
|
||||
|
||||
public String toLineString() {
|
||||
if (isUpdated()) {
|
||||
if (Arrays.equals(newInputs, newOutputs)) {
|
||||
return StringUtils.join(newInputs, ",");
|
||||
} else {
|
||||
return StringUtils.join(newInputs, ",") + "=>"
|
||||
+ StringUtils.join(newOutputs, ",");
|
||||
}
|
||||
} else {
|
||||
if (Arrays.equals(inputs, outputs)) {
|
||||
return StringUtils.join(inputs, ",");
|
||||
} else {
|
||||
return StringUtils.join(inputs, ",") + "=>"
|
||||
+ StringUtils.join(outputs, ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
38
src/main/java/jp/sf/fess/dict/synonym/SynonymLocator.java
Normal file
38
src/main/java/jp/sf/fess/dict/synonym/SynonymLocator.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package jp.sf.fess.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jp.sf.fess.dict.DictionaryFile;
|
||||
import jp.sf.fess.dict.DictionaryItem;
|
||||
import jp.sf.fess.dict.DictionaryLocator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SynonymLocator extends DictionaryLocator {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(SynonymLocator.class);
|
||||
|
||||
public String synonymFilePrefix = "synonym";
|
||||
|
||||
public List<String> excludedSynonymList;
|
||||
|
||||
@Override
|
||||
public List<DictionaryFile<? extends DictionaryItem>> find() {
|
||||
final List<DictionaryFile<? extends DictionaryItem>> fileList = new ArrayList<DictionaryFile<? extends DictionaryItem>>();
|
||||
for (final String path : searchPathList) {
|
||||
final File[] files = findFiles(path, synonymFilePrefix,
|
||||
excludedSynonymList);
|
||||
for (final File file : files) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Synonym File: " + file.getAbsolutePath());
|
||||
}
|
||||
fileList.add(new SynonymFile(file));
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
}
|
||||
|
||||
}
|
|
@ -26,8 +26,8 @@ import jp.sf.fess.Constants;
|
|||
import jp.sf.fess.db.exentity.DataCrawlingConfig;
|
||||
import jp.sf.fess.ds.DataStore;
|
||||
import jp.sf.fess.ds.IndexUpdateCallback;
|
||||
import jp.sf.fess.helper.CrawlingConfigHelper;
|
||||
import jp.sf.fess.helper.CrawlingSessionHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.taglib.FessFunctions;
|
||||
|
||||
import org.seasar.framework.container.SingletonS2Container;
|
||||
|
@ -61,8 +61,8 @@ public abstract class AbstractDataStoreImpl implements DataStore {
|
|||
final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container
|
||||
.getComponent("crawlingSessionHelper");
|
||||
final Date documentExpires = crawlingSessionHelper.getDocumentExpires();
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
|
||||
initParamMap.putAll(configParamMap);
|
||||
final Map<String, String> paramMap = initParamMap;
|
||||
|
@ -73,12 +73,11 @@ public abstract class AbstractDataStoreImpl implements DataStore {
|
|||
// cid
|
||||
final String configId = config.getConfigId();
|
||||
if (configId != null) {
|
||||
defaultDataMap.put(crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
defaultDataMap.put(systemHelper.configIdField, configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
defaultDataMap.put(crawlingSessionHelper.getExpiresField(),
|
||||
defaultDataMap.put(systemHelper.expiresField,
|
||||
FessFunctions.formatDate(documentExpires));
|
||||
}
|
||||
// segment
|
||||
|
|
|
@ -46,10 +46,6 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
|
||||
public boolean favoriteCountEnabled = true;
|
||||
|
||||
public String clickCountField = "clickCount_i";
|
||||
|
||||
public String favoriteCountField = "favoriteCount_i";
|
||||
|
||||
protected volatile AtomicLong documentSize = new AtomicLong(0);
|
||||
|
||||
protected volatile long commitPerCount = 0;
|
||||
|
@ -137,7 +133,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
|
||||
if (!dataMap.containsKey(Constants.DOC_ID)) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent(SystemHelper.class);
|
||||
.getComponent("systemHelper");
|
||||
doc.addField(Constants.DOC_ID, systemHelper.generateDocId(dataMap));
|
||||
}
|
||||
|
||||
|
@ -158,7 +154,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
logger.info("Committing documents. ");
|
||||
}
|
||||
synchronized (solrGroup) {
|
||||
solrGroup.commit();
|
||||
solrGroup.commit(true, true, false, true);
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Committed documents. The execution time is "
|
||||
|
@ -186,8 +182,10 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
final String url) {
|
||||
final SearchLogHelper searchLogHelper = SingletonS2Container
|
||||
.getComponent(SearchLogHelper.class);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final int count = searchLogHelper.getClickCount(url);
|
||||
doc.addField(clickCountField, count);
|
||||
doc.addField(systemHelper.clickCountField, count);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Click Count: " + count + ", url: " + url);
|
||||
}
|
||||
|
@ -197,8 +195,10 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
final String url) {
|
||||
final SearchLogHelper searchLogHelper = SingletonS2Container
|
||||
.getComponent(SearchLogHelper.class);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final long count = searchLogHelper.getFavoriteCount(url);
|
||||
doc.addField(favoriteCountField, count);
|
||||
doc.addField(systemHelper.favoriteCountField, count);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Favorite Count: " + count + ", url: " + url);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import jp.sf.fess.helper.DatabaseHelper;
|
|||
import jp.sf.fess.helper.MailHelper;
|
||||
import jp.sf.fess.helper.OverlappingHostHelper;
|
||||
import jp.sf.fess.helper.PathMappingHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.helper.WebFsIndexHelper;
|
||||
import jp.sf.fess.screenshot.ScreenShotManager;
|
||||
import jp.sf.fess.service.CrawlingSessionService;
|
||||
|
@ -378,6 +379,8 @@ public class Crawler implements Serializable {
|
|||
|
||||
final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container
|
||||
.getComponent("crawlingSessionHelper");
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
|
||||
boolean completed = false;
|
||||
int exitCode = Constants.EXIT_OK;
|
||||
|
@ -459,10 +462,8 @@ public class Crawler implements Serializable {
|
|||
|
||||
// clean up
|
||||
try {
|
||||
updateSolrGroup.deleteByQuery(crawlingSessionHelper
|
||||
.getExpiresField()
|
||||
+ ":[* TO "
|
||||
+ FessFunctions.formatDate(new Date())
|
||||
updateSolrGroup.deleteByQuery(systemHelper.expiresField
|
||||
+ ":[* TO " + FessFunctions.formatDate(new Date())
|
||||
+ "] NOT segment:" + options.sessionId);
|
||||
} catch (final Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class LoginInfoFilter implements Filter {
|
|||
private void updateRoleList(final HttpServletRequest hRequest,
|
||||
final LoginInfo loginInfo) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent(SystemHelper.class);
|
||||
.getComponent("systemHelper");
|
||||
final List<String> authenticatedRoleList = systemHelper
|
||||
.getAuthenticatedRoleList();
|
||||
final List<String> roleList = new ArrayList<String>();
|
||||
|
|
25
src/main/java/jp/sf/fess/form/admin/DictForm.java
Normal file
25
src/main/java/jp/sf/fess/form/admin/DictForm.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.form.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DictForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
43
src/main/java/jp/sf/fess/form/admin/dict/SynonymForm.java
Normal file
43
src/main/java/jp/sf/fess/form/admin/dict/SynonymForm.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package jp.sf.fess.form.admin.dict;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.struts.annotation.IntegerType;
|
||||
import org.seasar.struts.annotation.LongType;
|
||||
import org.seasar.struts.annotation.Maxbytelength;
|
||||
import org.seasar.struts.annotation.Required;
|
||||
|
||||
public class SynonymForm {
|
||||
@IntegerType
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
@Required
|
||||
public String dictId;
|
||||
|
||||
@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@LongType
|
||||
public String id;
|
||||
|
||||
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
@Maxbytelength(maxbytelength = 1000)
|
||||
public String inputs;
|
||||
|
||||
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
@Maxbytelength(maxbytelength = 1000)
|
||||
public String outputs;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
|
||||
}
|
||||
}
|
|
@ -60,18 +60,6 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
|
||||
protected int count = 1;
|
||||
|
||||
protected String configIdField = "cid_s_s";
|
||||
|
||||
protected String urlField = "url";
|
||||
|
||||
public String getUrlField() {
|
||||
return urlField;
|
||||
}
|
||||
|
||||
public void setUrlField(final String urlField) {
|
||||
this.urlField = urlField;
|
||||
}
|
||||
|
||||
public ConfigType getConfigType(final String configId) {
|
||||
if (configId == null || configId.length() < 2) {
|
||||
return null;
|
||||
|
@ -143,19 +131,13 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
return crawlingConfigMap.get(sessionId);
|
||||
}
|
||||
|
||||
public String getConfigIdField() {
|
||||
return configIdField;
|
||||
}
|
||||
|
||||
public void setConfigIdField(final String configIdField) {
|
||||
this.configIdField = configIdField;
|
||||
}
|
||||
|
||||
public void writeContent(final Map<String, Object> doc) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("writing the content of: " + doc);
|
||||
}
|
||||
final Object configIdObj = doc.get(configIdField);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final Object configIdObj = doc.get(systemHelper.configIdField);
|
||||
if (configIdObj == null) {
|
||||
throw new FessSystemException("Invalid configId: " + configIdObj);
|
||||
}
|
||||
|
@ -188,7 +170,7 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
if (config == null) {
|
||||
throw new FessSystemException("No crawlingConfig: " + configIdObj);
|
||||
}
|
||||
final String url = (String) doc.get(urlField);
|
||||
final String url = (String) doc.get(systemHelper.urlField);
|
||||
final S2RobotClientFactory robotClientFactory = SingletonS2Container
|
||||
.getComponent(S2RobotClientFactory.class);
|
||||
config.initializeClientFactory(robotClientFactory);
|
||||
|
@ -210,9 +192,11 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
StreamUtil.drain(is, os);
|
||||
os.flush();
|
||||
} catch (final IOException e) {
|
||||
throw new FessSystemException(
|
||||
"Failed to write a content. configId: " + configIdObj
|
||||
+ ", url: " + url, e);
|
||||
if (!"ClientAbortException".equals(e.getClass().getSimpleName())) {
|
||||
throw new FessSystemException(
|
||||
"Failed to write a content. configId: " + configIdObj
|
||||
+ ", url: " + url, e);
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(os);
|
||||
|
|
|
@ -57,8 +57,6 @@ public class CrawlingSessionHelper implements Serializable {
|
|||
|
||||
protected Date documentExpires;
|
||||
|
||||
protected String expiresField = "expires_dt";
|
||||
|
||||
protected CrawlingSessionService getCrawlingSessionService() {
|
||||
return SingletonS2Container.getComponent(CrawlingSessionService.class);
|
||||
}
|
||||
|
@ -220,12 +218,4 @@ public class CrawlingSessionHelper implements Serializable {
|
|||
return value.replace('"', ' ');
|
||||
}
|
||||
|
||||
public String getExpiresField() {
|
||||
return expiresField;
|
||||
}
|
||||
|
||||
public void setExpiresField(final String expiresField) {
|
||||
this.expiresField = expiresField;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
45
src/main/java/jp/sf/fess/helper/DocumentHelper.java
Normal file
45
src/main/java/jp/sf/fess/helper/DocumentHelper.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package jp.sf.fess.helper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import jp.sf.fess.FessSystemException;
|
||||
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.codelibs.solr.lib.SolrGroup;
|
||||
import org.codelibs.solr.lib.SolrGroupManager;
|
||||
import org.codelibs.solr.lib.policy.QueryType;
|
||||
|
||||
public class DocumentHelper {
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected SolrGroupManager solrGroupManager;
|
||||
|
||||
public void update(final String docId, final String fieldName,
|
||||
final long num) {
|
||||
|
||||
final SolrGroup solrGroup = solrGroupManager
|
||||
.getSolrGroup(QueryType.ADD);
|
||||
if (!solrGroup.isActive(QueryType.ADD)) {
|
||||
throw new FessSystemException("SolrGroup "
|
||||
+ solrGroup.getGroupName() + " is not available.");
|
||||
}
|
||||
|
||||
final SolrInputDocument doc = new SolrInputDocument();
|
||||
doc.setField(systemHelper.idField, "none");
|
||||
doc.setField(systemHelper.urlField, "none");
|
||||
doc.setField(systemHelper.docIdField, docId);
|
||||
doc.setField(fieldName, num);
|
||||
|
||||
final UpdateRequest req = new UpdateRequest();
|
||||
req.add(doc);
|
||||
req.setParam("excmd", "update");
|
||||
req.setParam("term", systemHelper.docIdField);
|
||||
solrGroup.request(req);
|
||||
solrGroup.commit(false, false, true);
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,8 @@ public interface QueryHelper {
|
|||
|
||||
String[] getResponseFields();
|
||||
|
||||
String[] getResponseDocValuesFields();
|
||||
|
||||
String[] getHighlightingFields();
|
||||
|
||||
int getHighlightSnippetSize();
|
||||
|
|
|
@ -105,6 +105,22 @@ public class SystemHelper implements Serializable {
|
|||
|
||||
private final AtomicBoolean forceStop = new AtomicBoolean(false);
|
||||
|
||||
public String favoriteCountField = "favoriteCount_l_x_dv";
|
||||
|
||||
public String clickCountField = "clickCount_l_x_dv";
|
||||
|
||||
public String screenshotField = "screenshot_s_s";
|
||||
|
||||
public String configIdField = "cid_s_s";
|
||||
|
||||
public String expiresField = "expires_dt";
|
||||
|
||||
public String urlField = "url";
|
||||
|
||||
public String docIdField = "docId";
|
||||
|
||||
public String idField = "id";
|
||||
|
||||
@InitMethod
|
||||
public void init() {
|
||||
final File[] files = ResourceUtil.getJarFiles(launcherFileNamePrefix);
|
||||
|
|
|
@ -82,14 +82,19 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
|
||||
protected String[] responseFields = new String[] { "id", "docId", "score",
|
||||
"boost", "contentLength", "host", "site", "lastModified",
|
||||
"mimetype", "created", "title", "digest", "url", "clickCount_i",
|
||||
"favoriteCount_i", "screenshot_s_s", "cid_s_s" };
|
||||
"mimetype", "created", "title", "digest", "url",
|
||||
"clickCount_l_x_dv", "favoriteCount_l_x_dv", "screenshot_s_s",
|
||||
"cid_s_s" };
|
||||
|
||||
protected String[] responseDocValuesFields = new String[] {
|
||||
"clickCount_l_x_dv", "favoriteCount_l_x_dv" };
|
||||
|
||||
protected String[] highlightingFields = new String[] { "content" };
|
||||
|
||||
protected String[] searchFields = new String[] { "url", "docId", "host",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype",
|
||||
"label", "segment", "clickCount_i", "favoriteCount_i", "inurl" };
|
||||
"label", "segment", "clickCount_l_x_dv", "favoriteCount_l_x_dv",
|
||||
"inurl" };
|
||||
|
||||
protected String[] facetFields = new String[] { "url", "host", "title",
|
||||
"content", "contentLength", "lastModified", "mimetype", "label",
|
||||
|
@ -98,7 +103,8 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
protected String sortPrefix = "sort:";
|
||||
|
||||
protected String[] supportedSortFields = new String[] { "created",
|
||||
"contentLength", "lastModified", "clickCount_i", "favoriteCount_i" };
|
||||
"contentLength", "lastModified", "clickCount_l_x_dv",
|
||||
"favoriteCount_l_x_dv" };
|
||||
|
||||
protected String[] supportedMltFields = new String[] { "content",
|
||||
"content_ja" };
|
||||
|
@ -1089,6 +1095,15 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
this.responseFields = responseFields;
|
||||
}
|
||||
|
||||
public String[] getResponseDocValuesFields() {
|
||||
return responseDocValuesFields;
|
||||
}
|
||||
|
||||
public void setResponseDocValuesFields(
|
||||
final String[] responseDocValuesFields) {
|
||||
this.responseDocValuesFields = responseDocValuesFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the highlightingFields
|
||||
*/
|
||||
|
|
|
@ -210,7 +210,7 @@ public class CrawlJob {
|
|||
final ServletContext servletContext = SingletonS2Container
|
||||
.getComponent(ServletContext.class);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent(SystemHelper.class);
|
||||
.getComponent("systemHelper");
|
||||
final JobHelper jobHelper = SingletonS2Container
|
||||
.getComponent(JobHelper.class);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TriggeredJob implements Job {
|
|||
|
||||
public void execute(final ScheduledJob scheduledJob) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent(SystemHelper.class);
|
||||
.getComponent("systemHelper");
|
||||
final JobHelper jobHelper = SingletonS2Container
|
||||
.getComponent(JobHelper.class);
|
||||
final JobLog jobLog = new JobLog(scheduledJob);
|
||||
|
|
118
src/main/java/jp/sf/fess/pager/SynonymPager.java
Normal file
118
src/main/java/jp/sf/fess/pager/SynonymPager.java
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.pager;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class SynonymPager implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
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 void clear() {
|
||||
pageSize = getDefaultPageSize();
|
||||
currentPageNumber = getDefaultCurrentPageNumber();
|
||||
|
||||
id = null;
|
||||
}
|
||||
|
||||
protected int getDefaultPageSize() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
protected int getDefaultCurrentPageNumber() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ import jp.sf.fess.helper.CrawlingConfigHelper;
|
|||
import jp.sf.fess.helper.CrawlingSessionHelper;
|
||||
import jp.sf.fess.helper.SambaHelper;
|
||||
import jp.sf.fess.helper.SearchLogHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
|
@ -62,10 +63,6 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
|
||||
public int childUrlSize = 10000;
|
||||
|
||||
public String clickCountField = "clickCount_i";
|
||||
|
||||
public String favoriteCountField = "favoriteCount_i";
|
||||
|
||||
@Override
|
||||
protected boolean isContentUpdated(final S2RobotClient client,
|
||||
final UrlQueue urlQueue) {
|
||||
|
@ -81,12 +78,14 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
.getComponent(CrawlingConfigHelper.class);
|
||||
final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container
|
||||
.getComponent(CrawlingSessionHelper.class);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final SambaHelper sambaHelper = SingletonS2Container
|
||||
.getComponent(SambaHelper.class);
|
||||
final boolean useAclAsRole = crawlerProperties.getProperty(
|
||||
Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals(
|
||||
Constants.TRUE);
|
||||
final String expiresField = crawlingSessionHelper.getExpiresField();
|
||||
final String expiresField = systemHelper.expiresField;
|
||||
|
||||
ResponseData responseData = null;
|
||||
try {
|
||||
|
@ -163,7 +162,7 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
}
|
||||
|
||||
final Integer clickCount = (Integer) solrDocument
|
||||
.get(clickCountField);
|
||||
.get(systemHelper.clickCountField);
|
||||
if (clickCount != null) {
|
||||
final SearchLogHelper searchLogHelper = SingletonS2Container
|
||||
.getComponent(SearchLogHelper.class);
|
||||
|
@ -176,7 +175,7 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
}
|
||||
|
||||
final Integer favoriteCount = (Integer) solrDocument
|
||||
.get(favoriteCountField);
|
||||
.get(systemHelper.favoriteCountField);
|
||||
if (favoriteCount != null) {
|
||||
final SearchLogHelper searchLogHelper = SingletonS2Container
|
||||
.getComponent(SearchLogHelper.class);
|
||||
|
@ -264,6 +263,8 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
final boolean wildcard, final String expiresField) {
|
||||
final SolrGroupManager solrGroupManager = SingletonS2Container
|
||||
.getComponent(SolrGroupManager.class);
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final SolrGroup solrGroup = solrGroupManager
|
||||
.getSolrGroup(QueryType.ADD);
|
||||
final SolrQuery solrQuery = new SolrQuery();
|
||||
|
@ -276,7 +277,8 @@ public class FessS2RobotThread extends S2RobotThread {
|
|||
queryBuf.append(id);
|
||||
solrQuery.setQuery(queryBuf.toString());
|
||||
solrQuery.setFields("id", "lastModified", "anchor", "segment", "role",
|
||||
expiresField, clickCountField, favoriteCountField);
|
||||
expiresField, systemHelper.clickCountField,
|
||||
systemHelper.favoriteCountField);
|
||||
for (int i = 0; i < maxSolrQueryRetryCount; i++) {
|
||||
try {
|
||||
final QueryResponse response = solrGroup.query(solrQuery);
|
||||
|
|
|
@ -32,8 +32,10 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.FessSystemException;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.seasar.framework.container.SingletonS2Container;
|
||||
import org.seasar.framework.container.annotation.tiger.InitMethod;
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
import org.seasar.robot.util.LruHashMap;
|
||||
|
@ -54,8 +56,6 @@ public class ScreenShotManager {
|
|||
|
||||
public int threadNum = 10;
|
||||
|
||||
public String solrFieldName = "screenshot_s_s";
|
||||
|
||||
public long shutdownTimeout = 5 * 60 * 1000; // 5min
|
||||
|
||||
public int screenShotPathCacheSize = 10;
|
||||
|
@ -90,12 +90,14 @@ public class ScreenShotManager {
|
|||
}
|
||||
|
||||
public void generate(final Map<String, Object> docMap) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
for (final ScreenShotGenerator generator : generatorList) {
|
||||
if (generator.isTarget(docMap)) {
|
||||
final String segment = (String) docMap.get("segment");
|
||||
final String url = (String) docMap.get("url");
|
||||
final String path = segment + "/" + generator.getPath(docMap);
|
||||
docMap.put(solrFieldName, path);
|
||||
docMap.put(systemHelper.screenshotField, path);
|
||||
executorService.execute(new GenerateTask(url, new File(baseDir,
|
||||
path), generator));
|
||||
break;
|
||||
|
@ -105,11 +107,14 @@ public class ScreenShotManager {
|
|||
|
||||
public void storeRequest(final String queryId,
|
||||
final List<Map<String, Object>> documentItems) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
final Map<String, String> dataMap = new HashMap<String, String>(
|
||||
documentItems.size());
|
||||
for (final Map<String, Object> docMap : documentItems) {
|
||||
final String url = (String) docMap.get("url");
|
||||
final String screenShotPath = (String) docMap.get(solrFieldName);
|
||||
final String screenShotPath = (String) docMap
|
||||
.get(systemHelper.screenshotField);
|
||||
if (StringUtil.isNotBlank(url)
|
||||
&& StringUtil.isNotBlank(screenShotPath)) {
|
||||
dataMap.put(url, screenShotPath);
|
||||
|
|
|
@ -202,7 +202,7 @@ public class FailureUrlService extends BsFailureUrlService implements
|
|||
|
||||
private String getStackTrace(final Throwable t) {
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent(SystemHelper.class);
|
||||
.getComponent("systemHelper");
|
||||
final StringWriter sw = new StringWriter();
|
||||
final PrintWriter pw = new PrintWriter(sw, true);
|
||||
t.printStackTrace(pw);
|
||||
|
|
|
@ -68,8 +68,13 @@ public class SearchService implements Serializable {
|
|||
protected Suggester suggester;
|
||||
|
||||
public Map<String, Object> getDocument(final String query) {
|
||||
return getDocument(query, null);
|
||||
}
|
||||
|
||||
public Map<String, Object> getDocument(final String query,
|
||||
final String[] docValuesFields) {
|
||||
final List<Map<String, Object>> docList = getDocumentList(query, 0, 1,
|
||||
null, null, null);
|
||||
null, null, null, docValuesFields);
|
||||
if (!docList.isEmpty()) {
|
||||
return docList.get(0);
|
||||
}
|
||||
|
@ -77,7 +82,8 @@ public class SearchService implements Serializable {
|
|||
}
|
||||
|
||||
public List<Map<String, Object>> getDocumentListByDocIds(
|
||||
final String[] docIds, final int pageSize) {
|
||||
final String[] docIds, final String[] docValuesFields,
|
||||
final int pageSize) {
|
||||
if (docIds == null || docIds.length == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -89,20 +95,22 @@ public class SearchService implements Serializable {
|
|||
}
|
||||
buf.append("docId:").append(docIds[i]);
|
||||
}
|
||||
return getDocumentList(buf.toString(), 0, pageSize, null, null, null);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDocumentList(final String query,
|
||||
final int start, final int rows, final FacetInfo facetInfo,
|
||||
final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo) {
|
||||
return getDocumentList(query, start, rows, facetInfo, geoInfo, mltInfo,
|
||||
true);
|
||||
return getDocumentList(buf.toString(), 0, pageSize, null, null, null,
|
||||
docValuesFields);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDocumentList(final String query,
|
||||
final int start, final int rows, final FacetInfo facetInfo,
|
||||
final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo,
|
||||
final boolean forUser) {
|
||||
final String[] docValuesFields) {
|
||||
return getDocumentList(query, start, rows, facetInfo, geoInfo, mltInfo,
|
||||
docValuesFields, true);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDocumentList(final String query,
|
||||
final int start, final int rows, final FacetInfo facetInfo,
|
||||
final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo,
|
||||
final String[] docValuesFields, final boolean forUser) {
|
||||
if (start > queryHelper.getMaxSearchResultOffset()) {
|
||||
throw new ResultOffsetExceededException(
|
||||
"The number of result size is exceeded.");
|
||||
|
@ -244,6 +252,12 @@ public class SearchService implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
if (docValuesFields != null) {
|
||||
for (final String docValuesField : docValuesFields) {
|
||||
solrQuery.setParam(Constants.DCF, docValuesField);
|
||||
}
|
||||
}
|
||||
|
||||
queryResponse = solrGroup.query(solrQuery, SolrRequest.METHOD.POST);
|
||||
}
|
||||
final long execTime = System.currentTimeMillis() - startTime;
|
||||
|
|
82
src/main/java/jp/sf/fess/service/SynonymService.java
Normal file
82
src/main/java/jp/sf/fess/service/SynonymService.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package jp.sf.fess.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import jp.sf.fess.crud.CommonConstants;
|
||||
import jp.sf.fess.dict.DictionaryFile;
|
||||
import jp.sf.fess.dict.DictionaryFile.PagingList;
|
||||
import jp.sf.fess.dict.DictionaryManager;
|
||||
import jp.sf.fess.dict.synonym.SynonymFile;
|
||||
import jp.sf.fess.dict.synonym.SynonymItem;
|
||||
import jp.sf.fess.pager.SynonymPager;
|
||||
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
|
||||
public class SynonymService {
|
||||
@Resource
|
||||
protected DictionaryManager dictionaryManager;
|
||||
|
||||
public List<SynonymItem> getSynonymList(final String dictId,
|
||||
final SynonymPager synonymPager) {
|
||||
final SynonymFile synonymFile = getSynonymFile(dictId);
|
||||
|
||||
final int pageSize = synonymPager.getPageSize();
|
||||
final PagingList<SynonymItem> synonymList = synonymFile.selectList(
|
||||
(synonymPager.getCurrentPageNumber() - 1) * pageSize, pageSize);
|
||||
|
||||
// update pager
|
||||
Beans.copy(synonymList, synonymPager)
|
||||
.includes(CommonConstants.PAGER_CONVERSION_RULE).execute();
|
||||
synonymList.setPageRangeSize(5);
|
||||
synonymPager.setPageNumberList(synonymList.createPageNumberList());
|
||||
|
||||
return synonymList;
|
||||
|
||||
}
|
||||
|
||||
protected SynonymFile getSynonymFile(final String dictId) {
|
||||
final DictionaryFile<?> dictionaryFile = dictionaryManager
|
||||
.getDictionaryFile(dictId);
|
||||
if (dictionaryFile instanceof SynonymFile) {
|
||||
return (SynonymFile) dictionaryFile;
|
||||
}
|
||||
throw new ActionMessagesException("errors.expired_dict_id");
|
||||
}
|
||||
|
||||
public SynonymItem getSynonym(final String dictId,
|
||||
final Map<String, String> paramMap) {
|
||||
final SynonymFile synonymFile = getSynonymFile(dictId);
|
||||
|
||||
final String idStr = paramMap.get("id");
|
||||
if (StringUtil.isNotBlank(idStr)) {
|
||||
try {
|
||||
final long id = Long.parseLong(idStr);
|
||||
return synonymFile.get(id);
|
||||
} catch (final NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void store(final String dictId, final SynonymItem synonymItem) {
|
||||
final SynonymFile synonymFile = getSynonymFile(dictId);
|
||||
|
||||
if (synonymItem.getId() == 0) {
|
||||
synonymFile.insert(synonymItem);
|
||||
} else {
|
||||
synonymFile.update(synonymItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(final String dictId, final SynonymItem synonymItem) {
|
||||
final SynonymFile synonymFile = getSynonymFile(dictId);
|
||||
synonymFile.delete(synonymItem);
|
||||
}
|
||||
}
|
|
@ -123,10 +123,6 @@ public class IndexUpdater extends Thread {
|
|||
|
||||
public boolean favoriteCountEnabled = true;
|
||||
|
||||
public String clickCountField = "clickCount_i";
|
||||
|
||||
public String favoriteCountField = "favoriteCount_i";
|
||||
|
||||
private final List<BoostDocumentRule> boostRuleList = new ArrayList<BoostDocumentRule>();
|
||||
|
||||
private final Map<String, Object> docValueMap = new HashMap<String, Object>();
|
||||
|
@ -497,8 +493,8 @@ public class IndexUpdater extends Thread {
|
|||
final ClickLogCB cb = new ClickLogCB();
|
||||
cb.query().setUrl_Equal(url);
|
||||
final int count = clickLogBhv.selectCount(cb);
|
||||
doc.addField(clickCountField, count);
|
||||
map.put(clickCountField, count);
|
||||
doc.addField(systemHelper.clickCountField, count);
|
||||
map.put(systemHelper.clickCountField, count);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Click Count: " + count + ", url: " + url);
|
||||
}
|
||||
|
@ -520,8 +516,8 @@ public class IndexUpdater extends Thread {
|
|||
count = list.get(0).getCnt().longValue();
|
||||
}
|
||||
|
||||
doc.addField(favoriteCountField, count);
|
||||
map.put(favoriteCountField, count);
|
||||
doc.addField(systemHelper.favoriteCountField, count);
|
||||
map.put(systemHelper.favoriteCountField, count);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Favorite Count: " + count + ", url: " + url);
|
||||
}
|
||||
|
@ -620,7 +616,7 @@ public class IndexUpdater extends Thread {
|
|||
logger.info("Committing documents. ");
|
||||
}
|
||||
synchronized (solrGroup) {
|
||||
solrGroup.commit();
|
||||
solrGroup.commit(true, true, false, true);
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Committed documents. The execution time is "
|
||||
|
|
|
@ -37,6 +37,7 @@ import jp.sf.fess.helper.CrawlingSessionHelper;
|
|||
import jp.sf.fess.helper.LabelTypeHelper;
|
||||
import jp.sf.fess.helper.PathMappingHelper;
|
||||
import jp.sf.fess.helper.SambaHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.taglib.FessFunctions;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -185,6 +186,8 @@ public abstract class AbstractFessFileTransformer extends
|
|||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
String urlEncoding;
|
||||
final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue();
|
||||
if (urlQueue != null && urlQueue.getEncoding() != null) {
|
||||
|
@ -196,12 +199,11 @@ public abstract class AbstractFessFileTransformer extends
|
|||
// cid
|
||||
final String configId = crawlingConfig.getConfigId();
|
||||
if (configId != null) {
|
||||
putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
putResultDataBody(dataMap, systemHelper.configIdField, configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(),
|
||||
putResultDataBody(dataMap, systemHelper.expiresField,
|
||||
FessFunctions.formatDate(documentExpires));
|
||||
}
|
||||
// segment
|
||||
|
|
|
@ -43,6 +43,7 @@ import jp.sf.fess.helper.CrawlingSessionHelper;
|
|||
import jp.sf.fess.helper.LabelTypeHelper;
|
||||
import jp.sf.fess.helper.OverlappingHostHelper;
|
||||
import jp.sf.fess.helper.PathMappingHelper;
|
||||
import jp.sf.fess.helper.SystemHelper;
|
||||
import jp.sf.fess.taglib.FessFunctions;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -220,6 +221,8 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
final SystemHelper systemHelper = SingletonS2Container
|
||||
.getComponent("systemHelper");
|
||||
String urlEncoding;
|
||||
final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue();
|
||||
if (urlQueue != null && urlQueue.getEncoding() != null) {
|
||||
|
@ -231,12 +234,11 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
// cid
|
||||
final String configId = crawlingConfig.getConfigId();
|
||||
if (configId != null) {
|
||||
putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
putResultDataBody(dataMap, systemHelper.configIdField, configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(),
|
||||
putResultDataBody(dataMap, systemHelper.expiresField,
|
||||
FessFunctions.formatDate(documentExpires));
|
||||
}
|
||||
// title
|
||||
|
|
|
@ -39,6 +39,12 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class QueryResponseList implements List<Map<String, Object>> {
|
||||
private static final String PARTIAL_RESULTS = "partialResults";
|
||||
|
||||
private static final String MORE_LIKE_THIS = "moreLikeThis";
|
||||
|
||||
private static final String DOC_VALUES = "docValues";
|
||||
|
||||
private static final String ID_FIELD = "id";
|
||||
|
||||
private static final Logger logger = LoggerFactory
|
||||
|
@ -96,7 +102,7 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
numFound = sdList.getNumFound();
|
||||
|
||||
final Object partialResultsValue = queryResponse
|
||||
.getResponseHeader().get("partialResults");
|
||||
.getResponseHeader().get(PARTIAL_RESULTS);
|
||||
if (partialResultsValue != null
|
||||
&& ((Boolean) partialResultsValue).booleanValue()) {
|
||||
partialResults = true;
|
||||
|
@ -157,7 +163,7 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
|
||||
// mlt
|
||||
final Object moreLikeThisMap = queryResponse.getResponse().get(
|
||||
"moreLikeThis");
|
||||
MORE_LIKE_THIS);
|
||||
if (moreLikeThisMap instanceof SimpleOrderedMap) {
|
||||
moreLikeThisResponse = new MoreLikeThisResponse();
|
||||
final int size = ((SimpleOrderedMap<?>) moreLikeThisMap).size();
|
||||
|
@ -179,6 +185,20 @@ public class QueryResponseList implements List<Map<String, Object>> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// docValues
|
||||
final Object docValuesObj = queryResponse.getResponse().get(
|
||||
DOC_VALUES);
|
||||
if (docValuesObj instanceof SimpleOrderedMap) {
|
||||
final SimpleOrderedMap<List<Long>> docValuesMap = (SimpleOrderedMap<List<Long>>) docValuesObj;
|
||||
for (int i = 0; i < docValuesMap.size(); i++) {
|
||||
final String name = docValuesMap.getName(i);
|
||||
final List<Long> valueList = docValuesMap.getVal(i);
|
||||
for (int j = 0; j < valueList.size() && j < parent.size(); j++) {
|
||||
parent.get(j).put(name, valueList.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
calculatePageInfo(start, pageSize, numFound);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package jp.sf.fess.util;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
|
@ -85,4 +87,26 @@ public class ResourceUtil {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String resolve(final String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final StringBuffer tunedText = new StringBuffer(value.length());
|
||||
final Pattern pattern = Pattern.compile("(\\$\\{([\\w\\.]+)\\})");
|
||||
final Matcher matcher = pattern.matcher(value);
|
||||
while (matcher.find()) {
|
||||
final String key = matcher.group(2);
|
||||
String replacement = System.getProperty(key);
|
||||
if (replacement == null) {
|
||||
replacement = matcher.group(1);
|
||||
}
|
||||
matcher.appendReplacement(tunedText,
|
||||
replacement.replace("$", "\\$"));
|
||||
|
||||
}
|
||||
matcher.appendTail(tunedText);
|
||||
return tunedText.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<include path="fess.dicon"/>
|
||||
<include path="fess_suggest.dicon"/>
|
||||
<include path="fess_job.dicon"/>
|
||||
<include path="fess_api.dicon"/>
|
||||
<include path="fess_dict.dicon"/>
|
||||
|
||||
<include path="mobylet.dicon"/>
|
||||
|
||||
|
@ -62,14 +64,15 @@
|
|||
<initMethod name="setApiResponseFields">
|
||||
<arg>new String[]{"id", "docId", "score", "boost",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype",
|
||||
"created", "title", "digest", "url", "clickCount_i", "favoriteCount_i"}</arg>
|
||||
"created", "title", "digest", "url"}</arg>
|
||||
</initMethod>
|
||||
<!--
|
||||
<property name="additionalGeoQuery">"location_i_i:1"</property>
|
||||
<property name="responseFields">new String[]{"id", "docId", "score", "boost",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype",
|
||||
"created", "title", "digest", "url", "clickCount_i", "favoriteCount_i",
|
||||
"screenshot_s_s", "cid_s_s"}</property>
|
||||
"created", "title", "digest", "url", "screenshot_s_s", "cid_s_s"}</property>
|
||||
<property name="responseDocValuesFields">new String[]{
|
||||
"clickCount_l_x_dv", "favoriteCount_l_x_dv"}</property>
|
||||
<property name="highlightingFields">new String[]{"digest", "cache" }</property>
|
||||
<property name="searchFields">new String[]{"url", "docId", "host",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype",
|
||||
|
@ -79,7 +82,7 @@
|
|||
"label", "segment" }</property>
|
||||
<property name="sortPrefix">"sort:"</property>
|
||||
<property name="supportedSortFields">new String[]{"created",
|
||||
"contentLength", "lastModified", "clickCount_i" }</property>
|
||||
"contentLength", "lastModified", "clickCount_l_x_dv" }</property>
|
||||
<property name="supportedMltFields">new String[]{"content",
|
||||
"content_ja" }</property>
|
||||
<property name="supportedSuggestFields">new String[]{"content",
|
||||
|
@ -206,6 +209,8 @@
|
|||
<property name="osddPath">"/WEB-INF/orig/open-search/osdd.xml"</property>
|
||||
<property name="encoding">"UTF-8"</property>
|
||||
</component>
|
||||
<component name="documentHelper" class="jp.sf.fess.helper.DocumentHelper">
|
||||
</component>
|
||||
<component name="queryResponseList" class="jp.sf.fess.util.QueryResponseList" instance="prototype">
|
||||
</component>
|
||||
<component name="userAgentName" class="java.lang.String">
|
||||
|
|
|
@ -71,6 +71,7 @@ errors.document_not_found=Not found URL of Doc ID:{0}
|
|||
errors.not_load_from_server=Could not load from this server: {0}
|
||||
errors.failed_to_start_job=Failed to start job {0}.
|
||||
errors.failed_to_stop_job=Failed to stop job {0}.
|
||||
errors.expired_dict_id=Expired dictionary information. Please reload it.
|
||||
|
||||
errors.invalid_query_unknown=The given query is invalid.
|
||||
errors.invalid_query_quoted=An invalid quote character is used.
|
||||
|
@ -285,9 +286,10 @@ labels.menu.scheduled_job_config=» Scheduled Jobs
|
|||
labels.menu.system_config=» System Info
|
||||
labels.menu.document_config=» Doc Info
|
||||
labels.menu.design=» Design
|
||||
labels.menu.dict=» Dictionary
|
||||
labels.menu.data=» Backup/Restore
|
||||
|
||||
labels.menu_crawl=Crawling
|
||||
labels.menu_crawl=Crawler
|
||||
labels.menu.web=» Web
|
||||
labels.menu.file_system=» File System
|
||||
labels.menu.data_store=» Data Store
|
||||
|
@ -1327,6 +1329,36 @@ labels.joblog_target=Target
|
|||
labels.joblog_title_confirm=Confirm
|
||||
labels.joblog_title_details=Details
|
||||
|
||||
# dict
|
||||
labels.dict_configuration=Dictionary List
|
||||
labels.dict_list_title=Dictionary List
|
||||
labels.dict_list_link=Dictionaries
|
||||
labels.dictionary_name=Name
|
||||
labels.dictionary_type=Type
|
||||
labels.dict_link_details=Details
|
||||
labels.dict_link_edit=Edit
|
||||
labels.dict_link_delete=Delete
|
||||
labels.dict_link_prev_page=Prev
|
||||
labels.dict_link_next_page=Next
|
||||
labels.dict_button_back=Back
|
||||
|
||||
# synonym
|
||||
labels.dict_synonym_configuration=Synonym List
|
||||
labels.dict_synonym_title=Synonym List
|
||||
labels.dict_synonym_list_link=List
|
||||
labels.dict_synonym_link_create=Create
|
||||
labels.dict_synonym_link_update=Update
|
||||
labels.dict_synonym_link_delete=Delete
|
||||
labels.dict_synonym_link_confirm=Confirm
|
||||
labels.dict_synonym_source=Source
|
||||
labels.dict_synonym_target=Target
|
||||
labels.dict_synonym_button_create=Create
|
||||
labels.dict_synonym_button_back=Back
|
||||
labels.dict_synonym_button_confirm=Confirm
|
||||
labels.dict_synonym_button_edit=Edit
|
||||
labels.dict_synonym_button_delete=Delete
|
||||
labels.dict_synonym_button_update=Update
|
||||
|
||||
# CRUD PROPERTIES: BEGIN
|
||||
errors.crud_invalid_mode=Invalid mode(expected value is {0}, but it's {1}).
|
||||
errors.crud_failed_to_create_crud_table=Failed to create a new data.
|
||||
|
@ -1352,7 +1384,7 @@ labels.crud_link_delete=Delete
|
|||
labels.crud_link_back=Back
|
||||
labels.crud_link_edit=Edit
|
||||
labels.crud_link_next_page=Next
|
||||
labels.crud_link_prev_page=Back
|
||||
labels.crud_link_prev_page=Prev
|
||||
|
||||
labels.crud_title_details=Details
|
||||
labels.crud_title_confirm=Confirmation
|
||||
|
|
|
@ -71,6 +71,7 @@ errors.document_not_found=ID:{0}\u306eURL\u304c\u898b\u3064\u304b\u308a\u307e\u3
|
|||
errors.not_load_from_server=\u3053\u306e\u30b5\u30fc\u30d0\u304b\u3089\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f: {0}
|
||||
errors.failed_to_start_job=\u30b8\u30e7\u30d6 {0} \u306e\u958b\u59cb\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
|
||||
errors.failed_to_stop_job=\u30b8\u30e7\u30d6 {0} \u306e\u958b\u59cb\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
|
||||
errors.expired_dict_id=\u8f9e\u66f8\u60c5\u5831\u304c\u671f\u9650\u5207\u308c\u3067\u3059\u3002\u518d\u5ea6\u8aad\u307f\u306a\u304a\u3057\u3066\u304f\u3060\u3055\u3044\u3002
|
||||
|
||||
errors.invalid_query_unknown=\u691c\u7d22\u30af\u30a8\u30ea\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002
|
||||
errors.invalid_query_quoted=\u30af\u30aa\u30fc\u30c8\u6587\u5b57(")\u306e\u5229\u7528\u65b9\u6cd5\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002
|
||||
|
@ -285,6 +286,7 @@ labels.menu.scheduled_job_config=» \u30b8\u30e7\u30d6\u7ba1\u7406
|
|||
labels.menu.system_config=» \u30b7\u30b9\u30c6\u30e0\u8a2d\u5b9a
|
||||
labels.menu.document_config=» \u30a4\u30f3\u30c7\u30c3\u30af\u30b9
|
||||
labels.menu.design=» \u30c7\u30b6\u30a4\u30f3
|
||||
labels.menu.dict=» \u8f9e\u66f8
|
||||
labels.menu.data=» \u30d0\u30c3\u30af\u30a2\u30c3\u30d7/\u30ea\u30b9\u30c8\u30a2
|
||||
|
||||
labels.menu_crawl=\u30af\u30ed\u30fc\u30eb
|
||||
|
@ -1325,6 +1327,36 @@ labels.joblog_target=\u5bfe\u8c61
|
|||
labels.joblog_title_confirm=\u78ba\u8a8d
|
||||
labels.joblog_title_details=\u8a73\u7d30
|
||||
|
||||
# dict
|
||||
labels.dict_configuration=\u8f9e\u66f8\u4e00\u89a7
|
||||
labels.dict_list_title=\u8f9e\u66f8\u4e00\u89a7
|
||||
labels.dict_list_link=\u8f9e\u66f8\u4e00\u89a7
|
||||
labels.dictionary_name=\u540d\u524d
|
||||
labels.dictionary_type=\u7a2e\u985e
|
||||
labels.dict_link_details=\u8a73\u7d30
|
||||
labels.dict_link_edit=\u7de8\u96c6
|
||||
labels.dict_link_delete=\u524a\u9664
|
||||
labels.dict_link_prev_page=\u524d\u3078
|
||||
labels.dict_link_next_page=\u6b21\u3078
|
||||
labels.dict_button_back=\u623b\u308b
|
||||
|
||||
# synonym
|
||||
labels.dict_synonym_configuration=\u540c\u7fa9\u8a9e\u4e00\u89a7
|
||||
labels.dict_synonym_title=\u540c\u7fa9\u8a9e\u4e00\u89a7
|
||||
labels.dict_synonym_list_link=\u4e00\u89a7
|
||||
labels.dict_synonym_link_create=\u4f5c\u6210
|
||||
labels.dict_synonym_link_update=\u66f4\u65b0
|
||||
labels.dict_synonym_link_delete=\u524a\u9664
|
||||
labels.dict_synonym_link_confirm=\u78ba\u8a8d
|
||||
labels.dict_synonym_source=\u5909\u63db\u5143
|
||||
labels.dict_synonym_target=\u5909\u63db\u5f8c
|
||||
labels.dict_synonym_button_create=\u4f5c\u6210
|
||||
labels.dict_synonym_button_back=\u623b\u308b
|
||||
labels.dict_synonym_button_confirm=\u78ba\u8a8d
|
||||
labels.dict_synonym_button_edit=\u7de8\u96c6
|
||||
labels.dict_synonym_button_delete=\u524a\u9664
|
||||
labels.dict_synonym_button_update=\u66f4\u65b0
|
||||
|
||||
# CRUD PROPERTIES: BEGIN
|
||||
errors.crud_invalid_mode=\u30e2\u30fc\u30c9\u304c\u9055\u3044\u307e\u3059\u3002(\u6b63\u3057\u3044\u5024\u306f {0} \u3067\u3059\u304c\u3001\u5165\u529b\u3055\u308c\u305f\u5024\u306f {1} \u306b\u306a\u3063\u3066\u3044\u307e\u3059)
|
||||
errors.crud_failed_to_create_crud_table=\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<components>
|
||||
<include path="solrlib.dicon"/>
|
||||
<include path="fess_ds.dicon"/>
|
||||
<include path="fess_api.dicon"/>
|
||||
|
||||
<component name="crawlerProperties" class="org.codelibs.core.util.DynamicProperties">
|
||||
<arg>
|
||||
|
|
19
src/main/resources/fess_dict.dicon
Normal file
19
src/main/resources/fess_dict.dicon
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
|
||||
"http://www.seasar.org/dtd/components24.dtd">
|
||||
<components>
|
||||
<component name="dictionaryManager" class="jp.sf.fess.dict.DictionaryManager">
|
||||
<initMethod name="addLocator">
|
||||
<arg>synonymLocator</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
|
||||
<component name="synonymLocator" class="jp.sf.fess.dict.synonym.SynonymLocator">
|
||||
<property name="excludedSynonymList">{"data", "txlog",
|
||||
"lib", "bin", "contrib"}</property>
|
||||
<initMethod name="addSearchPath">
|
||||
<arg>"${solr.solr.home}"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
|
||||
</components>
|
19
src/main/webapp/WEB-INF/view/admin/dict/error.jsp
Normal file
19
src/main/webapp/WEB-INF/view/admin/dict/error.jsp
Normal file
|
@ -0,0 +1,19 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp" flush="true">
|
||||
<tiles:put name="title"><bean:message key="labels.dict_configuration" /></tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<div id="main">
|
||||
|
||||
<html:errors/>
|
||||
<br/>
|
||||
<s:link href="index"><bean:message key="labels.dict_button_back"/></s:link>
|
||||
|
||||
</div>
|
||||
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
63
src/main/webapp/WEB-INF/view/admin/dict/index.jsp
Normal file
63
src/main/webapp/WEB-INF/view/admin/dict/index.jsp
Normal file
|
@ -0,0 +1,63 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
|
||||
flush="true">
|
||||
<tiles:put name="title">
|
||||
<bean:message key="labels.dict_configuration" />
|
||||
</tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<h3>
|
||||
<bean:message key="labels.dict_list_title" />
|
||||
</h3>
|
||||
|
||||
<%-- Message: BEGIN --%>
|
||||
<div>
|
||||
<html:messages id="msg" message="true">
|
||||
<div class="alert-message info"><bean:write name="msg" ignore="true" /></div>
|
||||
</html:messages>
|
||||
<html:errors />
|
||||
</div>
|
||||
<%-- Message: END --%>
|
||||
|
||||
<%-- List: BEGIN --%>
|
||||
<div class="list-table">
|
||||
<div>
|
||||
<ul class="pills">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_list_link" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<c:if test="${fn:length(dictFiles) == 0}">
|
||||
<p class="alert-message warning">
|
||||
<bean:message key="labels.list_could_not_find_crud_table" />
|
||||
</p>
|
||||
</c:if>
|
||||
<c:if test="${fn:length(dictFiles) > 0}">
|
||||
<table class="bordered-table zebra-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center;width:70px;"><bean:message
|
||||
key="labels.dictionary_type" /></th>
|
||||
<th style="text-align: center;"><bean:message
|
||||
key="labels.dictionary_name" /></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="data" varStatus="s" items="${dictFiles}">
|
||||
<tr class="${s.index % 2 == 0 ? 'row1' : 'row2'}">
|
||||
<td>${f:h(data.type)}</td>
|
||||
<td><s:link href="${f:h(data.type)}/index?dictId=${f:h(data.id)}">${f:h(data.name)}</s:link></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</c:if>
|
||||
</div>
|
||||
<%-- List: END --%>
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
106
src/main/webapp/WEB-INF/view/admin/dict/synonym/confirm.jsp
Normal file
106
src/main/webapp/WEB-INF/view/admin/dict/synonym/confirm.jsp
Normal file
|
@ -0,0 +1,106 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
|
||||
flush="true">
|
||||
<tiles:put name="title">
|
||||
<bean:message key="labels.dict_synonym_configuration" />
|
||||
</tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<h3>
|
||||
<bean:message key="labels.dict_synonym_title" />
|
||||
</h3>
|
||||
|
||||
<%-- Message: BEGIN --%>
|
||||
<div>
|
||||
<html:messages id="msg" message="true">
|
||||
<div class="alert-message info"><bean:write name="msg" ignore="true" /></div>
|
||||
</html:messages>
|
||||
<html:errors />
|
||||
</div>
|
||||
<%-- Message: END --%>
|
||||
|
||||
<div>
|
||||
<ul class="pills">
|
||||
<li><s:link href="../index">
|
||||
<bean:message key="labels.dict_list_link" />
|
||||
</s:link></li>
|
||||
<li><s:link href="index?dictId=${f:u(dictId)}">
|
||||
<bean:message key="labels.dict_synonym_list_link" />
|
||||
</s:link></li>
|
||||
<c:if test="${crudMode == 1}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_create" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 2}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_update" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 3}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_delete" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 4}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_confirm" /></a></li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<%-- Confirm Form: BEGIN --%>
|
||||
<s:form>
|
||||
<html:hidden property="crudMode" />
|
||||
<div>
|
||||
<html:hidden property="dictId" />
|
||||
<c:if test="${crudMode==2 || crudMode==3 || crudMode==4}">
|
||||
<html:hidden property="id" />
|
||||
</c:if>
|
||||
<table class="bordered-table zebra-striped" style="width: 500px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 150px;"><bean:message
|
||||
key="labels.dict_synonym_source" /></th>
|
||||
<td>${f:br(f:h(inputs))}<html:hidden property="inputs" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><bean:message key="labels.dict_synonym_target" /></th>
|
||||
<td>${f:br(f:h(outputs))}<html:hidden property="outputs" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2"><c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn mini" name="create"
|
||||
value="<bean:message key="labels.dict_synonym_button_create"/>" />
|
||||
<input type="submit" class="btn mini" name="editagain"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
</c:if> <c:if test="${crudMode == 2}">
|
||||
<input type="submit" class="btn mini" name="update"
|
||||
value="<bean:message key="labels.dict_synonym_button_update"/>" />
|
||||
<input type="submit" class="btn mini" name="editagain"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
</c:if> <c:if test="${crudMode == 3}">
|
||||
<input type="submit" class="btn mini" name="delete"
|
||||
value="<bean:message key="labels.dict_synonym_button_delete"/>" />
|
||||
<input type="submit" class="btn mini" name="back"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
</c:if> <c:if test="${crudMode == 4}">
|
||||
<input type="submit" class="btn mini" name="back"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
<input type="submit" class="btn mini" name="editfromconfirm"
|
||||
value="<bean:message key="labels.dict_synonym_button_edit"/>" />
|
||||
<input type="submit" class="btn mini" name="deletefromconfirm"
|
||||
value="<bean:message key="labels.dict_synonym_button_delete"/>" />
|
||||
</c:if></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</s:form>
|
||||
<%-- Confirm Form: BEGIN --%>
|
||||
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
95
src/main/webapp/WEB-INF/view/admin/dict/synonym/edit.jsp
Normal file
95
src/main/webapp/WEB-INF/view/admin/dict/synonym/edit.jsp
Normal file
|
@ -0,0 +1,95 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
|
||||
flush="true">
|
||||
<tiles:put name="title">
|
||||
<bean:message key="labels.dict_synonym_configuration" />
|
||||
</tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<h3>
|
||||
<bean:message key="labels.dict_synonym_title" />
|
||||
</h3>
|
||||
|
||||
<%-- Message: BEGIN --%>
|
||||
<div>
|
||||
<html:messages id="msg" message="true">
|
||||
<div class="alert-message info"><bean:write name="msg" ignore="true" /></div>
|
||||
</html:messages>
|
||||
<html:errors />
|
||||
</div>
|
||||
<%-- Message: END --%>
|
||||
|
||||
<div>
|
||||
<ul class="pills">
|
||||
<li><s:link href="../index">
|
||||
<bean:message key="labels.dict_list_link" />
|
||||
</s:link></li>
|
||||
<li><s:link href="index?dictId=${f:u(dictId)}">
|
||||
<bean:message key="labels.dict_synonym_list_link" />
|
||||
</s:link></li>
|
||||
<c:if test="${crudMode == 1}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_create" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 2}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_update" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 3}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_delete" /></a></li>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 4}">
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_link_confirm" /></a></li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<%-- Edit Form: BEGIN --%>
|
||||
<s:form>
|
||||
<html:hidden property="crudMode" />
|
||||
<div>
|
||||
<html:hidden property="dictId" />
|
||||
<c:if test="${crudMode==2}">
|
||||
<html:hidden property="id" />
|
||||
</c:if>
|
||||
<table class="bordered-table zebra-striped" style="width: 500px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 150px;"><bean:message
|
||||
key="labels.dict_synonym_source" /></th>
|
||||
<td><html:textarea property="inputs" rows="5" style="width:98%;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><bean:message
|
||||
key="labels.dict_synonym_target" /></th>
|
||||
<td><html:textarea property="outputs" rows="5" style="width:98%;" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2"><c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn mini" name="confirmfromcreate"
|
||||
value="<bean:message key="labels.dict_synonym_button_create"/>" />
|
||||
<input type="submit" class="btn mini" name="back"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
</c:if> <c:if test="${crudMode == 2}">
|
||||
<input type="submit" class="btn mini" name="confirmfromupdate"
|
||||
value="<bean:message key="labels.dict_synonym_button_confirm"/>" />
|
||||
<input type="submit" class="btn mini" name="back"
|
||||
value="<bean:message key="labels.dict_synonym_button_back"/>" />
|
||||
</c:if></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</s:form>
|
||||
<%-- Edit Form: BEGIN --%>
|
||||
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
19
src/main/webapp/WEB-INF/view/admin/dict/synonym/error.jsp
Normal file
19
src/main/webapp/WEB-INF/view/admin/dict/synonym/error.jsp
Normal file
|
@ -0,0 +1,19 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp" flush="true">
|
||||
<tiles:put name="title"><bean:message key="labels.dict_synonym_configuration" /></tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<div id="main">
|
||||
|
||||
<html:errors/>
|
||||
<br/>
|
||||
<s:link href="../index"><bean:message key="labels.dict_button_back"/></s:link>
|
||||
|
||||
</div>
|
||||
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
121
src/main/webapp/WEB-INF/view/admin/dict/synonym/index.jsp
Normal file
121
src/main/webapp/WEB-INF/view/admin/dict/synonym/index.jsp
Normal file
|
@ -0,0 +1,121 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
|
||||
flush="true">
|
||||
<tiles:put name="title">
|
||||
<bean:message key="labels.dict_synonym_configuration" />
|
||||
</tiles:put>
|
||||
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
|
||||
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
|
||||
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
|
||||
<tiles:put name="menuType" value="dict" />
|
||||
<tiles:put name="headerScript" type="string"></tiles:put>
|
||||
<tiles:put name="body" type="string">
|
||||
|
||||
<h3>
|
||||
<bean:message key="labels.dict_synonym_title" />
|
||||
</h3>
|
||||
|
||||
<%-- Message: BEGIN --%>
|
||||
<div>
|
||||
<html:messages id="msg" message="true">
|
||||
<div class="alert-message info"><bean:write name="msg" ignore="true" /></div>
|
||||
</html:messages>
|
||||
<html:errors />
|
||||
</div>
|
||||
<%-- Message: END --%>
|
||||
|
||||
<%-- List: BEGIN --%>
|
||||
<div class="list-table">
|
||||
<div>
|
||||
<ul class="pills">
|
||||
<li><s:link href="../index">
|
||||
<bean:message key="labels.dict_list_link" />
|
||||
</s:link></li>
|
||||
<li class="active"><a href="#"><bean:message
|
||||
key="labels.dict_synonym_list_link" /></a></li>
|
||||
<li><s:link href="createpage?dictId=${f:u(dictId)}">
|
||||
<bean:message key="labels.dict_synonym_link_create" />
|
||||
</s:link></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<c:if test="${synonymPager.allRecordCount == 0}">
|
||||
<p class="alert-message warning">
|
||||
<bean:message key="labels.list_could_not_find_crud_table" />
|
||||
</p>
|
||||
</c:if>
|
||||
<c:if test="${synonymPager.allRecordCount > 0}">
|
||||
<table class="bordered-table zebra-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center;"><bean:message
|
||||
key="labels.dict_synonym_source" /></th>
|
||||
<th style="text-align: center;"><bean:message
|
||||
key="labels.dict_synonym_target" /></th>
|
||||
<th style="text-align: center; width: 200px;"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach var="data" varStatus="s" items="${synonymItemItems}">
|
||||
<tr class="${s.index % 2 == 0 ? 'row1' : 'row2'}">
|
||||
<td>${f:h(data.inputs)}</td>
|
||||
<td>${f:h(data.outputs)}</td>
|
||||
<td style="text-align: center;"><s:link
|
||||
href="confirmpage/${f:u(dictId)}/4/${f:u(data.id)}">
|
||||
<bean:message key="labels.dict_link_details" />
|
||||
</s:link> <s:link href="editpage/${f:u(dictId)}/2/${f:u(data.id)}">
|
||||
<bean:message key="labels.dict_link_edit" />
|
||||
</s:link> <s:link href="deletepage/${f:u(dictId)}/3/${f:u(data.id)}">
|
||||
<bean:message key="labels.dict_link_delete" />
|
||||
</s:link></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<%-- Page Navigation: BEGIN --%>
|
||||
<div class="row center">
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<c:if test="${synonymPager.existPrePage}">
|
||||
<li class="prev"><s:link
|
||||
href="list/${f:u(dictId)}/${synonymPager.currentPageNumber - 1}">
|
||||
<bean:message key="labels.dict_link_prev_page" />
|
||||
</s:link></li>
|
||||
</c:if>
|
||||
<c:if test="${!synonymPager.existPrePage}">
|
||||
<li class="prev disabled"><a href="#"><bean:message
|
||||
key="labels.dict_link_prev_page" /></a></li>
|
||||
</c:if>
|
||||
<c:forEach var="p" varStatus="s"
|
||||
items="${synonymPager.pageNumberList}">
|
||||
<li
|
||||
<c:if test="${p == synonymPager.currentPageNumber}">class="active"</c:if>>
|
||||
<s:link href="list/${f:u(dictId)}/${p}">${p}</s:link>
|
||||
</li>
|
||||
</c:forEach>
|
||||
<c:if test="${synonymPager.existNextPage}">
|
||||
<li class="next disabled"><s:link
|
||||
href="list/${f:u(dictId)}/${synonymPager.currentPageNumber + 1}">
|
||||
<bean:message key="labels.dict_link_next_page" />
|
||||
</s:link></li>
|
||||
</c:if>
|
||||
<c:if test="${!synonymPager.existNextPage}">
|
||||
<li class="next disabled"><a href="#"><bean:message
|
||||
key="labels.dict_link_next_page" /></a></li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span><bean:message key="labels.pagination_page_guide_msg"
|
||||
arg0="${f:h(synonymPager.currentPageNumber)}"
|
||||
arg1="${f:h(synonymPager.allPageCount)}"
|
||||
arg2="${f:h(synonymPager.allRecordCount)}" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<%-- Page Navigation: END --%>
|
||||
</c:if>
|
||||
</div>
|
||||
<%-- List: END --%>
|
||||
|
||||
</tiles:put>
|
||||
</tiles:insert>
|
|
@ -16,7 +16,7 @@
|
|||
<bean:message key="labels.header.help" />
|
||||
</s:link></li>
|
||||
</c:if>
|
||||
<li><s:link href="../logout">
|
||||
<li><s:link href="${contextPath}/admin/logout">
|
||||
<bean:message key="labels.menu.logout" />
|
||||
</s:link></li>
|
||||
</ul>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<c:if test="${menuType=='wizard'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../wizard/index">
|
||||
<s:link href="${contextPath}/admin/wizard/index">
|
||||
<bean:message key="labels.menu.wizard" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='wizard'}">
|
||||
|
@ -18,7 +18,7 @@
|
|||
<c:if test="${menuType=='crawl'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../crawl/index">
|
||||
<s:link href="${contextPath}/admin/crawl/index">
|
||||
<bean:message key="labels.menu.crawl_config" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='crawl'}">
|
||||
|
@ -28,7 +28,7 @@
|
|||
<c:if test="${menuType=='system'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../system/index">
|
||||
<s:link href="${contextPath}/admin/system/index">
|
||||
<bean:message key="labels.menu.system_config" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='system'}">
|
||||
|
@ -38,7 +38,7 @@
|
|||
<c:if test="${menuType=='document'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../document/index">
|
||||
<s:link href="${contextPath}/admin/document/index">
|
||||
<bean:message key="labels.menu.document_config" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='document'}">
|
||||
|
@ -48,7 +48,7 @@
|
|||
<c:if test="${menuType=='scheduledJob'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../scheduledJob/index">
|
||||
<s:link href="${contextPath}/admin/scheduledJob/index">
|
||||
<bean:message key="labels.menu.scheduled_job_config" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='scheduledJob'}">
|
||||
|
@ -58,17 +58,27 @@
|
|||
<c:if test="${menuType=='design'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../design/index">
|
||||
<s:link href="${contextPath}/admin/design/index">
|
||||
<bean:message key="labels.menu.design" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='design'}">
|
||||
</span>
|
||||
</c:if>
|
||||
<br />
|
||||
<c:if test="${menuType=='dict'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="${contextPath}/admin/dict/index">
|
||||
<bean:message key="labels.menu.dict" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='dict'}">
|
||||
</span>
|
||||
</c:if>
|
||||
<br />
|
||||
<c:if test="${menuType=='data'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../data/index">
|
||||
<s:link href="${contextPath}/admin/data/index">
|
||||
<bean:message key="labels.menu.data" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='data'}">
|
||||
|
@ -83,7 +93,7 @@
|
|||
<c:if test="${menuType=='webCrawlingConfig'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../webCrawlingConfig/index">
|
||||
<s:link href="${contextPath}/admin/webCrawlingConfig/index">
|
||||
<bean:message key="labels.menu.web" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='webCrawlingConfig'}">
|
||||
|
@ -93,7 +103,7 @@
|
|||
<c:if test="${menuType=='fileCrawlingConfig'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../fileCrawlingConfig/index">
|
||||
<s:link href="${contextPath}/admin/fileCrawlingConfig/index">
|
||||
<bean:message key="labels.menu.file_system" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='fileCrawlingConfig'}">
|
||||
|
@ -103,7 +113,7 @@
|
|||
<c:if test="${menuType=='dataCrawlingConfig'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../dataCrawlingConfig/index">
|
||||
<s:link href="${contextPath}/admin/dataCrawlingConfig/index">
|
||||
<bean:message key="labels.menu.data_store" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='dataCrawlingConfig'}">
|
||||
|
@ -113,7 +123,7 @@
|
|||
<c:if test="${menuType=='labelType'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../labelType/index">
|
||||
<s:link href="${contextPath}/admin/labelType/index">
|
||||
<bean:message key="labels.menu.label_type" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='labelType'}">
|
||||
|
@ -123,7 +133,7 @@
|
|||
<c:if test="${menuType=='pathMapping'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../pathMapping/index">
|
||||
<s:link href="${contextPath}/admin/pathMapping/index">
|
||||
<bean:message key="labels.menu.path_mapping" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='pathMapping'}">
|
||||
|
@ -133,7 +143,7 @@
|
|||
<c:if test="${menuType=='webAuthentication'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../webAuthentication/index">
|
||||
<s:link href="${contextPath}/admin/webAuthentication/index">
|
||||
<bean:message key="labels.menu.web_authentication" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='webAuthentication'}">
|
||||
|
@ -143,7 +153,7 @@
|
|||
<c:if test="${menuType=='fileAuthentication'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../fileAuthentication/index">
|
||||
<s:link href="${contextPath}/admin/fileAuthentication/index">
|
||||
<bean:message key="labels.menu.file_authentication" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='fileAuthentication'}">
|
||||
|
@ -153,7 +163,7 @@
|
|||
<c:if test="${menuType=='requestHeader'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../requestHeader/index">
|
||||
<s:link href="${contextPath}/admin/requestHeader/index">
|
||||
<bean:message key="labels.menu.request_header" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='requestHeader'}">
|
||||
|
@ -163,7 +173,7 @@
|
|||
<c:if test="${menuType=='overlappingHost'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../overlappingHost/index">
|
||||
<s:link href="${contextPath}/admin/overlappingHost/index">
|
||||
<bean:message key="labels.menu.overlapping_host" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='overlappingHost'}">
|
||||
|
@ -173,7 +183,7 @@
|
|||
<c:if test="${menuType=='roleType'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../roleType/index">
|
||||
<s:link href="${contextPath}/admin/roleType/index">
|
||||
<bean:message key="labels.menu.role_type" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='roleType'}">
|
||||
|
@ -183,7 +193,7 @@
|
|||
<c:if test="${menuType=='browserType'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../browserType/index">
|
||||
<s:link href="${contextPath}/admin/browserType/index">
|
||||
<bean:message key="labels.menu.supported_browser" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='browserType'}">
|
||||
|
@ -198,7 +208,7 @@
|
|||
<c:if test="${menuType=='systemInfo'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../systemInfo/index">
|
||||
<s:link href="${contextPath}/admin/systemInfo/index">
|
||||
<bean:message key="labels.menu.system_info" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='systemInfo'}">
|
||||
|
@ -208,7 +218,7 @@
|
|||
<c:if test="${menuType=='jobLog'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../jobLog/index">
|
||||
<s:link href="${contextPath}/admin/jobLog/index">
|
||||
<bean:message key="labels.menu.jobLog" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='jobLog'}">
|
||||
|
@ -218,7 +228,7 @@
|
|||
<c:if test="${menuType=='crawlingSession'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../crawlingSession/index">
|
||||
<s:link href="${contextPath}/admin/crawlingSession/index">
|
||||
<bean:message key="labels.menu.session_info" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='crawlingSession'}">
|
||||
|
@ -228,7 +238,7 @@
|
|||
<c:if test="${menuType=='log'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../log/index">
|
||||
<s:link href="${contextPath}/admin/log/index">
|
||||
<bean:message key="labels.menu.log" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='log'}">
|
||||
|
@ -238,7 +248,7 @@
|
|||
<c:if test="${menuType=='failureUrl'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../failureUrl/index">
|
||||
<s:link href="${contextPath}/admin/failureUrl/index">
|
||||
<bean:message key="labels.menu.failure_url" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='failureUrl'}">
|
||||
|
@ -248,7 +258,7 @@
|
|||
<c:if test="${menuType=='searchList'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../searchList/index">
|
||||
<s:link href="${contextPath}/admin/searchList/index">
|
||||
<bean:message key="labels.menu.search_list" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='searchList'}">
|
||||
|
@ -263,7 +273,7 @@
|
|||
<c:if test="${menuType=='searchLog'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../searchLog/index">
|
||||
<s:link href="${contextPath}/admin/searchLog/index">
|
||||
<bean:message key="labels.menu.search_log" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='searchLog'}">
|
||||
|
@ -273,7 +283,7 @@
|
|||
<c:if test="${menuType=='stats'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../stats/index">
|
||||
<s:link href="${contextPath}/admin/stats/index">
|
||||
<bean:message key="labels.menu.stats" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='stats'}">
|
||||
|
@ -283,7 +293,7 @@
|
|||
<c:if test="${menuType=='userInfo'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../userInfo/index">
|
||||
<s:link href="${contextPath}/admin/userInfo/index">
|
||||
<bean:message key="labels.menu.user" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='userInfo'}">
|
||||
|
@ -293,7 +303,7 @@
|
|||
<c:if test="${menuType=='favoriteLog'}">
|
||||
<span class="selected">
|
||||
</c:if>
|
||||
<s:link href="../favoriteLog/index">
|
||||
<s:link href="${contextPath}/admin/favoriteLog/index">
|
||||
<bean:message key="labels.menu.favoriteLog" />
|
||||
</s:link>
|
||||
<c:if test="${menuType=='favoriteLog'}">
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
--%><%@taglib prefix="s" uri="http://sastruts.seasar.org" %><%--
|
||||
--%><%@taglib prefix="f" uri="http://sastruts.seasar.org/functions" %><%--
|
||||
--%><%@taglib prefix="m" uri="http://taglibs.mobylet.org/" %><%--
|
||||
--%><%@taglib prefix="fe" uri="http://fess.codelibs.org/functions" %>
|
||||
--%><%@taglib prefix="fe" uri="http://fess.codelibs.org/functions" %><%--
|
||||
--%><c:set var="contextPath" value="${request.contextPath}"/>
|
76
src/test/java/jp/sf/fess/dict/DictionaryManagerTest.java
Normal file
76
src/test/java/jp/sf/fess/dict/DictionaryManagerTest.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.dict;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.dict.synonym.SynonymLocator;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class DictionaryManagerTest extends S2TestCase {
|
||||
|
||||
private File testDir;
|
||||
|
||||
private File synonymFile1;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
testDir = File.createTempFile("synonymtest", "_dir");
|
||||
testDir.delete();
|
||||
testDir.mkdirs();
|
||||
synonymFile1 = new File(testDir, "synonym.txt");
|
||||
FileUtil.write(synonymFile1.getAbsolutePath(),
|
||||
"abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
|
||||
public void test_getSynonymFiles() throws Exception {
|
||||
final DictionaryManager dictionaryManager = new DictionaryManager();
|
||||
dictionaryManager.keepAlive = 1000;
|
||||
dictionaryManager.watcherTimeout = 1;
|
||||
final SynonymLocator synonymLocator = new SynonymLocator();
|
||||
synonymLocator.excludedSynonymList = new ArrayList<String>();
|
||||
synonymLocator.excludedSynonymList.add("data");
|
||||
synonymLocator.addSearchPath(testDir.getAbsolutePath());
|
||||
dictionaryManager.addLocator(synonymLocator);
|
||||
dictionaryManager.init();
|
||||
final DictionaryFile<? extends DictionaryItem>[] synonymFiles = dictionaryManager
|
||||
.getDictionaryFiles();
|
||||
assertEquals(1, synonymFiles.length);
|
||||
|
||||
assertNotNull(dictionaryManager.dicFileMap);
|
||||
Thread.sleep(2000);
|
||||
assertNull(dictionaryManager.dicFileMap);
|
||||
|
||||
final DictionaryFile<? extends DictionaryItem>[] synonymFiles2 = dictionaryManager
|
||||
.getDictionaryFiles();
|
||||
assertEquals(1, synonymFiles2.length);
|
||||
|
||||
assertNotNull(dictionaryManager.dicFileMap);
|
||||
Thread.sleep(2000);
|
||||
assertNull(dictionaryManager.dicFileMap);
|
||||
}
|
||||
}
|
188
src/test/java/jp/sf/fess/dict/synonym/SynonymFileTest.java
Normal file
188
src/test/java/jp/sf/fess/dict/synonym/SynonymFileTest.java
Normal file
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.dict.DictionaryFile.PagingList;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class SynonymFileTest extends S2TestCase {
|
||||
|
||||
private File file1;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
file1 = File.createTempFile("synonym", ".txt");
|
||||
FileUtil.write(file1.getAbsolutePath(),
|
||||
"a1=>A1\nb1,b2 => B1\nc1 => C1, C2\nx1,X1\ny1, Y1, y2"
|
||||
.getBytes(Constants.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
file1.delete();
|
||||
}
|
||||
|
||||
public void test_selectList() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
assertEquals(5, itemList1.getAllRecordCount());
|
||||
assertEquals(1, itemList1.getCurrentPageNumber());
|
||||
assertEquals(20, itemList1.getPageSize());
|
||||
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(4, 2);
|
||||
assertEquals(1, itemList2.size());
|
||||
assertEquals(5, itemList2.getAllRecordCount());
|
||||
assertEquals(3, itemList2.getCurrentPageNumber());
|
||||
assertEquals(2, itemList2.getPageSize());
|
||||
|
||||
assertEquals(0, synonymFile.selectList(5, 5).size());
|
||||
assertEquals(0, synonymFile.selectList(-1, 5).size());
|
||||
}
|
||||
|
||||
public void test_selectList2() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList = synonymFile.selectList(0, 5);
|
||||
assertEquals(1, itemList.get(0).getInputs().length);
|
||||
assertEquals(1, itemList.get(0).getOutputs().length);
|
||||
assertEquals("a1", itemList.get(0).getInputs()[0]);
|
||||
assertEquals("A1", itemList.get(0).getOutputs()[0]);
|
||||
assertFalse(itemList.get(0).isUpdated());
|
||||
|
||||
assertEquals(2, itemList.get(1).getInputs().length);
|
||||
assertEquals(1, itemList.get(1).getOutputs().length);
|
||||
assertEquals("b1", itemList.get(1).getInputs()[0]);
|
||||
assertEquals("b2", itemList.get(1).getInputs()[1]);
|
||||
assertEquals("B1", itemList.get(1).getOutputs()[0]);
|
||||
assertFalse(itemList.get(1).isUpdated());
|
||||
|
||||
assertEquals(1, itemList.get(2).getInputs().length);
|
||||
assertEquals(2, itemList.get(2).getOutputs().length);
|
||||
assertEquals("c1", itemList.get(2).getInputs()[0]);
|
||||
assertEquals("C1", itemList.get(2).getOutputs()[0]);
|
||||
assertEquals("C2", itemList.get(2).getOutputs()[1]);
|
||||
assertFalse(itemList.get(2).isUpdated());
|
||||
|
||||
assertEquals(2, itemList.get(3).getInputs().length);
|
||||
assertEquals(2, itemList.get(3).getOutputs().length);
|
||||
assertEquals("X1", itemList.get(3).getInputs()[0]);
|
||||
assertEquals("x1", itemList.get(3).getInputs()[1]);
|
||||
assertEquals("X1", itemList.get(3).getOutputs()[0]);
|
||||
assertEquals("x1", itemList.get(3).getOutputs()[1]);
|
||||
assertFalse(itemList.get(3).isUpdated());
|
||||
|
||||
assertEquals(3, itemList.get(4).getInputs().length);
|
||||
assertEquals(3, itemList.get(4).getOutputs().length);
|
||||
assertEquals("Y1", itemList.get(4).getInputs()[0]);
|
||||
assertEquals("y1", itemList.get(4).getInputs()[1]);
|
||||
assertEquals("y2", itemList.get(4).getInputs()[2]);
|
||||
assertEquals("Y1", itemList.get(4).getOutputs()[0]);
|
||||
assertEquals("y1", itemList.get(4).getOutputs()[1]);
|
||||
assertEquals("y2", itemList.get(4).getOutputs()[2]);
|
||||
assertFalse(itemList.get(4).isUpdated());
|
||||
}
|
||||
|
||||
public void test_insert() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = new SynonymItem(0, new String[] {
|
||||
"z1", "z2" }, new String[] { "Z1", "Z2" });
|
||||
synonymFile.insert(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(6, itemList2.size());
|
||||
assertEquals("z1", itemList2.get(5).getInputs()[0]);
|
||||
assertEquals("z2", itemList2.get(5).getInputs()[1]);
|
||||
assertEquals("Z1", itemList2.get(5).getOutputs()[0]);
|
||||
assertEquals("Z2", itemList2.get(5).getOutputs()[1]);
|
||||
|
||||
final SynonymItem synonymItem2 = new SynonymItem(0, new String[] {
|
||||
"z1", "z2" }, new String[] { "z1", "z2" });
|
||||
synonymFile.insert(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(7, itemList3.size());
|
||||
assertEquals("z1", itemList3.get(6).getInputs()[0]);
|
||||
assertEquals("z2", itemList3.get(6).getInputs()[1]);
|
||||
assertEquals("z1", itemList3.get(6).getOutputs()[0]);
|
||||
assertEquals("z2", itemList3.get(6).getOutputs()[1]);
|
||||
}
|
||||
|
||||
public void test_update() {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymItem1.setNewInputs(new String[] { "a1", "a2" });
|
||||
synonymItem1.setNewOutputs(new String[] { "A1", "A2" });
|
||||
synonymFile.update(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList2.size());
|
||||
final SynonymItem synonymItem2 = itemList2.get(0);
|
||||
assertEquals(2, synonymItem2.getInputs().length);
|
||||
assertEquals(2, synonymItem2.getOutputs().length);
|
||||
assertEquals("a1", synonymItem2.getInputs()[0]);
|
||||
assertEquals("a2", synonymItem2.getInputs()[1]);
|
||||
assertEquals("A1", synonymItem2.getOutputs()[0]);
|
||||
assertEquals("A2", synonymItem2.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
|
||||
final SynonymItem synonymItem3 = itemList2.get(2);
|
||||
synonymItem3.setNewInputs(new String[] { "c1", "c2" });
|
||||
synonymItem3.setNewOutputs(new String[] { "c1", "c2" });
|
||||
synonymFile.update(synonymItem3);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList3.size());
|
||||
final SynonymItem synonymItem4 = itemList3.get(2);
|
||||
assertEquals(2, synonymItem4.getInputs().length);
|
||||
assertEquals(2, synonymItem4.getOutputs().length);
|
||||
assertEquals("c1", synonymItem4.getInputs()[0]);
|
||||
assertEquals("c2", synonymItem4.getInputs()[1]);
|
||||
assertEquals("c1", synonymItem4.getOutputs()[0]);
|
||||
assertEquals("c2", synonymItem4.getOutputs()[1]);
|
||||
assertFalse(synonymItem2.isUpdated());
|
||||
}
|
||||
|
||||
public void test_delete() throws Exception {
|
||||
final SynonymFile synonymFile = new SynonymFile(file1);
|
||||
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
|
||||
assertEquals(5, itemList1.size());
|
||||
|
||||
final SynonymItem synonymItem1 = itemList1.get(0);
|
||||
synonymFile.delete(synonymItem1);
|
||||
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
|
||||
assertEquals(4, itemList2.size());
|
||||
|
||||
final SynonymItem synonymItem2 = itemList2.get(3);
|
||||
synonymFile.delete(synonymItem2);
|
||||
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
|
||||
assertEquals(3, itemList3.size());
|
||||
|
||||
assertEquals(
|
||||
"b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2"
|
||||
+ Constants.LINE_SEPARATOR + "X1,x1"
|
||||
+ Constants.LINE_SEPARATOR,
|
||||
new String(FileUtil.getBytes(file1), Constants.UTF_8));
|
||||
|
||||
}
|
||||
}
|
122
src/test/java/jp/sf/fess/dict/synonym/SynonymItemTest.java
Normal file
122
src/test/java/jp/sf/fess/dict/synonym/SynonymItemTest.java
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.dict.synonym;
|
||||
|
||||
import jp.sf.fess.dict.synonym.SynonymItem;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class SynonymItemTest extends S2TestCase {
|
||||
|
||||
public void test_new1() {
|
||||
final SynonymItem synonymItem = new SynonymItem(1, new String[] { "a",
|
||||
"A" }, new String[] { "b", "B" });
|
||||
assertEquals(1, synonymItem.getId());
|
||||
assertEquals(2, synonymItem.getInputs().length);
|
||||
assertEquals("A", synonymItem.getInputs()[0]);
|
||||
assertEquals("a", synonymItem.getInputs()[1]);
|
||||
assertEquals(2, synonymItem.getOutputs().length);
|
||||
assertEquals("B", synonymItem.getOutputs()[0]);
|
||||
assertEquals("b", synonymItem.getOutputs()[1]);
|
||||
assertNull(synonymItem.getNewInputs());
|
||||
assertNull(synonymItem.getNewOutputs());
|
||||
assertFalse(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[] { "1", "2" });
|
||||
synonymItem.setNewOutputs(new String[] { "3", "4" });
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[0]);
|
||||
synonymItem.setNewOutputs(new String[0]);
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertTrue(synonymItem.isDeleted());
|
||||
}
|
||||
|
||||
public void test_new2() {
|
||||
final SynonymItem synonymItem = new SynonymItem(1, new String[] { "A",
|
||||
"a" }, new String[] { "B", "b" });
|
||||
assertEquals(1, synonymItem.getId());
|
||||
assertEquals(2, synonymItem.getInputs().length);
|
||||
assertEquals("A", synonymItem.getInputs()[0]);
|
||||
assertEquals("a", synonymItem.getInputs()[1]);
|
||||
assertEquals(2, synonymItem.getOutputs().length);
|
||||
assertEquals("B", synonymItem.getOutputs()[0]);
|
||||
assertEquals("b", synonymItem.getOutputs()[1]);
|
||||
assertNull(synonymItem.getNewInputs());
|
||||
assertNull(synonymItem.getNewOutputs());
|
||||
assertFalse(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[] { "2", "1" });
|
||||
synonymItem.setNewOutputs(new String[] { "4", "3" });
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertFalse(synonymItem.isDeleted());
|
||||
|
||||
synonymItem.setNewInputs(new String[0]);
|
||||
synonymItem.setNewOutputs(new String[0]);
|
||||
assertTrue(synonymItem.isUpdated());
|
||||
assertTrue(synonymItem.isDeleted());
|
||||
}
|
||||
|
||||
public void test_equals1() {
|
||||
final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a",
|
||||
"A" }, new String[] { "b", "B" });
|
||||
|
||||
assertTrue(synonymItem1.equals(synonymItem1));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "A",
|
||||
"a" }, new String[] { "B", "b" })));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(2, new String[] { "A",
|
||||
"a" }, new String[] { "B", "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A",
|
||||
"a" }, new String[] { "B", })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2,
|
||||
new String[] { "A" }, new String[] { "B", "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A",
|
||||
"a" }, new String[] { "B", "c" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A",
|
||||
"c" }, new String[] { "B", "b" })));
|
||||
}
|
||||
|
||||
public void test_equals2() {
|
||||
final SynonymItem synonymItem1 = new SynonymItem(1,
|
||||
new String[] { "a" }, new String[] { "b" });
|
||||
|
||||
assertTrue(synonymItem1.equals(synonymItem1));
|
||||
assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "a" },
|
||||
new String[] { "b" })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2,
|
||||
new String[] { "a" }, new String[] { "B", })));
|
||||
assertFalse(synonymItem1.equals(new SynonymItem(2,
|
||||
new String[] { "A" }, new String[] { "b" })));
|
||||
}
|
||||
|
||||
public void test_toLineString() {
|
||||
assertEquals("a1,a2,a3=>b1,b2,b3",
|
||||
new SynonymItem(1, new String[] { "a1", "a2", "a3" },
|
||||
new String[] { "b1", "b2", "b3" }).toLineString());
|
||||
assertEquals("a=>b", new SynonymItem(1, new String[] { "a" },
|
||||
new String[] { "b" }).toLineString());
|
||||
assertEquals("A,a=>B,b", new SynonymItem(1, new String[] { "a", "A" },
|
||||
new String[] { "b", "B" }).toLineString());
|
||||
assertEquals("A,a", new SynonymItem(1, new String[] { "a", "A" },
|
||||
new String[] { "a", "A" }).toLineString());
|
||||
assertEquals("a", new SynonymItem(1, new String[] { "a" },
|
||||
new String[] { "a" }).toLineString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.dict.synonym;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jp.sf.fess.Constants;
|
||||
import jp.sf.fess.dict.DictionaryFile;
|
||||
import jp.sf.fess.dict.DictionaryItem;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
import org.seasar.framework.util.FileUtil;
|
||||
|
||||
public class SynonymLocatorTest extends S2TestCase {
|
||||
|
||||
private File testDir;
|
||||
|
||||
private File testDataDir;
|
||||
|
||||
private File testCoreDir;
|
||||
|
||||
private File synonymFile1;
|
||||
|
||||
private File synonymFile2;
|
||||
|
||||
private File synonymFile3;
|
||||
|
||||
private File dummyFile1;
|
||||
|
||||
private File dummyFile2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
testDir = File.createTempFile("synonymtest", "_dir");
|
||||
testDir.delete();
|
||||
testDir.mkdirs();
|
||||
testDataDir = new File(testDir, "data");
|
||||
testDataDir.mkdirs();
|
||||
testCoreDir = new File(testDir, "core");
|
||||
testCoreDir.mkdirs();
|
||||
synonymFile1 = new File(testDir, "synonym.txt");
|
||||
FileUtil.write(synonymFile1.getAbsolutePath(),
|
||||
"abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
synonymFile2 = new File(testDataDir, "synonym_data.txt");
|
||||
FileUtil.write(synonymFile2.getAbsolutePath(),
|
||||
"abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
synonymFile3 = new File(testCoreDir, "synonym_core.txt");
|
||||
FileUtil.write(synonymFile3.getAbsolutePath(),
|
||||
"abc=>123\nxyz,890".getBytes(Constants.UTF_8));
|
||||
dummyFile1 = new File(testDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile1.getAbsolutePath(),
|
||||
"dummy 1".getBytes(Constants.UTF_8));
|
||||
dummyFile2 = new File(testCoreDir, "dummy.txt");
|
||||
FileUtil.write(dummyFile2.getAbsolutePath(),
|
||||
"dummy 2".getBytes(Constants.UTF_8));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
|
||||
public void test_find() {
|
||||
final SynonymLocator synonymLocator = new SynonymLocator();
|
||||
synonymLocator.excludedSynonymList = new ArrayList<String>();
|
||||
synonymLocator.excludedSynonymList.add("data");
|
||||
synonymLocator.addSearchPath(testDir.getAbsolutePath());
|
||||
final List<DictionaryFile<? extends DictionaryItem>> list = synonymLocator
|
||||
.find();
|
||||
assertEquals(2, list.size());
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile1 = list.get(0);
|
||||
final DictionaryFile<? extends DictionaryItem> dicFile2 = list.get(1);
|
||||
assertEquals(synonymFile3.getAbsolutePath(), dicFile1.getName());
|
||||
assertEquals(synonymFile1.getAbsolutePath(), dicFile2.getName());
|
||||
}
|
||||
|
||||
}
|
79
src/test/java/jp/sf/fess/util/ResourceUtilTest.java
Normal file
79
src/test/java/jp/sf/fess/util/ResourceUtilTest.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2009-2013 the Fess 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 jp.sf.fess.util;
|
||||
|
||||
import org.seasar.extension.unit.S2TestCase;
|
||||
|
||||
public class ResourceUtilTest extends S2TestCase {
|
||||
public void test_resolve() {
|
||||
String value;
|
||||
|
||||
value = null;
|
||||
assertNull(ResourceUtil.resolve(value));
|
||||
|
||||
value = "";
|
||||
assertEquals("", ResourceUtil.resolve(value));
|
||||
|
||||
value = "a";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "${a}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "$a";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "${a";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "$a}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "${abc}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
value = "${abc.xyz}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
System.setProperty("abc", "123");
|
||||
|
||||
value = "${abc}";
|
||||
assertEquals("123", ResourceUtil.resolve(value));
|
||||
|
||||
value = "xxx${abc}zzz";
|
||||
assertEquals("xxx123zzz", ResourceUtil.resolve(value));
|
||||
|
||||
value = "${abc.xyz}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
System.setProperty("abc.xyz", "789");
|
||||
|
||||
value = "${abc.xyz}";
|
||||
assertEquals("789", ResourceUtil.resolve(value));
|
||||
|
||||
value = "${abc}${abc.xyz}";
|
||||
assertEquals("123789", ResourceUtil.resolve(value));
|
||||
|
||||
value = "xxx${abc.xyz}zzz";
|
||||
assertEquals("xxx789zzz", ResourceUtil.resolve(value));
|
||||
|
||||
value = "${\\$}";
|
||||
assertEquals(value, ResourceUtil.resolve(value));
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue