瀏覽代碼

update wizard page

Shinsuke Sugaya 9 年之前
父節點
當前提交
c26a49e21a

+ 0 - 7
pom.xml

@@ -89,19 +89,12 @@
 					<encoding>UTF-8</encoding>
 					<!-- TODO remove -->
 					<excludes>
-						<exclude>org/codelibs/fess/app/web/admin/WizardAction.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/dict/UserDictForm.java</exclude>
 						<exclude>org/codelibs/fess/app/web/admin/dict/SynonymForm.java</exclude>
 						<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/DictForm.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/DictAction.java</exclude>
-						<exclude>org/codelibs/fess/app/web/admin/DataAction.java</exclude>
-						<exclude>org/codelibs/fess/app/web/admin/WizardForm.java</exclude>
 					</excludes>
 				</configuration>
 			</plugin>

+ 42 - 0
src/main/java/org/codelibs/fess/app/web/admin/AdminAction.java

@@ -0,0 +1,42 @@
+/*
+ * 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 org.codelibs.fess.app.web.admin.wizard.AdminWizardAction;
+import org.codelibs.fess.app.web.base.FessAdminAction;
+import org.lastaflute.web.Execute;
+import org.lastaflute.web.response.HtmlResponse;
+
+public class AdminAction extends FessAdminAction {
+
+    // ===================================================================================
+    //                                                                            Constant
+    //     
+
+    // ===================================================================================
+    //                                                                           Attribute
+    //     
+
+    // ===================================================================================
+    //                                                                      Search Execute
+    //                                                                      ==============
+    @Execute
+    public HtmlResponse index() {
+        return redirect(AdminWizardAction.class);
+    }
+
+}

+ 0 - 181
src/main/java/org/codelibs/fess/app/web/admin/DataAction.java

@@ -1,181 +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.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.Serializable;
-import java.io.Writer;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.codelibs.core.CoreLibConstants;
-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.crud.util.SAStrutsUtil;
-import org.codelibs.fess.exception.SSCActionMessagesException;
-import org.codelibs.fess.helper.SystemHelper;
-import org.codelibs.fess.app.service.CrawlingSessionService;
-import org.lastaflute.web.util.LaResponseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataAction implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private static final Logger logger = LoggerFactory.getLogger(DataAction.class);
-
-    @Resource
-    //@ActionForm
-    protected DataForm dataForm;
-
-    @Resource
-    protected CrawlingSessionService crawlingSessionService;
-
-    @Resource
-    protected DynamicProperties crawlerProperties;
-
-    @Resource
-    protected SystemHelper systemHelper;
-
-    public String getHelpLink() {
-        return systemHelper.getHelpLink("data");
-    }
-
-    //@Execute(validator = false)
-    public String index() {
-        // set a default value
-        dataForm.overwrite = "on";
-        return "index.jsp";
-    }
-
-    //@Execute(validator = false)
-    public String downloadCrawlingSession() {
-        final DateFormat df = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_DIGIT_ONLY);
-        final StringBuilder buf = new StringBuilder();
-        buf.append("backup-cs-");
-        buf.append(df.format(new Date()));
-        buf.append(".csv");
-
-        final HttpServletResponse response = LaResponseUtil.getResponse();
-        response.setContentType("application/octet-stream");
-        response.setHeader("Content-Disposition", "attachment; filename=\"" + buf.toString() + "\"");
-
-        Writer writer = null;
-        try {
-            writer =
-                    new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty(
-                            Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)));
-            crawlingSessionService.exportCsv(writer);
-            writer.flush();
-            return null;
-        } catch (final Exception e) {
-            logger.error("Failed to export data.", e);
-            throw new SSCActionMessagesException(e, "errors.failed_to_export_data");
-        } finally {
-            IOUtils.closeQuietly(writer);
-        }
-    }
-
-    //@Execute(validator = true, input = "index")
-    public String upload() {
-        final String fileName = dataForm.uploadedFile.getFileName();
-        if (fileName.endsWith(".csv")) {
-            BufferedInputStream is = null;
-            File tempFile = null;
-            FileOutputStream fos = null;
-            final byte[] b = new byte[20];
-            try {
-                tempFile = File.createTempFile("fess-import-", ".csv");
-                is = new BufferedInputStream(dataForm.uploadedFile.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("SessionId,")) {
-                    logger.error("Unknown file: " + dataForm.uploadedFile);
-                    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));
-                        if (head.startsWith("SessionId,")) {
-                            // Crawling Session
-                        crawlingSessionService.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);
-                }
-            }   ).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.importing_data");
-        return "index?redirect=true";
-    }
-}

+ 0 - 29
src/main/java/org/codelibs/fess/app/web/admin/DataForm.java

@@ -1,29 +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;
-
-public class DataForm implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    //@Required
-    //public FormFile uploadedFile;
-
-    public String overwrite;
-}

+ 0 - 247
src/main/java/org/codelibs/fess/app/web/admin/DocumentAction.java

@@ -1,247 +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.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
-import org.codelibs.fess.annotation.Token;
-import org.codelibs.fess.client.FessEsClient;
-import org.codelibs.fess.crud.util.SAStrutsUtil;
-import org.codelibs.fess.exception.SSCActionMessagesException;
-import org.codelibs.fess.helper.FieldHelper;
-import org.codelibs.fess.helper.JobHelper;
-import org.codelibs.fess.helper.SystemHelper;
-import org.codelibs.fess.helper.WebManagementHelper;
-import org.codelibs.fess.util.ComponentUtil;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.search.aggregations.AggregationBuilders;
-import org.elasticsearch.search.aggregations.bucket.terms.Terms;
-import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
-import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order;
-import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
-import org.lastaflute.taglib.function.LaFunctions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DocumentAction implements Serializable {
-    private static final Logger logger = LoggerFactory.getLogger(DocumentAction.class);
-
-    private static final long serialVersionUID = 1L;
-
-    //@ActionForm
-    @Resource
-    protected DocumentForm documentForm;
-
-    @Resource
-    protected FessEsClient fessEsClient;
-
-    @Resource
-    protected WebManagementHelper webManagementHelper;
-
-    @Resource
-    protected SystemHelper systemHelper;
-
-    @Resource
-    protected FieldHelper fieldHelper;
-
-    @Resource
-    protected JobHelper jobHelper;
-
-    public Map<String, Long> suggestDocumentNums;
-
-    public String getHelpLink() {
-        return systemHelper.getHelpLink("document");
-    }
-
-    protected String showIndex(final boolean redirect) {
-        // TODO
-
-        if (redirect) {
-            return "index?redirect=true";
-        } else {
-            return "index.jsp";
-        }
-    }
-
-    @Token(save = true, validate = false)
-    //@Execute(validator = false)
-    public String index() {
-        return showIndex(false);
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String commit() {
-        // TODO change to flush
-        if (jobHelper.isCrawlProcessRunning()) {
-            throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running");
-        }
-
-        fessEsClient.flush(ComponentUtil.getFieldHelper().docIndex);
-        SAStrutsUtil.addSessionMessage("success.commit_solr_index");
-        return showIndex(true);
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String optimize() {
-        // TODO change to optimize
-        if (jobHelper.isCrawlProcessRunning()) {
-            throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running");
-        }
-        fessEsClient.optimize(ComponentUtil.getFieldHelper().docIndex);
-        SAStrutsUtil.addSessionMessage("success.optimize_solr_index");
-        return showIndex(true);
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String delete() {
-        QueryBuilder deleteQuery;
-        if ("*".equals(documentForm.sessionId)) {
-            deleteQuery = QueryBuilders.matchAllQuery();
-        } else {
-            deleteQuery = QueryBuilders.termQuery(fieldHelper.segmentField, documentForm.sessionId);
-        }
-        return deleteByQuery(deleteQuery);
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String confirmByUrl() {
-        final String confirmQuery = fieldHelper.urlField + ":\"" + documentForm.deleteUrl + "\"";
-        return "/admin/searchList/search?query=" + LaFunctions.u(confirmQuery) + "&redirect=true";
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String deleteByUrl() {
-        return deleteByQuery(QueryBuilders.termQuery(fieldHelper.urlField, documentForm.deleteUrl));
-    }
-
-    private String deleteByQuery(final QueryBuilder queryBuilder) {
-        if (jobHelper.isCrawlProcessRunning()) {
-            throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running");
-        }
-
-        fessEsClient.deleteByQuery(fieldHelper.docIndex, fieldHelper.docType, queryBuilder);
-        SAStrutsUtil.addSessionMessage("success.delete_solr_index");
-        return showIndex(true);
-    }
-
-    protected SessionIdList<Map<String, String>> getSessionIdList(final String groupName) {
-        // TODO remove groupName?
-        final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
-        return fessEsClient.search(
-                fieldHelper.docIndex,
-                fieldHelper.docType,
-                queryRequestBuilder -> {
-                    queryRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
-                    final TermsBuilder termsBuilder =
-                            AggregationBuilders.terms(fieldHelper.segmentField).field(fieldHelper.segmentField).size(100)
-                                    .order(Order.count(false));
-                    queryRequestBuilder.addAggregation(termsBuilder);
-                    return true;
-                }, (queryRequestBuilder, execTime, searchResponse) -> {
-                    final SessionIdList<Map<String, String>> sessionIdList = new SessionIdList<Map<String, String>>();
-                    searchResponse.ifPresent(response -> {
-                        final Terms terms = response.getAggregations().get(fieldHelper.segmentField);
-                        for (final Bucket bucket : terms.getBuckets()) {
-                            final Map<String, String> map = new HashMap<String, String>(3);
-                            map.put("label", bucket.getKey() + " (" + bucket.getDocCount() + ")");
-                            map.put("value", bucket.getKey());
-                            map.put("count", Long.toString(bucket.getDocCount()));
-                            sessionIdList.add(map);
-                            sessionIdList.addTotalCount(bucket.getDocCount());
-                        }
-                    });
-                    return sessionIdList;
-                });
-
-    }
-
-    public boolean isSolrProcessRunning() {
-        return jobHelper.isCrawlProcessRunning();
-    }
-
-    public Set<String> getRunningSessionIdSet() {
-        return jobHelper.getRunningSessionIdSet();
-    }
-
-    protected Map<String, Long> getSuggestDocumentNum() {
-        final Map<String, Long> map = new HashMap<String, Long>();
-        // map.put(SUGGEST_TYPE_CONTENT,
-        // suggestService.getContentDocumentNum());
-        // map.put(SUGGEST_TYPE_SEARCH_LOG,
-        // suggestService.getSearchLogDocumentNum());
-        // map.put(SUGGEST_TYPE_ALL, suggestService.getDocumentNum());
-        return map;
-    }
-
-    @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "index")
-    public String deleteSuggest() {
-        // TODO
-        /*
-         * final SuggestSolrServer suggestSolrServer =
-         * suggestService.getSuggestSolrServer(); final String query; if
-         * (SUGGEST_TYPE_CONTENT.equals(documentForm.deleteSuggestType)) { query
-         * = "*:* NOT " + SuggestConstants.SuggestFieldNames.SEGMENT + ":" +
-         * SuggestConstants.SEGMENT_ELEVATE + " NOT " +
-         * SuggestConstants.SuggestFieldNames.SEGMENT + ":" +
-         * SuggestConstants.SEGMENT_QUERY; } else if
-         * (SUGGEST_TYPE_SEARCH_LOG.equals(documentForm.deleteSuggestType)) {
-         * query = SuggestConstants.SuggestFieldNames.SEGMENT + ":" +
-         * SuggestConstants.SEGMENT_QUERY; } else { query = ""; }
-         * 
-         * if (StringUtil.isNotBlank(query)) { final Thread thread = new
-         * Thread(new Runnable() {
-         * 
-         * @Override public void run() { if (!jobHelper.isCrawlProcessRunning())
-         * { final long execTime = System.currentTimeMillis(); try {
-         * suggestSolrServer.deleteByQuery(query); suggestSolrServer.commit();
-         * if (logger.isInfoEnabled()) {
-         * logger.info("[EXEC TIME] suggest index cleanup time: " +
-         * (System.currentTimeMillis() - execTime) + "ms"); } } catch (final
-         * Exception e) { logger.error("Failed to delete suggest index (query="
-         * + query + ").", e); } } else { if (logger.isInfoEnabled()) {
-         * logger.info("could not start index cleanup process" +
-         * " because of running solr process."); } } } }); thread.start();
-         * SAStrutsUtil.addSessionMessage("success.delete_solr_index"); }
-         */
-        return showIndex(true);
-    }
-
-    private static class SessionIdList<E> extends ArrayList<E> {
-
-        private static final long serialVersionUID = 1L;
-
-        private long totalCount = 0;
-
-        public void addTotalCount(final long count) {
-            totalCount += count;
-        }
-
-    }
-}

