|
@@ -17,35 +17,57 @@
|
|
package org.codelibs.fess.web.admin;
|
|
package org.codelibs.fess.web.admin;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
-import org.apache.commons.logging.Log;
|
|
|
|
-import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.codelibs.fess.beans.FessBeans;
|
|
import org.codelibs.fess.beans.FessBeans;
|
|
import org.codelibs.fess.crud.CommonConstants;
|
|
import org.codelibs.fess.crud.CommonConstants;
|
|
import org.codelibs.fess.crud.CrudMessageException;
|
|
import org.codelibs.fess.crud.CrudMessageException;
|
|
-import org.codelibs.fess.crud.action.admin.BsWebCrawlingConfigAction;
|
|
|
|
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
|
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
|
import org.codelibs.fess.db.exentity.CrawlingConfig;
|
|
import org.codelibs.fess.db.exentity.CrawlingConfig;
|
|
import org.codelibs.fess.db.exentity.LabelType;
|
|
import org.codelibs.fess.db.exentity.LabelType;
|
|
import org.codelibs.fess.db.exentity.RoleType;
|
|
import org.codelibs.fess.db.exentity.RoleType;
|
|
import org.codelibs.fess.db.exentity.WebCrawlingConfig;
|
|
import org.codelibs.fess.db.exentity.WebCrawlingConfig;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
|
|
+import org.codelibs.fess.pager.WebCrawlingConfigPager;
|
|
import org.codelibs.fess.service.FailureUrlService;
|
|
import org.codelibs.fess.service.FailureUrlService;
|
|
import org.codelibs.fess.service.LabelTypeService;
|
|
import org.codelibs.fess.service.LabelTypeService;
|
|
import org.codelibs.fess.service.RoleTypeService;
|
|
import org.codelibs.fess.service.RoleTypeService;
|
|
|
|
+import org.codelibs.fess.service.WebCrawlingConfigService;
|
|
|
|
+import org.codelibs.fess.web.base.FessAdminAction;
|
|
|
|
+import org.codelibs.sastruts.core.annotation.Token;
|
|
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
|
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
|
|
|
+import org.seasar.framework.beans.util.Beans;
|
|
|
|
+import org.seasar.framework.util.StringUtil;
|
|
|
|
+import org.seasar.struts.annotation.ActionForm;
|
|
import org.seasar.struts.annotation.Execute;
|
|
import org.seasar.struts.annotation.Execute;
|
|
import org.seasar.struts.exception.ActionMessagesException;
|
|
import org.seasar.struts.exception.ActionMessagesException;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|
|
|
|
|
+public class WebCrawlingConfigAction extends FessAdminAction {
|
|
|
|
|
|
- private static final long serialVersionUID = 1L;
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(WebCrawlingConfigAction.class);
|
|
|
|
|
|
- private static final Log log = LogFactory.getLog(WebCrawlingConfigAction.class);
|
|
|
|
|
|
+ // for list
|
|
|
|
|
|
|
|
+ public List<WebCrawlingConfig> webCrawlingConfigItems;
|
|
|
|
+
|
|
|
|
+ // for edit/confirm/delete
|
|
|
|
+
|
|
|
|
+ @ActionForm
|
|
|
|
+ @Resource
|
|
|
|
+ protected WebCrawlingConfigForm webCrawlingConfigForm;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ protected WebCrawlingConfigService webCrawlingConfigService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ protected WebCrawlingConfigPager webCrawlingConfigPager;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
protected RoleTypeService roleTypeService;
|
|
protected RoleTypeService roleTypeService;
|
|
|
|
|
|
@@ -61,8 +83,201 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|
public String getHelpLink() {
|
|
public String getHelpLink() {
|
|
return systemHelper.getHelpLink("webCrawlingConfig");
|
|
return systemHelper.getHelpLink("webCrawlingConfig");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ protected String displayList(final boolean redirect) {
|
|
|
|
+ // page navi
|
|
|
|
+ webCrawlingConfigItems = webCrawlingConfigService.getWebCrawlingConfigList(webCrawlingConfigPager);
|
|
|
|
+
|
|
|
|
+ // restore from pager
|
|
|
|
+ Beans.copy(webCrawlingConfigPager, webCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
|
+
|
|
|
|
+ .execute();
|
|
|
|
+
|
|
|
|
+ if (redirect) {
|
|
|
|
+ return "index?redirect=true";
|
|
|
|
+ } else {
|
|
|
|
+ return "index.jsp";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String index() {
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
|
|
|
+ public String list() {
|
|
|
|
+ // page navi
|
|
|
|
+ if (StringUtil.isNotBlank(webCrawlingConfigForm.pageNumber)) {
|
|
|
|
+ try {
|
|
|
|
+ webCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(webCrawlingConfigForm.pageNumber));
|
|
|
|
+ } catch (final NumberFormatException e) {
|
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
|
+ logger.debug("Invalid value: " + webCrawlingConfigForm.pageNumber, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String search() {
|
|
|
|
+ Beans.copy(webCrawlingConfigForm.searchParams, webCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
|
+
|
|
|
|
+ .execute();
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String reset() {
|
|
|
|
+ webCrawlingConfigPager.clear();
|
|
|
|
+
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String back() {
|
|
|
|
+ return displayList(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String editagain() {
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
|
|
|
+ public String confirmpage() {
|
|
|
|
+ if (webCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
|
|
|
+ webCrawlingConfigForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadWebCrawlingConfig();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String createpage() {
|
|
|
|
+ // page navi
|
|
|
|
+ webCrawlingConfigForm.initialize();
|
|
|
|
+ webCrawlingConfigForm.crudMode = CommonConstants.CREATE_MODE;
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
|
|
|
+ public String editpage() {
|
|
|
|
+ if (webCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
|
|
|
+ webCrawlingConfigForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadWebCrawlingConfig();
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String editfromconfirm() {
|
|
|
|
+ webCrawlingConfigForm.crudMode = CommonConstants.EDIT_MODE;
|
|
|
|
+
|
|
|
|
+ loadWebCrawlingConfig();
|
|
|
|
+
|
|
|
|
+ return "edit.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String confirmfromcreate() {
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String confirmfromupdate() {
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
|
|
|
+ public String deletepage() {
|
|
|
|
+ if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
|
|
|
+ webCrawlingConfigForm.crudMode });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ loadWebCrawlingConfig();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = true, validate = false)
|
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
|
+ public String deletefromconfirm() {
|
|
|
|
+ webCrawlingConfigForm.crudMode = CommonConstants.DELETE_MODE;
|
|
|
|
+
|
|
|
|
+ loadWebCrawlingConfig();
|
|
|
|
+
|
|
|
|
+ return "confirm.jsp";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String create() {
|
|
|
|
+ try {
|
|
|
|
+ final WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
|
|
|
+ webCrawlingConfigService.store(webCrawlingConfig);
|
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
|
|
|
+
|
|
|
|
+ return displayList(true);
|
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
|
+ } catch (final Exception e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Token(save = false, validate = true)
|
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
|
+ public String update() {
|
|
|
|
+ try {
|
|
|
|
+ final WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
|
|
|
+ webCrawlingConfigService.store(webCrawlingConfig);
|
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
|
|
|
+
|
|
|
|
+ return displayList(true);
|
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
|
+ } catch (final Exception e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected Map<String, String> createKeyMap() {
|
|
|
|
+ final Map<String, String> keys = new HashMap<String, String>();
|
|
|
|
+
|
|
|
|
+ keys.put("id", webCrawlingConfigForm.id);
|
|
|
|
+
|
|
|
|
+ return keys;
|
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
|
protected void loadWebCrawlingConfig() {
|
|
protected void loadWebCrawlingConfig() {
|
|
|
|
|
|
final CrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
|
final CrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
|
@@ -79,7 +294,6 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
protected WebCrawlingConfig createWebCrawlingConfig() {
|
|
protected WebCrawlingConfig createWebCrawlingConfig() {
|
|
WebCrawlingConfig webCrawlingConfig;
|
|
WebCrawlingConfig webCrawlingConfig;
|
|
final String username = systemHelper.getUsername();
|
|
final String username = systemHelper.getUsername();
|
|
@@ -102,7 +316,6 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|
return webCrawlingConfig;
|
|
return webCrawlingConfig;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
@Execute(validator = false, input = "error.jsp")
|
|
@Execute(validator = false, input = "error.jsp")
|
|
public String delete() {
|
|
public String delete() {
|
|
if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
@@ -129,13 +342,13 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|
|
|
|
|
return displayList(true);
|
|
return displayList(true);
|
|
} catch (final ActionMessagesException e) {
|
|
} catch (final ActionMessagesException e) {
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
throw e;
|
|
throw e;
|
|
} catch (final CrudMessageException e) {
|
|
} catch (final CrudMessageException e) {
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
|
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
|
} catch (final Exception e) {
|
|
} catch (final Exception e) {
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
|
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
|
}
|
|
}
|
|
}
|
|
}
|