modify system action

This commit is contained in:
Keiichi Watanabe 2015-09-14 19:04:58 +09:00
parent 9771ee9b0c
commit ac64474e85
3 changed files with 56 additions and 51 deletions

View file

@ -14,9 +14,8 @@
* governing permissions and limitations under the License.
*/
package org.codelibs.fess.app.web.admin;
package org.codelibs.fess.app.web.admin.system;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
@ -24,91 +23,93 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.misc.DynamicProperties;
import org.codelibs.fess.annotation.Token;
import org.codelibs.fess.client.FessEsClient;
import org.codelibs.fess.crud.util.SAStrutsUtil;
import org.codelibs.fess.app.service.ScheduledJobService;
import org.codelibs.fess.app.web.base.FessAdminAction;
import org.codelibs.fess.es.exentity.ScheduledJob;
import org.codelibs.fess.helper.JobHelper;
import org.codelibs.fess.helper.SystemHelper;
import org.codelibs.fess.app.service.ScheduledJobService;
import org.lastaflute.web.Execute;
import org.lastaflute.web.callback.ActionRuntime;
import org.lastaflute.web.response.HtmlResponse;
import org.lastaflute.web.util.LaRequestUtil;
public class SystemAction implements Serializable {
/**
* @author Keiichi Watanabe
*/
public class AdminSystemAction extends FessAdminAction {
// ===================================================================================
// Attribute
// =========
private static final String STARTING_CRAWL_PROCESS = "startingCrawlProcess";
private static final long serialVersionUID = 1L;
//@ActionForm
@Resource
protected SystemForm systemForm;
private SystemHelper systemHelper;
@Resource
protected FessEsClient fessEsClient;
@Resource
protected SystemHelper systemHelper;
protected DynamicProperties crawlerProperties;
@Resource
protected JobHelper jobHelper;
@Resource
protected ScheduledJobService scheduledJobService;
public String clusterName;
public String clusterStatus;
public String getHelpLink() {
return systemHelper.getHelpLink("system");
// ===================================================================================
// Hook
// ======
@Override
protected void setupHtmlData(final ActionRuntime runtime) {
super.setupHtmlData(runtime);
runtime.registerData("helpLink", systemHelper.getHelpLink("system"));
}
protected String showIndex(final boolean redirect) {
if (redirect) {
return "index?redirect=true";
} else {
return "index.jsp";
}
}
@Token(save = true, validate = false)
//@Execute(validator = false)
public String index() {
return showIndex(false);
// ===================================================================================
// Index
// ==============
@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());
});
}
@Token(save = false, validate = true)
//@Execute(validator = true, input = "index")
public String start() {
// @Execute(validator = true, input = "index")
public HtmlResponse start(final SystemForm form) {
if (!jobHelper.isCrawlProcessRunning()) {
final List<ScheduledJob> scheduledJobList = scheduledJobService.getCrawloerJobList();
for (final ScheduledJob scheduledJob : scheduledJobList) {
scheduledJob.start();
}
SAStrutsUtil.addSessionMessage("success.start_crawl_process");
saveInfo(messages -> messages.addSuccessStartCrawlProcess(GLOBAL));
LaRequestUtil.getRequest().getSession().setAttribute(STARTING_CRAWL_PROCESS, Boolean.TRUE);
} else {
SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process");
saveInfo(messages -> messages.addErrorsFailedToStartCrawlProcess(GLOBAL));
}
return showIndex(true);
return redirect(getClass());
}
@Token(save = false, validate = true)
//@Execute(validator = true, input = "index")
public String stop() {
public HtmlResponse stop(final SystemForm form) {
if (jobHelper.isCrawlProcessRunning()) {
if (StringUtil.isNotBlank(systemForm.sessionId)) {
jobHelper.destroyCrawlerProcess(systemForm.sessionId);
if (StringUtil.isNotBlank(form.sessionId)) {
jobHelper.destroyCrawlerProcess(form.sessionId);
} else {
for (final String sessionId : jobHelper.getRunningSessionIdSet()) {
jobHelper.destroyCrawlerProcess(sessionId);
}
}
SAStrutsUtil.addSessionMessage("success.stopping_crawl_process");
saveInfo(messages -> messages.addSuccessStoppingCrawlProcess(GLOBAL));
} else {
SAStrutsUtil.addSessionMessage("errors.no_running_crawl_process");
saveInfo(messages -> messages.addErrorsNoRunningCrawlProcess(GLOBAL));
}
return showIndex(true);
return redirect(getClass());
}
public boolean isCrawlerRunning() {
@ -128,4 +129,4 @@ public class SystemAction implements Serializable {
return idSet.toArray(new String[idSet.size()]);
}
}
}

View file

@ -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.system;
import java.io.Serializable;
/**
* @author codelibs
* @author Keiichi Watanabe
*/
public class SystemForm implements Serializable {
private static final long serialVersionUID = 1L;

View file

@ -37,10 +37,10 @@
<span><la:message key="labels.menu.crawl_config" /></span>
</la:link></li>
<li <c:if test="${param.menuType=='system'}">class="active"</c:if>><todo:link href="/admin/system/index">
<li <c:if test="${param.menuType=='system'}">class="active"</c:if>><la:link href="/admin/system/index">
<i class='fa fa-angle-right'></i>
<span><la:message key="labels.menu.system_config" /></span>
</todo:link></li>
</la:link></li>
<li <c:if test="${param.menuType=='scheduledJob'}">class="active"</c:if>><la:link
href="/admin/scheduledjob/index"