Explorar el Código

modify log action

Keiichi Watanabe hace 9 años
padre
commit
add923ba7a

+ 0 - 6
pom.xml

@@ -98,19 +98,13 @@
 						<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/SystemAction.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/DictForm.java</exclude>
-						<exclude>org/codelibs/fess/app/web/admin/SystemForm.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/SearchListAction.java</exclude>
-						<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/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/DataAction.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/WizardForm.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/FailureUrlForm.java</exclude>

+ 0 - 142
src/main/java/org/codelibs/fess/app/web/admin/LogAction.java

@@ -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<Map<String, Object>> getLogFileItems() {
-        final List<Map<String, Object>> logFileItems = new ArrayList<Map<String, Object>>();
-        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<String, Object> createLogFileItem(final File file) {
-        final Map<String, Object> map = new HashMap<String, Object>();
-        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;
-    }
-}

+ 89 - 0
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<Map<String, Object>> getLogFileItems() {
+        // TODO
+        final List<Map<String, Object>> logFileItems = new ArrayList<Map<String, Object>>();
+        return logFileItems;
+    }
+
+}

+ 5 - 1
src/main/java/org/codelibs/fess/app/web/admin/LogForm.java → 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;

+ 2 - 2
src/main/webapp/WEB-INF/view/common/admin2/sidebar.jsp

@@ -211,10 +211,10 @@
 							<span><la:message key="labels.menu.session_info" /></span>
 						</la:link></li>
 
-					<li <c:if test="${param.menuType=='log'}">class="active"</c:if>><todo:link href="/admin/log/index">
+					<li <c:if test="${param.menuType=='log'}">class="active"</c:if>><la:link href="/admin/log/index">
 							<i class='fa fa-angle-right'></i>
 							<span><la:message key="labels.menu.log" /></span>
-						</todo:link></li>
+						</la:link></li>
 
 					<li <c:if test="${param.menuType=='failureUrl'}">class="active"</c:if>><todo:link href="/admin/failureUrl/index">
 							<i class='fa fa-angle-right'></i>