diff --git a/pom.xml b/pom.xml index 5a3b0b0b7..56b12b428 100644 --- a/pom.xml +++ b/pom.xml @@ -98,22 +98,14 @@ org/codelibs/fess/app/web/admin/dict/UserDictAction.java org/codelibs/fess/app/web/admin/dict/SynonymAction.java org/codelibs/fess/app/web/admin/DocumentAction.java - org/codelibs/fess/app/web/admin/SystemAction.java org/codelibs/fess/app/web/admin/DictForm.java - org/codelibs/fess/app/web/admin/SystemForm.java org/codelibs/fess/app/web/admin/SearchListAction.java - org/codelibs/fess/app/web/admin/SuggestElevateWordForm.java org/codelibs/fess/app/web/admin/DocumentForm.java org/codelibs/fess/app/web/admin/DataForm.java org/codelibs/fess/app/web/admin/IndexAction.java - org/codelibs/fess/app/web/admin/LogAction.java - org/codelibs/fess/app/web/admin/FailureUrlAction.java org/codelibs/fess/app/web/admin/DictAction.java - org/codelibs/fess/app/web/admin/SuggestElevateWordAction.java - org/codelibs/fess/app/web/admin/LogForm.java org/codelibs/fess/app/web/admin/DataAction.java org/codelibs/fess/app/web/admin/WizardForm.java - org/codelibs/fess/app/web/admin/FailureUrlForm.java diff --git a/src/main/java/org/codelibs/fess/app/web/admin/FailureUrlAction.java b/src/main/java/org/codelibs/fess/app/web/admin/FailureUrlAction.java deleted file mode 100644 index 71ea6fd6c..000000000 --- a/src/main/java/org/codelibs/fess/app/web/admin/FailureUrlAction.java +++ /dev/null @@ -1,331 +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.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; - -import org.codelibs.core.beans.util.BeanUtil; -import org.codelibs.fess.annotation.Token; -import org.codelibs.fess.app.web.base.FessAdminAction; -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.FailureUrl; -import org.codelibs.fess.helper.SystemHelper; -import org.codelibs.fess.app.pager.FailureUrlPager; -import org.codelibs.fess.app.service.FailureUrlService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FailureUrlAction extends FessAdminAction { - - private static final Logger logger = LoggerFactory.getLogger(FailureUrlAction.class); - - // for list - - public List failureUrlItems; - - // for edit/confirm/delete - - //@ActionForm - @Resource - protected FailureUrlForm failureUrlForm; - - @Resource - protected FailureUrlService failureUrlService; - - @Resource - protected FailureUrlPager failureUrlPager; - - @Resource - protected SystemHelper systemHelper; - - public String getHelpLink() { - return systemHelper.getHelpLink("failureUrl"); - } - - protected String displayList(final boolean redirect) { - // page navi - failureUrlItems = failureUrlService.getFailureUrlList(failureUrlPager); - - // restore from pager - BeanUtil.copyBeanToBean(failureUrlPager, failureUrlForm.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(failureUrlForm.pageNumber)) { - try { - failureUrlPager.setCurrentPageNumber(Integer.parseInt(failureUrlForm.pageNumber)); - } catch (final NumberFormatException e) { - if (logger.isDebugEnabled()) { - logger.debug("Invalid value: " + failureUrlForm.pageNumber, e); - } - } - } - - return displayList(false); - } - - //@Execute(validator = false, input = "error.jsp") - public String search() { - BeanUtil.copyBeanToBean(failureUrlForm.searchParams, failureUrlPager, - option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE)); - - return displayList(false); - } - - //@Execute(validator = false, input = "error.jsp") - public String reset() { - failureUrlPager.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 (failureUrlForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, - failureUrlForm.crudMode }); - } - - loadFailureUrl(); - - return "confirm.jsp"; - } - - @Token(save = true, validate = false) - //@Execute(validator = false, input = "error.jsp") - public String createpage() { - // page navi - failureUrlForm.initialize(); - failureUrlForm.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 (failureUrlForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, failureUrlForm.crudMode }); - } - - loadFailureUrl(); - - return "edit.jsp"; - } - - @Token(save = true, validate = false) - //@Execute(validator = false, input = "error.jsp") - public String editfromconfirm() { - failureUrlForm.crudMode = CommonConstants.EDIT_MODE; - - loadFailureUrl(); - - 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 (failureUrlForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, - failureUrlForm.crudMode }); - } - - loadFailureUrl(); - - return "confirm.jsp"; - } - - @Token(save = true, validate = false) - //@Execute(validator = false, input = "error.jsp") - public String deletefromconfirm() { - failureUrlForm.crudMode = CommonConstants.DELETE_MODE; - - loadFailureUrl(); - - return "confirm.jsp"; - } - - @Token(save = false, validate = true) - //@Execute(validator = true, input = "edit.jsp") - public String create() { - try { - final FailureUrl failureUrl = createFailureUrl(); - failureUrlService.store(failureUrl); - 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 FailureUrl failureUrl = createFailureUrl(); - failureUrlService.store(failureUrl); - 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 = false, validate = true) - //@Execute(validator = false, input = "error.jsp") - public String delete() { - if (failureUrlForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, - failureUrlForm.crudMode }); - } - - try { - final FailureUrl failureUrl = failureUrlService.getFailureUrl(createKeyMap()); - if (failureUrl == null) { - // throw an exception - throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - - new Object[] { failureUrlForm.id }); - - } - - failureUrlService.delete(failureUrl); - 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 ActionMessagesException(e.getMessageId(), e.getArgs()); - } catch (final Exception e) { - logger.error(e.getMessage(), e); - throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); - } - } - - protected void loadFailureUrl() { - - final FailureUrl failureUrl = failureUrlService.getFailureUrl(createKeyMap()); - if (failureUrl == null) { - // throw an exception - throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - - new Object[] { failureUrlForm.id }); - - } - - BeanUtil.copyBeanToBean(failureUrl, failureUrlForm, option -> option.exclude("searchParams", "mode")); - } - - protected FailureUrl createFailureUrl() { - FailureUrl failureUrl; - if (failureUrlForm.crudMode == CommonConstants.EDIT_MODE) { - failureUrl = failureUrlService.getFailureUrl(createKeyMap()); - if (failureUrl == null) { - // throw an exception - throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - - new Object[] { failureUrlForm.id }); - - } - } else { - failureUrl = new FailureUrl(); - } - BeanUtil.copyBeanToBean(failureUrlForm, failureUrl, option -> option.exclude("searchParams", "mode")); - - return failureUrl; - } - - protected Map createKeyMap() { - final Map keys = new HashMap(); - - keys.put("id", failureUrlForm.id); - - return keys; - } - - //@Execute(validator = false, input = "error.jsp") - public String deleteall() { - failureUrlService.deleteAll(failureUrlPager); - SAStrutsUtil.addSessionMessage("success.failure_url_delete_all"); - return displayList(true); - } -} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/LogAction.java b/src/main/java/org/codelibs/fess/app/web/admin/LogAction.java deleted file mode 100644 index f0baf652c..000000000 --- a/src/main/java/org/codelibs/fess/app/web/admin/LogAction.java +++ /dev/null @@ -1,142 +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.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FilenameFilter; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; - -import org.apache.commons.codec.binary.Base64; -import org.codelibs.core.lang.StringUtil; -import org.codelibs.fess.Constants; -import org.codelibs.fess.exception.SSCActionMessagesException; -import org.codelibs.fess.helper.SystemHelper; -import org.codelibs.fess.util.ComponentUtil; -import org.lastaflute.web.util.LaResponseUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LogAction implements Serializable { - - private static final long serialVersionUID = 1L; - - private static final Logger logger = LoggerFactory.getLogger(LogAction.class); - - //@ActionForm - @Resource - protected LogForm logForm; - - @Resource - protected SystemHelper systemHelper; - - public String getHelpLink() { - return systemHelper.getHelpLink("log"); - } - - //@Execute(validator = false) - public String index() { - return "index.jsp"; - } - - //@Execute(validator = true, input = "index", urlPattern = "download/{logFileName}") - public String download() { - final String logFilePath = ComponentUtil.getSystemHelper().getLogFilePath(); - if (StringUtil.isNotBlank(logFilePath)) { - final File file = new File(logFilePath); - final File parentDir = file.getParentFile(); - String fileName; - try { - fileName = new String(Base64.decodeBase64(logForm.logFileName.getBytes(Constants.UTF_8)), Constants.UTF_8); - } catch (final UnsupportedEncodingException e1) { - fileName = - new String(Base64.decodeBase64(logForm.logFileName.getBytes(Charset.defaultCharset())), Charset.defaultCharset()); - } - final File logFile = new File(parentDir, fileName); - if (logFile.isFile()) { - try { - LaResponseUtil.download(fileName, new FileInputStream(logFile)); - return null; - } catch (final FileNotFoundException e) { - logger.warn("Could not find " + logFile.getAbsolutePath(), e); - } - } - } - throw new SSCActionMessagesException("errors.could_not_find_log_file", new Object[] { logForm.logFileName }); - } - - public List> getLogFileItems() { - final List> logFileItems = new ArrayList>(); - final String logFilePath = ComponentUtil.getSystemHelper().getLogFilePath(); - if (StringUtil.isNotBlank(logFilePath)) { - try { - final File file = new File(logFilePath); - final File parentDir = file.getParentFile(); - if (!parentDir.exists()) { - logger.warn("Log directory does not exist: " + parentDir.getAbsolutePath()); - return logFileItems; - } - final File[] files = parentDir.listFiles((FilenameFilter) (dir, name) -> { - if (name.indexOf(".out") > 0) { - return true; - } - return false; - }); - if (files == null) { - return logFileItems; - } - Arrays.sort(files, (o1, o2) -> { - if (o1.lastModified() < o2.lastModified()) { - return 1; - } else { - return -1; - } - }); - for (final File logFile : files) { - logFileItems.add(createLogFileItem(logFile)); - } - } catch (final Exception e) { - logger.warn("Could not find log files.", e); - } - } - return logFileItems; - } - - protected Map createLogFileItem(final File file) { - final Map map = new HashMap(); - map.put("name", file.getName()); - try { - map.put("logFileName", new String(Base64.encodeBase64(file.getName().getBytes(Constants.UTF_8)), "UTF-8")); - } catch (final UnsupportedEncodingException e) { - map.put("logFileName", - new String(Base64.encodeBase64(file.getName().getBytes(Charset.defaultCharset())), Charset.defaultCharset())); - } - map.put("lastModified", new Date(file.lastModified())); - return map; - } -} \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/app/web/admin/failureurl/AdminFailureurlAction.java b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/AdminFailureurlAction.java new file mode 100644 index 000000000..7ad9c6897 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/AdminFailureurlAction.java @@ -0,0 +1,164 @@ +/* + * 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.failureurl; + +import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Resource; + +import org.codelibs.fess.annotation.Token; +import org.codelibs.fess.app.pager.FailureUrlPager; +import org.codelibs.fess.app.service.FailureUrlService; +import org.codelibs.fess.app.web.base.FessAdminAction; +import org.codelibs.fess.crud.CommonConstants; +import org.codelibs.fess.es.exentity.FailureUrl; +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.validation.VaErrorHook; + +/** + * @author codelibs + * @author Keiichi Watanabe + */ +public class AdminFailureurlAction extends FessAdminAction { + + // =================================================================================== + // Attribute + // ========= + @Resource + private FailureUrlService failureUrlService; + @Resource + private FailureUrlPager failureUrlPager; + @Resource + private SystemHelper systemHelper; + + // =================================================================================== + // Hook + // ====== + @Override + protected void setupHtmlData(final ActionRuntime runtime) { + super.setupHtmlData(runtime); + runtime.registerData("helpLink", systemHelper.getHelpLink("failureUrl")); + } + + // =================================================================================== + // Search Execute + // ============== + @Execute + public HtmlResponse index(final FailureUrlSearchForm form) { + return asHtml(path_AdminFailureurl_IndexJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse list(final Integer pageNumber, final FailureUrlSearchForm form) { + failureUrlPager.setCurrentPageNumber(pageNumber); + return asHtml(path_AdminFailureurl_IndexJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse search(final FailureUrlSearchForm form) { + copyBeanToBean(form.searchParams, failureUrlPager, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE)); + return asHtml(path_AdminFailureurl_IndexJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse reset(final FailureUrlSearchForm form) { + failureUrlPager.clear(); + return asHtml(path_AdminFailureurl_IndexJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + @Execute + public HtmlResponse back(final FailureUrlSearchForm form) { + return asHtml(path_AdminFailureurl_IndexJsp).renderWith(data -> { + searchPaging(data, form); + }); + } + + protected void searchPaging(final RenderData data, final FailureUrlSearchForm form) { + data.register("failureUrlItems", failureUrlService.getFailureUrlList(failureUrlPager)); // page navi + + // restore from pager + copyBeanToBean(failureUrlPager, form.searchParams, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE)); + } + + // ----------------------------------------------------- + // Confirm + // ------- + @Execute + public HtmlResponse confirmpage(final int crudMode, final String id, final FailureUrlEditForm form) { + // TODO + // form.crudMode = crudMode; + // form.id = id; + // verifyCrudMode(form, CommonConstants.CONFIRM_MODE); + loadFailureUrl(form); + return asHtml(path_AdminFailureurl_ConfirmJsp); + } + + // ----------------------------------------------------- + // Actually Crud (only Delete) + // ------------- + + @Execute + public HtmlResponse delete(final FailureUrlEditForm form) { + // TODO verifyCrudMode(form, CommonConstants.DELETE_MODE); + failureUrlService.delete(getFailureUrl(form)); + saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL)); + return redirect(getClass()); + } + + @Execute + public HtmlResponse deleteall(final FailureUrlEditForm form) { + failureUrlService.deleteAll(failureUrlPager); + saveInfo(messages -> messages.addSuccessFailureUrlDeleteAll(GLOBAL)); + return redirect(getClass()); + } + + // =================================================================================== + // Assist Logic + // ============ + + protected void loadFailureUrl(final FailureUrlEditForm form) { + copyBeanToBean(getFailureUrl(form), form, op -> op.exclude("crudMode")); + } + + protected FailureUrl getFailureUrl(final FailureUrlEditForm form) { + final FailureUrl failureUrl = failureUrlService.getFailureUrl(createKeyMap(form)); + if (failureUrl == null) { + // TODO + } + return failureUrl; + } + + protected Map createKeyMap(final FailureUrlEditForm form) { + final Map keys = new HashMap(); + keys.put("id", form.id); + return keys; + } + +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/FailureUrlForm.java b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlEditForm.java similarity index 89% rename from src/main/java/org/codelibs/fess/app/web/admin/FailureUrlForm.java rename to src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlEditForm.java index 8c75d1bcd..b75e65a8e 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/FailureUrlForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlEditForm.java @@ -14,13 +14,19 @@ * governing permissions and limitations under the License. */ -package org.codelibs.fess.app.web.admin; +package org.codelibs.fess.app.web.admin.failureurl; import java.io.Serializable; import java.util.HashMap; import java.util.Map; -public class FailureUrlForm implements Serializable { +import org.codelibs.fess.util.ComponentUtil; + +/** + * @author codelibs + * @author Keiichi Watanabe + */ +public class FailureUrlEditForm implements Serializable { private static final long serialVersionUID = 1L; @@ -33,7 +39,8 @@ public class FailureUrlForm implements Serializable { public Map searchParams = new HashMap(); - //@IntegerType + //@IntegerType + // TODO necessary? public int crudMode; public String getCurrentPageNumber() { diff --git a/src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlSearchForm.java b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlSearchForm.java new file mode 100644 index 000000000..86c0b6954 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/failureurl/FailureUrlSearchForm.java @@ -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.failureurl; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * @author codelibs + * @author Keiichi Watanabe + */ +public class FailureUrlSearchForm implements Serializable { + + private static final long serialVersionUID = 1L; + + public Map searchParams = new HashMap(); +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/log/AdminLogAction.java b/src/main/java/org/codelibs/fess/app/web/admin/log/AdminLogAction.java new file mode 100644 index 000000000..161588f58 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/log/AdminLogAction.java @@ -0,0 +1,89 @@ +/* + * 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.log; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; + +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; + +/** + * @author codelibs + * @author Keiichi Watanabe + */ +public class AdminLogAction extends FessAdminAction { + + @Resource + private SystemHelper systemHelper; + + @Override + protected void setupHtmlData(final ActionRuntime runtime) { + super.setupHtmlData(runtime); + runtime.registerData("helpLink", systemHelper.getHelpLink("log")); + } + + @Execute + public HtmlResponse index(final LogForm form) { + return asHtml(path_AdminLog_IndexJsp).renderWith(data -> { + data.register("logFileItems", getLogFileItems()); + }); + } + + //@Execute(validator = true, input = "index", urlPattern = "download/{logFileName}") + public HtmlResponse download(final LogForm form) { + // TODO + return redirect(getClass()); + /* + final String logFilePath = ComponentUtil.getSystemHelper().getLogFilePath(); + if (StringUtil.isNotBlank(logFilePath)) { + final File file = new File(logFilePath); + final File parentDir = file.getParentFile(); + String fileName; + try { + fileName = new String(Base64.decodeBase64(logForm.logFileName.getBytes(Constants.UTF_8)), Constants.UTF_8); + } catch (final UnsupportedEncodingException e1) { + fileName = + new String(Base64.decodeBase64(logForm.logFileName.getBytes(Charset.defaultCharset())), Charset.defaultCharset()); + } + final File logFile = new File(parentDir, fileName); + if (logFile.isFile()) { + try { + LaResponseUtil.download(fileName, new FileInputStream(logFile)); + return null; + } catch (final FileNotFoundException e) { + logger.warn("Could not find " + logFile.getAbsolutePath(), e); + } + } + } + throw new SSCActionMessagesException("errors.could_not_find_log_file", new Object[] { logForm.logFileName }); + */ + } + + public List> getLogFileItems() { + // TODO + final List> logFileItems = new ArrayList>(); + return logFileItems; + } + +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/LogForm.java b/src/main/java/org/codelibs/fess/app/web/admin/log/LogForm.java similarity index 88% rename from src/main/java/org/codelibs/fess/app/web/admin/LogForm.java rename to src/main/java/org/codelibs/fess/app/web/admin/log/LogForm.java index f3829bc8e..d1045c5ee 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/LogForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/log/LogForm.java @@ -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.log; import java.io.Serializable; +/** + * @author codelibs + * @author Keiichi Watanabe + */ public class LogForm implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/system/AdminSystemAction.java b/src/main/java/org/codelibs/fess/app/web/admin/system/AdminSystemAction.java index d86f4a6bb..e34bf504a 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/system/AdminSystemAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/system/AdminSystemAction.java @@ -27,6 +27,7 @@ import org.codelibs.core.misc.DynamicProperties; import org.codelibs.fess.annotation.Token; import org.codelibs.fess.app.service.ScheduledJobService; import org.codelibs.fess.app.web.base.FessAdminAction; +import org.codelibs.fess.client.FessEsClient; import org.codelibs.fess.es.exentity.ScheduledJob; import org.codelibs.fess.helper.JobHelper; import org.codelibs.fess.helper.SystemHelper; @@ -53,6 +54,8 @@ public class AdminSystemAction extends FessAdminAction { protected JobHelper jobHelper; @Resource protected ScheduledJobService scheduledJobService; + @Resource + protected FessEsClient fessEsClient; // =================================================================================== // Hook @@ -69,12 +72,11 @@ public class AdminSystemAction extends FessAdminAction { @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()); - }); + data.register("clusterName", fessEsClient.getClusterName()); + data.register("clusterStatus", fessEsClient.getStatus()); + data.register("crawlerRunning", isCrawlerRunning()); + data.register("runningSessionIds", getRunningSessionIds()); + }); } @Token(save = false, validate = true) diff --git a/src/main/java/org/codelibs/fess/client/FessEsClient.java b/src/main/java/org/codelibs/fess/client/FessEsClient.java index 17abba2d6..c71e3b237 100644 --- a/src/main/java/org/codelibs/fess/client/FessEsClient.java +++ b/src/main/java/org/codelibs/fess/client/FessEsClient.java @@ -194,6 +194,10 @@ public class FessEsClient implements Client { this.clusterName = clusterName; } + public String getStatus() { + return admin().cluster().prepareHealth().execute().actionGet().getStatus().name(); + } + public void setRunner(final ElasticsearchClusterRunner runner) { this.runner = runner; } diff --git a/src/main/webapp/WEB-INF/view/admin/system/index.jsp b/src/main/webapp/WEB-INF/view/admin/system/index.jsp index 959e7cddf..3c8d66f38 100644 --- a/src/main/webapp/WEB-INF/view/admin/system/index.jsp +++ b/src/main/webapp/WEB-INF/view/admin/system/index.jsp @@ -1,119 +1,108 @@ <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> - - - Fess | <la:message key="labels.system_title_configuration" /> - - - -
- - - - - + + +Fess | <la:message key="labels.system_title_configuration" /> + + + +
+ + + + + -
- <%-- Content Header --%> - <%-- Message --%> -
- -
- ${msg} -
-
- -
+
+ <%-- Content Header --%> + <%-- Message --%> +
+ +
${msg}
+
+ +
-
-
-
- -
- <%-- Box Header --%> -
-

- -

-
- <%-- Box Body --%> -
- - - - - - - -
- ${f:h(clusterName)} - ( - - - - ) -
-
-
- - -
- <%-- Box Header --%> -
-

- -

-
- <%-- Box Body --%> -
- <%-- Message --%> - - - - - - - - - - - -
- - - - - - -
- - - - " /> - - -
- - - - - - - " /> -
-
-
-
-
-
-
-
-
+
+
+
+
+ <%-- Box Header --%> +
+

+ +

+
+ <%-- Box Body --%> +
+ + + + + + + +
${f:h(clusterName)} + (${f:h(clusterStatus)})
+
- + + +
+ <%-- Box Header --%> +
+

+ +

+
+ <%-- Box Body --%> +
+ <%-- Message --%> + + + + + + + + + + + +
+ + + + +
+ + " /> + +
+ + + + + + + " /> +
+
+
+
+
+
- - +
+
+ +
+ + diff --git a/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp b/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp index a84947e75..7f8fb1930 100644 --- a/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp +++ b/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp @@ -211,15 +211,15 @@ -
  • class="active"> +
  • class="active"> -
  • + -
  • class="active"> +
  • class="active"> -
  • +
  • class="active">