diff --git a/pom.xml b/pom.xml index 5a3b0b0b7..740999738 100644 --- a/pom.xml +++ b/pom.xml @@ -98,19 +98,13 @@ 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/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/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/webapp/WEB-INF/view/common/admin2/sidebar.jsp b/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp index a84947e75..4f2e51e04 100644 --- a/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp +++ b/src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp @@ -211,10 +211,10 @@ -
  • class="active"> +
  • class="active"> -
  • +
  • class="active">