modify systemInfo action

This commit is contained in:
Keiichi Watanabe 2015-09-14 18:03:14 +09:00
parent 3b0e352d79
commit 9771ee9b0c
6 changed files with 156 additions and 131 deletions

View file

@ -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>
@ -114,7 +113,6 @@
<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/CrawlingSessionForm.java</exclude>

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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>

View file

@ -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>