+ 0 - 52
src/main/java/org/codelibs/fess/app/web/admin/DocumentForm.java

@@ -1,52 +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.List;
-import java.util.Map;
-
-public class DocumentForm implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    public String currentServerForUpdate;
-
-    public String currentServerForSelect;
-
-    public String currentServerStatusForUpdate;
-
-    public String currentServerStatusForSelect;
-
-    public List<Map<String, String>> serverStatusList = new ArrayList<Map<String, String>>();
-
-    //@Required(target = "commit,optimize,delete")
-    public String groupName;
-
-    //@Required(target = "delete")
-    public String sessionId;
-
-    //@Required(target = "deleteByUrl,confirmByUrl")
-    public String deleteUrl;
-
-    //@Required(target = "startSolrInstance,stopSolrInstance,reloadSolrInstance")
-    public String solrInstanceName;
-
-    //@Required(target = "deleteSuggest")
-    public String deleteSuggestType;
-}

+ 0 - 48
src/main/java/org/codelibs/fess/app/web/admin/IndexAction.java

@@ -1,48 +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 javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.codelibs.fess.helper.SystemHelper;
-import org.codelibs.fess.util.ActivityUtil;
-import org.lastaflute.web.util.LaRequestUtil;
-
-public class IndexAction {
-
-    @Resource
-    protected SystemHelper systemHelper;
-
-    public String getHelpLink() {
-        return systemHelper.getHelpLink("wizard");
-    }
-
-    //@Execute(validator = false)
-    public String index() {
-        return "/admin/wizard/index?redirect=true";
-    }
-
-    //@Execute(validator = false)
-    public String logout() {
-        final HttpServletRequest request = LaRequestUtil.getRequest();
-        ActivityUtil.logout(request.getRemoteUser(), request);
-
-        request.getSession().invalidate();
-        return "/admin/wizard/index?redirect=true";
-    }
-}

