Merge pull request #321 from kw-udon/lastaflute-dev
Lastaflute: suggestBadWord, systemInfo, system
This commit is contained in:
commit
30d348744c
33 changed files with 715 additions and 698 deletions
4
pom.xml
4
pom.xml
|
@ -99,7 +99,6 @@
|
|||
<exclude>org/codelibs/fess/app/web/admin/dict/UserDictAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/dict/SynonymAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DocumentAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SystemInfoForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/JobLogForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SystemAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DictForm.java</exclude>
|
||||
|
@ -108,17 +107,14 @@
|
|||
<exclude>org/codelibs/fess/app/web/admin/SuggestElevateWordForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DocumentForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DataForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SuggestBadWordAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/IndexAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/LogAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/FailureUrlAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DictAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SuggestElevateWordAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/LogForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SystemInfoAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DataAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/CrawlingSessionAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SuggestBadWordForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/CrawlingSessionForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/WizardForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/FailureUrlForm.java</exclude>
|
||||
|
|
|
@ -1,453 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.core.io.CopyUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.FessSystemException;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.es.exentity.SuggestBadWord;
|
||||
import org.codelibs.fess.exception.SSCActionMessagesException;
|
||||
import org.codelibs.fess.helper.SuggestHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.app.pager.SuggestBadWordPager;
|
||||
import org.codelibs.fess.app.service.SuggestBadWordService;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SuggestBadWordAction extends FessAdminAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SuggestBadWordAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<SuggestBadWord> suggestBadWordItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
//@ActionForm
|
||||
@Resource
|
||||
protected SuggestBadWordForm suggestBadWordForm;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordService suggestBadWordService;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordPager suggestBadWordPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected SuggestHelper suggestHelper;
|
||||
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
suggestBadWordItems = suggestBadWordService.getSuggestBadWordList(suggestBadWordPager);
|
||||
|
||||
// restore from pager
|
||||
BeanUtil.copyBeanToBean(suggestBadWordPager, suggestBadWordForm.searchParams,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
if (redirect) {
|
||||
return "index?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/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(suggestBadWordForm.pageNumber)) {
|
||||
try {
|
||||
suggestBadWordPager.setCurrentPageNumber(Integer.parseInt(suggestBadWordForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + suggestBadWordForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
BeanUtil.copyBeanToBean(suggestBadWordForm.searchParams, suggestBadWordPager,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
suggestBadWordPager.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/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (suggestBadWordForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
suggestBadWordForm.initialize();
|
||||
suggestBadWordForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (suggestBadWordForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
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/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", suggestBadWordForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("suggestBadWord");
|
||||
}
|
||||
|
||||
protected void loadSuggestBadWord() {
|
||||
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id });
|
||||
}
|
||||
|
||||
BeanUtil.copyBeanToBean(suggestBadWord, suggestBadWordForm, option -> option.exclude("searchParams", "mode"));
|
||||
}
|
||||
|
||||
protected SuggestBadWord createSuggestBadWord() {
|
||||
SuggestBadWord suggestBadWord;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (suggestBadWordForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id });
|
||||
}
|
||||
} else {
|
||||
suggestBadWord = new SuggestBadWord();
|
||||
suggestBadWord.setCreatedBy(username);
|
||||
suggestBadWord.setCreatedTime(currentTime);
|
||||
}
|
||||
suggestBadWord.setUpdatedBy(username);
|
||||
suggestBadWord.setUpdatedTime(currentTime);
|
||||
BeanUtil.copyBeanToBean(suggestBadWordForm, suggestBadWord, option -> option.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id });
|
||||
}
|
||||
|
||||
suggestBadWordService.delete(suggestBadWord);
|
||||
suggestHelper.deleteAllBadWord();
|
||||
suggestHelper.updateSolrBadwordFile();
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SuggestBadWord suggestBadWord = createSuggestBadWord();
|
||||
suggestBadWordService.store(suggestBadWord);
|
||||
suggestHelper.deleteAllBadWord();
|
||||
suggestHelper.updateSolrBadwordFile();
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.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 SuggestBadWord suggestBadWord = createSuggestBadWord();
|
||||
suggestBadWordService.store(suggestBadWord);
|
||||
suggestHelper.deleteAllBadWord();
|
||||
suggestHelper.updateSolrBadwordFile();
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "downloadpage")
|
||||
public String downloadpage() {
|
||||
return "download.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = false, input = "downloadpage")
|
||||
public String download() {
|
||||
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\"");
|
||||
|
||||
try (Writer writer =
|
||||
new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty(
|
||||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestBadWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to export data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_export_data");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "uploadpage")
|
||||
public String uploadpage() {
|
||||
return "upload.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "uploadpage")
|
||||
public String upload() {
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
final byte[] b = new byte[20];
|
||||
try {
|
||||
tempFile = File.createTempFile("suggestbadword-import-", ".csv");
|
||||
is = new BufferedInputStream(suggestBadWordForm.suggestBadWordFile.getInputStream());
|
||||
is.mark(20);
|
||||
if (is.read(b, 0, 20) <= 0) {
|
||||
throw new FessSystemException("no import data.");
|
||||
}
|
||||
is.reset();
|
||||
fos = new FileOutputStream(tempFile);
|
||||
CopyUtil.copy(is, fos);
|
||||
} catch (final Exception e) {
|
||||
if (tempFile != null && !tempFile.delete()) {
|
||||
logger.warn("Could not delete " + tempFile.getAbsolutePath());
|
||||
}
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(fos);
|
||||
}
|
||||
|
||||
final File oFile = tempFile;
|
||||
try {
|
||||
final String head = new String(b, Constants.UTF_8);
|
||||
if (!(head.startsWith("\"BadWord\"") || head.startsWith("BadWord"))) {
|
||||
logger.error("Unknown file: " + suggestBadWordForm.suggestBadWordFile);
|
||||
throw new SSCActionMessagesException("errors.unknown_import_file");
|
||||
}
|
||||
final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
|
||||
new Thread(() -> {
|
||||
Reader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc));
|
||||
suggestBadWordService.importCsv(reader);
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new FessSystemException("Failed to import data.", e);
|
||||
} finally {
|
||||
if (!oFile.delete()) {
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
suggestHelper.deleteAllBadWord();
|
||||
suggestHelper.updateSolrBadwordFile();
|
||||
}
|
||||
}).start();
|
||||
} catch (final ActionMessagesException e) {
|
||||
if (!oFile.delete()) {
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
if (!oFile.delete()) {
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.upload_suggest_bad_word");
|
||||
|
||||
return "uploadpage?redirect=true";
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
|
||||
public class SystemInfoAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@ActionForm
|
||||
@Resource
|
||||
protected SystemInfoForm systemInfoForm;
|
||||
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
public List<Map<String, String>> envItems;
|
||||
|
||||
public List<Map<String, String>> propItems;
|
||||
|
||||
public List<Map<String, String>> fessPropItems;
|
||||
|
||||
public List<Map<String, String>> bugReportItems;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("systemInfo");
|
||||
}
|
||||
|
||||
//@Execute(validator = false)
|
||||
public String index() {
|
||||
envItems = new ArrayList<Map<String, String>>();
|
||||
propItems = new ArrayList<Map<String, String>>();
|
||||
fessPropItems = new ArrayList<Map<String, String>>();
|
||||
bugReportItems = new ArrayList<Map<String, String>>();
|
||||
|
||||
for (final Map.Entry<String, String> entry : System.getenv().entrySet()) {
|
||||
envItems.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
|
||||
propItems.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
for (final Map.Entry<Object, Object> entry : crawlerProperties.entrySet()) {
|
||||
fessPropItems.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
bugReportItems.add(createPropItem("file.separator"));
|
||||
bugReportItems.add(createPropItem("file.encoding"));
|
||||
bugReportItems.add(createPropItem("java.runtime.version"));
|
||||
bugReportItems.add(createPropItem("java.vm.info"));
|
||||
bugReportItems.add(createPropItem("java.vm.name"));
|
||||
bugReportItems.add(createPropItem("java.vm.vendor"));
|
||||
bugReportItems.add(createPropItem("java.vm.version"));
|
||||
bugReportItems.add(createPropItem("os.arch"));
|
||||
bugReportItems.add(createPropItem("os.name"));
|
||||
bugReportItems.add(createPropItem("os.version"));
|
||||
bugReportItems.add(createPropItem("user.country"));
|
||||
bugReportItems.add(createPropItem("user.language"));
|
||||
bugReportItems.add(createPropItem("user.timezone"));
|
||||
for (final Map.Entry<Object, Object> entry : crawlerProperties.entrySet()) {
|
||||
if (isBugReportTarget(entry.getKey())) {
|
||||
bugReportItems.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
return "index.jsp";
|
||||
}
|
||||
|
||||
private boolean isBugReportTarget(final Object key) {
|
||||
if ("snapshot.path".equals(key) || "label.value".equals(key)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<String, String> createPropItem(final String key) {
|
||||
return createItem(key, System.getProperty(key));
|
||||
}
|
||||
|
||||
private Map<String, String> createItem(final Object label, final Object value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label != null ? label.toString() : StringUtil.EMPTY);
|
||||
map.put(Constants.ITEM_VALUE, value != null ? value.toString() : StringUtil.EMPTY);
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminDataconfigAction extends FessAdminAction {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class DataConfigEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class DataConfigSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.lastaflute.web.util.LaRequestUtil;
|
|||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminFileauthenticationAction extends FessAdminAction {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileAuthenticationEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileAuthenticationSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminFileconfigAction extends FessAdminAction {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileConfigEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileConfigSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminOverlappinghostAction extends FessAdminAction {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class OverlappingHostEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class OverlappingHostSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminRoletypeAction extends FessAdminAction {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class RoleTypeEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class RoleTypeSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -0,0 +1,389 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.codelibs.core.io.CopyUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.FessSystemException;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.SuggestBadWordPager;
|
||||
import org.codelibs.fess.app.service.SuggestBadWordService;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.es.exentity.SuggestBadWord;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class AdminSuggestbadwordAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private SuggestBadWordService suggestBadWordService;
|
||||
@Resource
|
||||
private SuggestBadWordPager suggestBadWordPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("suggestBadWord"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SuggestBadWordSearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final SuggestBadWordSearchForm form) {
|
||||
suggestBadWordPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final SuggestBadWordSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, suggestBadWordPager, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SuggestBadWordSearchForm form) {
|
||||
suggestBadWordPager.clear();
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final SuggestBadWordSearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final SuggestBadWordSearchForm form) {
|
||||
data.register("suggestBadWordItems", suggestBadWordService.getSuggestBadWordList(suggestBadWordPager)); // page navi
|
||||
// restore from pager
|
||||
copyBeanToBean(suggestBadWordPager, form.searchParams, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Edit Execute
|
||||
// ============
|
||||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final SuggestBadWordEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final SuggestBadWordEditForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final SuggestBadWordEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final SuggestBadWordEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final SuggestBadWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final SuggestBadWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Download
|
||||
// -------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse downloadpage(final SuggestBadWordSearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_DownloadJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse download(final SuggestBadWordSearchForm form) {
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\"");
|
||||
try (Writer writer =
|
||||
new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty(
|
||||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestBadWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return asHtml(path_AdminSuggestbadword_DownloadJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Upload
|
||||
// -------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse uploadpage(final SuggestBadWordUploadForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_UploadJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final SuggestBadWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestBadWordService.store(createSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final SuggestBadWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestBadWordService.store(createSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final SuggestBadWordEditForm form) {
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
suggestBadWordService.delete(getSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse upload(final SuggestBadWordUploadForm form) {
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
final byte[] b = new byte[20];
|
||||
try {
|
||||
tempFile = File.createTempFile("suggestbadword-import-", ".csv");
|
||||
is = new BufferedInputStream(form.suggestBadWordFile.getInputStream());
|
||||
is.mark(20);
|
||||
if (is.read(b, 0, 20) <= 0) {
|
||||
// TODO
|
||||
}
|
||||
is.reset();
|
||||
fos = new FileOutputStream(tempFile);
|
||||
CopyUtil.copy(is, fos);
|
||||
} catch (final Exception e) {
|
||||
if (tempFile != null && !tempFile.delete()) {
|
||||
// TODO
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(fos);
|
||||
}
|
||||
|
||||
final File oFile = tempFile;
|
||||
try {
|
||||
final String head = new String(b, Constants.UTF_8);
|
||||
if (!(head.startsWith("\"SuggestWord\"") || head.startsWith("SuggestWord"))) {
|
||||
// TODO
|
||||
}
|
||||
final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
|
||||
new Thread(() -> {
|
||||
Reader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc));
|
||||
suggestBadWordService.importCsv(reader);
|
||||
} catch (final Exception e) {
|
||||
throw new FessSystemException("Failed to import data.", e);
|
||||
} finally {
|
||||
if (!oFile.delete()) {
|
||||
// TODO
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
} ).start();
|
||||
} catch (final Exception e) {
|
||||
if (!oFile.delete()) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
saveInfo(messages -> messages.addSuccessUploadSuggestBadWord(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
copyBeanToBean(getSuggestBadWord(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected SuggestBadWord getSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap(form));
|
||||
if (suggestBadWord == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
protected SuggestBadWord createSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
SuggestBadWord suggestBadWord;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CommonConstants.EDIT_MODE) {
|
||||
suggestBadWord = getSuggestBadWord(form);
|
||||
} else {
|
||||
suggestBadWord = new SuggestBadWord();
|
||||
suggestBadWord.setCreatedBy(username);
|
||||
suggestBadWord.setCreatedTime(currentTime);
|
||||
}
|
||||
suggestBadWord.setUpdatedBy(username);
|
||||
suggestBadWord.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, suggestBadWord, op -> op.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final SuggestBadWordEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final SuggestBadWordEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
@ -22,7 +22,11 @@ import java.util.Map;
|
|||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
public class SuggestBadWordForm implements Serializable {
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -45,10 +49,16 @@ public class SuggestBadWordForm implements Serializable {
|
|||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
public String suggestWord;
|
||||
|
||||
public String reading;
|
||||
|
||||
public String targetRole;
|
||||
|
||||
public String targetLabel;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@FloatType
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
@ -67,18 +77,18 @@ public class SuggestBadWordForm implements Serializable {
|
|||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
//@Required(target = "upload")
|
||||
//public FormFile suggestBadWordFile;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
suggestWord = null;
|
||||
reading = null;
|
||||
targetRole = null;
|
||||
targetLabel = null;
|
||||
boost = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
boost = "100";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordSearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordUploadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MultipartFormFile suggestBadWordFile;
|
||||
|
||||
}
|
|
@ -43,7 +43,6 @@ import org.codelibs.fess.app.service.SuggestElevateWordService;
|
|||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.es.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.helper.SuggestHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
|
@ -53,7 +52,7 @@ import org.lastaflute.web.util.LaResponseUtil;
|
|||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminSuggestelevatewordAction extends FessAdminAction {
|
||||
|
||||
|
@ -67,8 +66,6 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected SuggestHelper suggestHelper;
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -138,9 +135,7 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
public HtmlResponse createpage(final SuggestElevateWordEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -150,17 +145,13 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final SuggestElevateWordEditForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -168,9 +159,7 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
public HtmlResponse editfromconfirm(final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -180,9 +169,7 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -190,9 +177,7 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
public HtmlResponse deletefromconfirm(final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -204,27 +189,21 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -335,7 +314,6 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// TODO
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
suggestHelper.storeAllElevateWords();
|
||||
}
|
||||
} ).start();
|
||||
} catch (final Exception e) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestElevateWordEditForm implements Serializable {
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestElevateWordSearchForm implements Serializable {
|
||||
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.system;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -24,91 +23,93 @@ import javax.annotation.Resource;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.client.FessEsClient;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.app.service.ScheduledJobService;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.ScheduledJob;
|
||||
import org.codelibs.fess.helper.JobHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.app.service.ScheduledJobService;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
|
||||
public class SystemAction implements Serializable {
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminSystemAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
private static final String STARTING_CRAWL_PROCESS = "startingCrawlProcess";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@ActionForm
|
||||
@Resource
|
||||
protected SystemForm systemForm;
|
||||
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected FessEsClient fessEsClient;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
protected DynamicProperties crawlerProperties;
|
||||
@Resource
|
||||
protected JobHelper jobHelper;
|
||||
|
||||
@Resource
|
||||
protected ScheduledJobService scheduledJobService;
|
||||
|
||||
public String clusterName;
|
||||
|
||||
public String clusterStatus;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("system");
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("system"));
|
||||
}
|
||||
|
||||
protected String showIndex(final boolean redirect) {
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false)
|
||||
public String index() {
|
||||
return showIndex(false);
|
||||
// ===================================================================================
|
||||
// Index
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SystemForm form) {
|
||||
return asHtml(path_AdminSystem_IndexJsp).renderWith(data -> {
|
||||
// TODO
|
||||
// data.register("clusterName", );
|
||||
// data.register("clusterStatus", );
|
||||
data.register("crawlerRunning", isCrawlerRunning());
|
||||
data.register("runningSessionIds", getRunningSessionIds());
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "index")
|
||||
public String start() {
|
||||
// @Execute(validator = true, input = "index")
|
||||
public HtmlResponse start(final SystemForm form) {
|
||||
if (!jobHelper.isCrawlProcessRunning()) {
|
||||
final List<ScheduledJob> scheduledJobList = scheduledJobService.getCrawloerJobList();
|
||||
for (final ScheduledJob scheduledJob : scheduledJobList) {
|
||||
scheduledJob.start();
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.start_crawl_process");
|
||||
saveInfo(messages -> messages.addSuccessStartCrawlProcess(GLOBAL));
|
||||
LaRequestUtil.getRequest().getSession().setAttribute(STARTING_CRAWL_PROCESS, Boolean.TRUE);
|
||||
} else {
|
||||
SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process");
|
||||
saveInfo(messages -> messages.addErrorsFailedToStartCrawlProcess(GLOBAL));
|
||||
}
|
||||
return showIndex(true);
|
||||
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "index")
|
||||
public String stop() {
|
||||
public HtmlResponse stop(final SystemForm form) {
|
||||
if (jobHelper.isCrawlProcessRunning()) {
|
||||
if (StringUtil.isNotBlank(systemForm.sessionId)) {
|
||||
jobHelper.destroyCrawlerProcess(systemForm.sessionId);
|
||||
if (StringUtil.isNotBlank(form.sessionId)) {
|
||||
jobHelper.destroyCrawlerProcess(form.sessionId);
|
||||
} else {
|
||||
for (final String sessionId : jobHelper.getRunningSessionIdSet()) {
|
||||
jobHelper.destroyCrawlerProcess(sessionId);
|
||||
}
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.stopping_crawl_process");
|
||||
saveInfo(messages -> messages.addSuccessStoppingCrawlProcess(GLOBAL));
|
||||
} else {
|
||||
SAStrutsUtil.addSessionMessage("errors.no_running_crawl_process");
|
||||
saveInfo(messages -> messages.addErrorsNoRunningCrawlProcess(GLOBAL));
|
||||
}
|
||||
return showIndex(true);
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
public boolean isCrawlerRunning() {
|
||||
|
@ -128,4 +129,4 @@ public class SystemAction implements Serializable {
|
|||
return idSet.toArray(new String[idSet.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,10 +14,14 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.system;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SystemForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.systeminfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminSysteminfoAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
private static final String[] bugReportLabels = { "file.separator", "file.encoding", "java.runtime.version", "java.vm.info",
|
||||
"java.vm.name", "java.vm.vendor", "java.vm.version", "os.arch", "os.name", "os.version", "user.country", "user.language",
|
||||
"user.timezone" };
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("systemInfo"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Index
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SystemInfoForm form) {
|
||||
return asHtml(path_AdminSysteminfo_IndexJsp).renderWith(data -> {
|
||||
registerEnvItems(data);
|
||||
registerPropItems(data);
|
||||
registerFessPropItems(data);
|
||||
registerBugReportItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
|
||||
protected void registerEnvItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
for (final Map.Entry<String, String> entry : System.getenv().entrySet()) {
|
||||
itemList.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
data.register("envItems", itemList);
|
||||
}
|
||||
|
||||
protected void registerPropItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
|
||||
itemList.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
data.register("propItems", itemList);
|
||||
}
|
||||
|
||||
protected void registerFessPropItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
for (final Map.Entry<Object, Object> entry : crawlerProperties.entrySet()) {
|
||||
itemList.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
data.register("fessPropItems", itemList);
|
||||
}
|
||||
|
||||
protected void registerBugReportItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
for (final String label : bugReportLabels) {
|
||||
itemList.add(createPropItem(label));
|
||||
}
|
||||
|
||||
for (final Map.Entry<Object, Object> entry : crawlerProperties.entrySet()) {
|
||||
if (isBugReportTarget(entry.getKey())) {
|
||||
itemList.add(createItem(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
data.register("bugReportItems", itemList);
|
||||
}
|
||||
|
||||
private boolean isBugReportTarget(final Object key) {
|
||||
if ("snapshot.path".equals(key) || "label.value".equals(key)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Map<String, String> createPropItem(final String key) {
|
||||
return createItem(key, System.getProperty(key));
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final Object label, final Object value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label != null ? label.toString() : StringUtil.EMPTY);
|
||||
map.put(Constants.ITEM_VALUE, value != null ? value.toString() : StringUtil.EMPTY);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,10 +14,16 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.systeminfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SystemInfoForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
|
@ -118,8 +118,8 @@ success.job_stopped=Stopped job {0}.
|
|||
success.joblog_delete_all=Deleted job logs.
|
||||
success.upload_synonym_file=Uploaded Synonym file.
|
||||
success.upload_userdict_file=Uploaded UserDict file.
|
||||
success.upload_suggest_elevate_word=Uploaded Additional Word file.
|
||||
success.upload_suggest_bad_word=Uploaded Bad Word file.
|
||||
success.upload_suggest_elevate_word=Uploaded Additional Word file. <br/>Started to restore data.
|
||||
success.upload_suggest_bad_word=Uploaded Bad Word file. <br/>Started to restore data.
|
||||
|
||||
label.facet_label_title=Label
|
||||
label.facet_lastModified_title=Term
|
||||
|
|
|
@ -115,8 +115,8 @@ success.job_stopped=\u30b8\u30e7\u30d6 {0} \u3092\u505c\u6b62\u3057\u307e\u3057\
|
|||
success.joblog_delete_all=\u30b8\u30e7\u30d6\u30ed\u30b0\u3092\u524a\u9664\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_synonym_file=\u540c\u7fa9\u8a9e\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_userdict_file=\u30e6\u30fc\u30b6\u30fc\u8f9e\u66f8\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_suggest_elevate_word=\u8ffd\u52a0\u5019\u88dc\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_suggest_bad_word=NG\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_suggest_elevate_word=\u8ffd\u52a0\u5019\u88dc\u30d5\u30a1\u30a4\u30eb\u306e\u767b\u9332\u51e6\u7406\u3092\u958b\u59cb\u3057\u307e\u3057\u305f\u3002
|
||||
success.upload_suggest_bad_word=NG\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306e\u767b\u9332\u51e6\u7406\u3092\u958b\u59cb\u3057\u307e\u3057\u305f\u3002
|
||||
|
||||
label.facet_label_title=\u30e9\u30d9\u30eb
|
||||
label.facet_lastModified_title=\u671f\u9593
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
</div>
|
||||
<%-- Box Body --%>
|
||||
<div class="box-body">
|
||||
<textarea id="envData" style="height: 300px;" class="form-control">
|
||||
<c:forEach var="item" items="${envItems}">${f:h(item.label)}=${f:h(item.value)}</c:forEach>
|
||||
</textarea>
|
||||
<textarea id="envData" style="height: 300px;" class="form-control">
|
||||
<c:forEach var="item" items="${envItems}">${f:h(item.label)}=${f:h(item.value)}
|
||||
</c:forEach>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
|
@ -50,7 +51,8 @@
|
|||
<%-- Box Body --%>
|
||||
<div class="box-body">
|
||||
<textarea id="propData" style="height: 300px;" class="form-control">
|
||||
<c:forEach var="item" items="${propItems}">${f:h(item.label)}=${f:h(item.value)}</c:forEach>
|
||||
<c:forEach var="item" items="${propItems}">${f:h(item.label)}=${f:h(item.value)}
|
||||
</c:forEach>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,13 +66,12 @@
|
|||
<%-- Box Body --%>
|
||||
<div class="box-body">
|
||||
<c:if test="${empty fessPropItems}">
|
||||
<textarea id="fessPropData" style="height: 300px;" class="form-control">
|
||||
<la:message key="labels.system_info_crawler_properties_does_not_exist" />
|
||||
</textarea>
|
||||
<textarea id="fessPropData" style="height: 300px;" class="form-control"><la:message key="labels.system_info_crawler_properties_does_not_exist" /></textarea>
|
||||
</c:if>
|
||||
<c:if test="${!empty fessPropItems}">
|
||||
<textarea id="fessPropData" style="height: 300px;" class="form-control">
|
||||
<c:forEach var="item" items="${fessPropItems}">${f:h(item.label)}=${f:h(item.value)}</c:forEach>
|
||||
<c:forEach var="item" items="${fessPropItems}">${f:h(item.label)}=${f:h(item.value)}
|
||||
</c:forEach>
|
||||
</textarea>
|
||||
</c:if>
|
||||
</div>
|
||||
|
@ -85,7 +86,8 @@
|
|||
<%-- Box Body --%>
|
||||
<div class="box-body">
|
||||
<textarea id="bugReportData" style="height: 300px;" class="form-control">
|
||||
<c:forEach var="item" items="${bugReportItems}">${f:h(item.label)}=${f:h(item.value)}</c:forEach>
|
||||
<c:forEach var="item" items="${bugReportItems}">${f:h(item.label)}=${f:h(item.value)}
|
||||
</c:forEach>
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -100,4 +102,3 @@
|
|||
<jsp:include page="/WEB-INF/view/common/admin2/foot.jsp"></jsp:include>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
<span><la:message key="labels.menu.crawl_config" /></span>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='system'}">class="active"</c:if>><todo:link href="/admin/system/index">
|
||||
<li <c:if test="${param.menuType=='system'}">class="active"</c:if>><la:link href="/admin/system/index">
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.system_config" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='scheduledJob'}">class="active"</c:if>><la:link
|
||||
href="/admin/scheduledjob/index"
|
||||
|
@ -180,12 +180,12 @@
|
|||
<span><la:message key="labels.menu.suggest_elevate_word" /></span>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='suggestBadWord'}">class="active"</c:if>><todo:link
|
||||
href="/admin/suggestBadWord/index"
|
||||
<li <c:if test="${param.menuType=='suggestBadWord'}">class="active"</c:if>><la:link
|
||||
href="/admin/suggestbadword/index"
|
||||
>
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.suggest_bad_word" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -194,10 +194,10 @@
|
|||
></i> <span><la:message key="labels.menu_system_log" /></span> <i class="fa fa-angle-left pull-right"></i></a>
|
||||
<ul class="treeview-menu">
|
||||
|
||||
<li <c:if test="${param.menuType=='systemInfo'}">class="active"</c:if>><todo:link href="/admin/systemInfo/index">
|
||||
<li <c:if test="${param.menuType=='systemInfo'}">class="active"</c:if>><la:link href="/admin/systeminfo/index">
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.system_info" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='jobLog'}">class="active"</c:if>><todo:link href="/admin/jobLog/index">
|
||||
<i class='fa fa-angle-right'></i>
|
||||
|
|
Loading…
Add table
Reference in a new issue