+ 0 - 42
src/main/java/org/codelibs/fess/app/web/admin/WizardForm.java

@@ -1,42 +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;
-
-public class WizardForm implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    //@Maxbytelength(maxbytelength = 200, target = "crawlingConfig,crawlingConfigNext")
-    public String crawlingConfigName;
-
-    //@Required(target = "crawlingConfig,crawlingConfigNext")
-    //@Maxbytelength(maxbytelength = 1000)
-    public String crawlingConfigPath;
-
-    //@LongRange(min = 0, max = Long.MAX_VALUE, target = "crawlingConfig,crawlingConfigNext")
-    public String maxAccessCount;
-
-    //@IntRange(min = 0, max = Integer.MAX_VALUE, target = "crawlingConfig,crawlingConfigNext")
-    public String depth;
-
-    public WizardForm() {
-        maxAccessCount = "10000";
-        depth = null;
-    }
-}

+ 76 - 54
src/main/java/org/codelibs/fess/app/web/admin/WizardAction.java → src/main/java/org/codelibs/fess/app/web/admin/wizard/AdminWizardAction.java

@@ -14,44 +14,48 @@
  * governing permissions and limitations under the License.
  */
 
-package org.codelibs.fess.app.web.admin;
+package org.codelibs.fess.app.web.admin.wizard;
 
-import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.List;
 
 import javax.annotation.Resource;
 
+import org.apache.commons.lang3.StringUtils;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.misc.DynamicProperties;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.annotation.Token;
-import org.codelibs.fess.crud.util.SAStrutsUtil;
+import org.codelibs.fess.app.service.FileConfigService;
+import org.codelibs.fess.app.service.ScheduledJobService;
+import org.codelibs.fess.app.service.WebConfigService;
+import org.codelibs.fess.app.web.admin.system.AdminSystemAction;
+import org.codelibs.fess.app.web.base.FessAdminAction;
 import org.codelibs.fess.es.exentity.FileConfig;
 import org.codelibs.fess.es.exentity.ScheduledJob;
 import org.codelibs.fess.es.exentity.WebConfig;
-import org.codelibs.fess.exception.SSCActionMessagesException;
 import org.codelibs.fess.helper.JobHelper;
 import org.codelibs.fess.helper.SystemHelper;
 import org.codelibs.fess.job.TriggeredJob;
-import org.codelibs.fess.app.service.FileConfigService;
-import org.codelibs.fess.app.service.ScheduledJobService;
-import org.codelibs.fess.app.service.WebConfigService;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.robot.util.CharUtil;
+import org.lastaflute.web.Execute;
+import org.lastaflute.web.callback.ActionRuntime;
+import org.lastaflute.web.response.HtmlResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class WizardAction implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    private static final Logger logger = LoggerFactory.getLogger(WizardAction.class);
+public class AdminWizardAction extends FessAdminAction {
 
-    //@ActionForm
-    @Resource
-    protected WizardForm wizardForm;
+    // ===================================================================================
+    //                                                                            Constant
+    //     
+    private static final Logger logger = LoggerFactory.getLogger(AdminWizardAction.class);
 
+    // ===================================================================================
+    //                                                                           Attribute
+    //     
     @Resource
     protected DynamicProperties crawlerProperties;
 
@@ -70,47 +74,62 @@ public class WizardAction implements Serializable {
     @Resource
     protected ScheduledJobService scheduledJobService;
 
-    public String getHelpLink() {
-        return systemHelper.getHelpLink("wizard");
+    // ===================================================================================
+    //                                                                               Hook
+    //                                                                              ======
+    @Override
+    protected void setupHtmlData(final ActionRuntime runtime) {
+        super.setupHtmlData(runtime);
+        runtime.registerData("helpLink", systemHelper.getHelpLink("wizard"));
     }
 
-    //@Execute(validator = false)
-    public String index() {
-        return "index.jsp";
+    // ===================================================================================
+    //                                                                      Search Execute
+    //                                                                      ==============
+
+    @Execute
+    public HtmlResponse index() {
+        return asHtml(path_AdminWizard_IndexJsp).useForm(IndexForm.class);
     }
 
     @Token(save = true, validate = false)
-    //@Execute(validator = false)
-    public String crawlingConfigForm() {
-        return "crawlingConfig.jsp";
+    @Execute
+    public HtmlResponse crawlingConfigForm() {
+        return asHtml(path_AdminWizard_CrawlingConfigJsp).useForm(CrawlingConfigForm.class);
     }
 
     @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "crawlingConfigForm")
-    public String crawlingConfig() {
-        final String name = crawlingConfigInternal(wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath);
-        SAStrutsUtil.addSessionMessage("success.create_crawling_config_at_wizard", name);
-        return "crawlingConfigForm?redirect=true";
+    @Execute
+    public HtmlResponse crawlingConfig(CrawlingConfigForm form) {
+        validate(form, messages -> {}, () -> {
+            return asHtml(path_AdminWizard_CrawlingConfigJsp);
+        });
+        final String name = crawlingConfigInternal(form);
+        saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
+        return redirectWith(getClass(), moreUrl("crawlingConfigForm"));
     }
 
     @Token(save = false, validate = true)
-    //@Execute(validator = true, input = "crawlingConfigForm")
-    public String crawlingConfigNext() {
-        final String name = crawlingConfigInternal(wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath);
-        SAStrutsUtil.addSessionMessage("success.create_crawling_config_at_wizard", name);
-        return "startCrawlingForm?redirect=true";
+    @Execute
+    public HtmlResponse crawlingConfigNext(CrawlingConfigForm form) {
+        validate(form, messages -> {}, () -> {
+            return asHtml(path_AdminWizard_CrawlingConfigJsp);
+        });
+        final String name = crawlingConfigInternal(form);
+        saveInfo(messages -> messages.addSuccessCreateCrawlingConfigAtWizard(GLOBAL, name));
+        return redirectWith(getClass(), moreUrl("startCrawlingForm"));
     }
 
-    protected String crawlingConfigInternal(final String crawlingConfigName, final String crawlingConfigPath) {
+    protected String crawlingConfigInternal(final CrawlingConfigForm form) {
 
-        String configName = crawlingConfigName;
-        String configPath = crawlingConfigPath.trim();
+        String configName = form.crawlingConfigName;
+        String configPath = form.crawlingConfigPath.trim();
         if (StringUtil.isBlank(configName)) {
             configName = StringUtils.abbreviate(configPath, 30);
         }
 
         // normalize
-        final StringBuilder buf = new StringBuilder();
+        final StringBuilder buf = new StringBuilder(1000);
         for (int i = 0; i < configPath.length(); i++) {
             final char c = configPath.charAt(i);
             if (c == '\\') {
@@ -138,16 +157,16 @@ public class WizardAction implements Serializable {
                 wConfig.setBoost(1.0f);
                 wConfig.setCreatedBy(username);
                 wConfig.setCreatedTime(now);
-                if (StringUtil.isNotBlank(wizardForm.depth)) {
-                    wConfig.setDepth(Integer.parseInt(wizardForm.depth));
+                if (StringUtil.isNotBlank(form.depth)) {
+                    wConfig.setDepth(Integer.parseInt(form.depth));
                 }
                 wConfig.setExcludedDocUrls(getDefaultString("default.config.web.excludedDocUrls", StringUtil.EMPTY));
                 wConfig.setExcludedUrls(getDefaultString("default.config.web.excludedUrls", StringUtil.EMPTY));
                 wConfig.setIncludedDocUrls(getDefaultString("default.config.web.includedDocUrls", StringUtil.EMPTY));
                 wConfig.setIncludedUrls(getDefaultString("default.config.web.includedUrls", StringUtil.EMPTY));
                 wConfig.setIntervalTime(getDefaultInteger("default.config.web.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_WEB));
-                if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) {
-                    wConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount));
+                if (StringUtil.isNotBlank(form.maxAccessCount)) {
+                    wConfig.setMaxAccessCount(Long.parseLong(form.maxAccessCount));
                 }
                 wConfig.setName(configName);
                 wConfig.setNumOfThread(getDefaultInteger("default.config.web.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB));
@@ -166,16 +185,16 @@ public class WizardAction implements Serializable {
                 fConfig.setBoost(1.0f);
                 fConfig.setCreatedBy(username);
                 fConfig.setCreatedTime(now);
-                if (StringUtil.isNotBlank(wizardForm.depth)) {
-                    fConfig.setDepth(Integer.parseInt(wizardForm.depth));
+                if (StringUtil.isNotBlank(form.depth)) {
+                    fConfig.setDepth(Integer.parseInt(form.depth));
                 }
                 fConfig.setExcludedDocPaths(getDefaultString("default.config.file.excludedDocPaths", StringUtil.EMPTY));
                 fConfig.setExcludedPaths(getDefaultString("default.config.file.excludedPaths", StringUtil.EMPTY));
                 fConfig.setIncludedDocPaths(getDefaultString("default.config.file.includedDocPaths", StringUtil.EMPTY));
                 fConfig.setIncludedPaths(getDefaultString("default.config.file.includedPaths", StringUtil.EMPTY));
                 fConfig.setIntervalTime(getDefaultInteger("default.config.file.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_FS));
-                if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) {
-                    fConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount));
+                if (StringUtil.isNotBlank(form.maxAccessCount)) {
+                    fConfig.setMaxAccessCount(Long.parseLong(form.maxAccessCount));
                 }
                 fConfig.setName(configName);
                 fConfig.setNumOfThread(getDefaultInteger("default.config.file.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_FS));
@@ -188,8 +207,11 @@ public class WizardAction implements Serializable {
             }
             return configName;
         } catch (final Exception e) {
-            logger.error("Failed to create crawling config: " + wizardForm.crawlingConfigPath, e);
-            throw new SSCActionMessagesException(e, "errors.failed_to_create_crawling_config_at_wizard", wizardForm.crawlingConfigPath);
+            logger.error("Failed to create crawling config: " + form.crawlingConfigPath, e);
+            throwValidationError(messages -> messages.addErrorsFailedToCreateCrawlingConfigAtWizard(GLOBAL), () -> {
+                return asHtml(path_AdminWizard_CrawlingConfigJsp);
+            });
+            return null;
         }
     }
 
@@ -249,23 +271,23 @@ public class WizardAction implements Serializable {
     }
 
     @Token(save = true, validate = false)
-    //@Execute(validator = false)
-    public String startCrawlingForm() {
-        return "startCrawling.jsp";
+    @Execute
+    public HtmlResponse startCrawlingForm() {
+        return asHtml(path_AdminWizard_StartCrawlingJsp).useForm(StartCrawlingForm.class);
     }
 
     @Token(save = false, validate = true)
-    //@Execute(validator = false)
-    public String startCrawling() {
+    @Execute
+    public HtmlResponse startCrawling(StartCrawlingForm form) {
         if (!jobHelper.isCrawlProcessRunning()) {
             final List<ScheduledJob> scheduledJobList = scheduledJobService.getCrawloerJobList();
             for (final ScheduledJob scheduledJob : scheduledJobList) {
                 new Thread(() -> new TriggeredJob().execute(scheduledJob)).start();
             }
-            SAStrutsUtil.addSessionMessage("success.start_crawl_process");
+            saveInfo(messages -> messages.addSuccessStartCrawlProcess(GLOBAL));
         } else {
-            SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process");
+            saveError(messages -> messages.addErrorsFailedToStartCrawlProcess(GLOBAL));
         }
-        return "../system/index?redirect=true";
+        return redirect(AdminSystemAction.class);
     }
 }

+ 32 - 0
src/main/java/org/codelibs/fess/app/web/admin/wizard/CrawlingConfigForm.java

@@ -0,0 +1,32 @@
+package org.codelibs.fess.app.web.admin.wizard;
+
+import java.io.Serializable;
+
+import javax.validation.constraints.Size;
+
+import org.lastaflute.web.validation.Required;
+
+public class CrawlingConfigForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Required
+    @Size(max = 200)
+    public String crawlingConfigName;
+
+    @Required
+    @Size(max = 1000)
+    public String crawlingConfigPath;
+
+    // TODO
+    //    @Min(0)
+    //    @Max(Integer.MAX_VALUE)
+    public String depth;
+
+    // TODO
+    @Size(max = 100)
+    //    @Min(0)
+    //    @Max(Long.MAX_VALUE)
+    public String maxAccessCount;
+
+}

+ 9 - 0
src/main/java/org/codelibs/fess/app/web/admin/wizard/IndexForm.java

@@ -0,0 +1,9 @@
+package org.codelibs.fess.app.web.admin.wizard;
+
+import java.io.Serializable;
+
+public class IndexForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 9 - 0
src/main/java/org/codelibs/fess/app/web/admin/wizard/StartCrawlingForm.java

@@ -0,0 +1,9 @@
+package org.codelibs.fess.app.web.admin.wizard;
+
+import java.io.Serializable;
+
+public class StartCrawlingForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 6 - 0
src/main/java/org/codelibs/fess/app/web/base/FessAdminAction.java

@@ -47,6 +47,12 @@ public abstract class FessAdminAction extends FessBaseAction {
         sessionManager.info().save(messages);
     }
 
+    protected void saveError(final VaMessenger<FessMessages> validationMessagesLambda) {
+        final FessMessages messages = createMessages();
+        validationMessagesLambda.message(messages);
+        sessionManager.errors().save(messages);
+    }
+
     protected void write(final String path, final byte[] data) {
         LdiFileUtil.write(path, data);
     }

+ 0 - 207
src/main/webapp/WEB-INF/view/admin/document/index.jsp

@@ -1,207 +0,0 @@
-<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
-	flush="true">
-	<tiles:put name="title">
-		<la:message key="labels.system_title_configuration" />
-	</tiles:put>
-	<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
-	<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
-	<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
-	<tiles:put name="menuType" value="system" />
-	<tiles:put name="headerScript" type="string"></tiles:put>
-	<tiles:put name="body" type="string">
-
-		<div id="main">
-		<%-- Message: BEGIN --%>
-		<div>
-			<la:info id="msg" message="true">
-				<div class="alert-message info">${msg}</div>
-			</la:info>
-			<la:errors />
-		</div>
-		<%-- Message: END --%>
-
-<c:if test="${empty groupActionItems}">
-<div class="alert-message error"><la:message key="labels.no_available_solr_servers" /></div>
-</c:if>
-<c:if test="${!empty groupActionItems}">
-			<div>
-				<h3>
-					<la:message key="labels.es_title_action" />
-				</h3>
-				<table class="bordered-table zebra-striped">
-					<tbody>
-						<c:forEach var="groupAction" items="${groupActionItems}">
-							<la:form>
-							<tr>
-								<th style="width:200px;">${f:h(groupAction.groupName)}</th>
-								<td>
-									<la:hidden property="groupName"
-										value="${f:u(groupAction.groupName)}" />
-									<la:submit
-										property="commit" disabled="${solrProcessRunning}"
-										styleClass="btn">
-										<la:message key="labels.es_action_commit" />
-									</la:submit>
-									<la:submit property="optimize"
-										disabled="${solrProcessRunning}" styleClass="btn">
-										<la:message key="labels.es_action_optimize" />
-									</la:submit>
-								</td>
-							</tr>
-							</la:form>
-						</c:forEach>
-					</tbody>
-				</table>
-			</div>
-
-			<div style="margin-top: 5px;">
-				<h3>
-					<la:message key="labels.es_title_delete" />
-				</h3>
-				<table class="bordered-table zebra-striped">
-					<tbody>
-						<c:forEach var="groupAction" items="${groupActionItems}">
-							<la:form>
-							<tr>
-								<th style="width:200px;" rowspan="2">${f:h(groupAction.groupName)}</th>
-								<td>
-									<la:select property="sessionId"
-										disabled="${solrProcessRunning}">
-										<la:option value="">
-											<la:message key="labels.es_action_none" />
-										</la:option>
-										<c:forEach var="sessionIdItem"
-											items="${groupAction.sessionIdItems}">
-											<la:option value="${f:u(sessionIdItem.value)}">${f:h(sessionIdItem.label)}</la:option>
-										</c:forEach>
-										<la:option value="*">
-											<la:message key="labels.es_action_all" /> (${f:h(groupAction.totalCount)})</la:option>
-									</la:select>
-									<la:submit styleClass="btn" property="delete"
-										disabled="${solrProcessRunning}">
-										<la:message key="labels.es_action_delete" />
-									</la:submit>
-									<la:hidden property="groupName"
-										value="${f:u(groupAction.groupName)}" />
-								</td>
-							</tr>
-							<tr>
-								<td style="vertical-align: middle;">
-									<la:message key="labels.es_action_url_delete" />
-									<la:text property="deleteUrl" style="width:150px;"
-										disabled="${solrProcessRunning}"></la:text> <la:submit
-										property="confirmByUrl" styleClass="btn"
-										disabled="${solrProcessRunning}">
-										<la:message key="labels.es_action_confirm_list" />
-									</la:submit>
-									<la:submit property="deleteByUrl"
-										disabled="${solrProcessRunning}" styleClass="btn">
-										<la:message key="labels.es_action_delete" />
-									</la:submit>
-								</td>
-							</tr>
-							</la:form>
-						</c:forEach>
-					</tbody>
-				</table>
-			</div>
-
-			<div style="margin-top: 5px;">
-				<h3>
-					<la:message key="labels.es_document_title" />
-				</h3>
-				<table class="bordered-table zebra-striped">
-					<thead>
-						<tr>
-							<th style="width:200px;"><la:message key="labels.es_group_name" /></th>
-							<th><la:message key="labels.session_name" /></th>
-							<th><la:message key="labels.es_num_of_docs" /></th>
-						</tr>
-					</thead>
-					<tbody>
-						<c:forEach var="groupAction" items="${groupActionItems}">
-							<tr>
-								<td>${f:h(groupAction.groupName)}</td>
-								<td align="center"><la:message
-										key="labels.system_document_all" /></td>
-								<td align="center">${f:h(groupAction.totalCount)}</td>
-							</tr>
-						</c:forEach>
-						<c:forEach var="groupAction" items="${groupActionItems}">
-							<c:forEach var="sessionIdItem"
-								items="${groupAction.sessionIdItems}">
-								<tr>
-									<td>${f:h(groupAction.groupName)}</td>
-									<td align="center"><la:link
-											href="${f:url('/admin/searchList/search')}?query=segment:${f:u(sessionIdItem.value)}">${f:h(sessionIdItem.value)}</la:link></td>
-									<td align="center">${f:h(sessionIdItem.count)}</td>
-								</tr>
-							</c:forEach>
-						</c:forEach>
-					</tbody>
-				</table>
-			</div>
-			<div style="margin-top: 5px;">
-				<h3>
-					<la:message key="labels.suggest_document_title" />
-				</h3>
-				<table class="bordered-table zebra-striped">
-					<thead>
-						<tr>
-							<th style="width:200px;"><la:message key="labels.suggest_type" /></th>
-							<th><la:message key="labels.es_num_of_docs" /></th>
-							<th></th>
-						</tr>
-					</thead>
-					<tbody>
-						<tr>
-							<td style="vertical-align: middle;"><la:message key="labels.suggest_type_all" /></td>
-							<td align="center" style="vertical-align: middle;">${suggestDocumentNums.all}</td>
-							<td align="center">
-							</td>
-						</tr>
-						<tr>
-							<td style="vertical-align: middle;"><la:message key="labels.suggest_type_content" /></td>
-							<td align="center" style="vertical-align: middle;">${suggestDocumentNums.content}</td>
-							<td align="center">
-								<la:form style="margin-bottom:0;">
-									<la:hidden property="deleteSuggestType"
-										value="content" />
-									<la:submit styleClass="btn" property="deleteSuggest"
-										disabled="${solrProcessRunning}">
-										<la:message key="labels.es_action_delete" />
-									</la:submit>
-								</la:form>
-							</td>
-						</tr>
-						<tr>
-							<td style="vertical-align: middle;"><la:message key="labels.suggest_type_searchlog" /></td>
-							<td align="center" style="vertical-align: middle;">${suggestDocumentNums.searchLog}</td>
-							<td align="center">
-								<la:form style="margin-bottom:0;">
-									<la:hidden property="deleteSuggestType"
-										value="searchLog" />
-									<la:submit styleClass="btn" property="deleteSuggest"
-										disabled="${solrProcessRunning}">
-										<la:message key="labels.es_action_delete" />
-									</la:submit>
-								</la:form>
-							</td>
-						</tr>
-					</tbody>
-				</table>
-			</div>
-			</c:if>
-		</div>
-
-		<c:if test="${solrProcessRunning}">
-			<script type="text/javascript">
-			<!--
-				setTimeout(function() {
-					window.location.reload();
-				}, 15000);
-			// -->
-			</script>
-		</c:if>
-	</tiles:put>
-</tiles:insert>

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

@@ -27,10 +27,10 @@
 				></i> <span><la:message key="labels.menu_system" /></span> <i class="fa fa-angle-left pull-right"></i></a>
 				<ul class="treeview-menu">
 
-					<li <c:if test="${param.menuType=='wizard'}">class="active"</c:if>><todo:link href="/admin/wizard/index">
+					<li <c:if test="${param.menuType=='wizard'}">class="active"</c:if>><la:link href="/admin/wizard/index">
 							<i class='fa fa-angle-right'></i>
 							<span><la:message key="labels.menu.wizard" /></span>
-						</todo:link></li>
+						</la:link></li>
 
 					<li <c:if test="${param.menuType=='crawl'}">class="active"</c:if>><la:link href="/admin/crawl/index">
 							<i class='fa fa-angle-right'></i>