JobLogAction.java

This commit is contained in:
Shunji Makino 2015-04-02 17:57:53 +09:00
commit 81dc804122
4 changed files with 512 additions and 2 deletions

View file

@ -51,7 +51,11 @@ import org.slf4j.LoggerFactory;
public class FileCrawlingConfigAction extends FessAdminAction {
private static final Logger logger = LoggerFactory.getLogger(FileCrawlingConfigAction.class);
<<<<<<< HEAD
=======
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
// for list
public List<FileCrawlingConfig> fileCrawlingConfigItems;
@ -83,7 +87,7 @@ public class FileCrawlingConfigAction extends FessAdminAction {
public String getHelpLink() {
return systemHelper.getHelpLink("fileCrawlingConfig");
}
protected String displayList(final boolean redirect) {
// page navi
fileCrawlingConfigItems = fileCrawlingConfigService.getFileCrawlingConfigList(fileCrawlingConfigPager);
@ -178,6 +182,103 @@ public class FileCrawlingConfigAction extends FessAdminAction {
fileCrawlingConfigForm.crudMode });
}
<<<<<<< HEAD
protected String displayList(final boolean redirect) {
// page navi
fileCrawlingConfigItems = fileCrawlingConfigService.getFileCrawlingConfigList(fileCrawlingConfigPager);
// restore from pager
Beans.copy(fileCrawlingConfigPager, fileCrawlingConfigForm.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(fileCrawlingConfigForm.pageNumber)) {
try {
fileCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(fileCrawlingConfigForm.pageNumber));
} catch (final NumberFormatException e) {
if (logger.isDebugEnabled()) {
logger.debug("Invalid value: " + fileCrawlingConfigForm.pageNumber, e);
}
}
}
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String search() {
Beans.copy(fileCrawlingConfigForm.searchParams, fileCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
.execute();
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String reset() {
fileCrawlingConfigPager.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 (fileCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
fileCrawlingConfigForm.crudMode });
}
loadFileCrawlingConfig();
return "confirm.jsp";
}
@Token(save = true, validate = false)
@Execute(validator = false, input = "error.jsp")
public String createpage() {
// page navi
fileCrawlingConfigForm.initialize();
fileCrawlingConfigForm.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 (fileCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
fileCrawlingConfigForm.crudMode });
}
=======
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
loadFileCrawlingConfig();
return "edit.jsp";
@ -277,7 +378,11 @@ public class FileCrawlingConfigAction extends FessAdminAction {
return keys;
}
<<<<<<< HEAD
=======
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
protected void loadFileCrawlingConfig() {
final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap());

View file

@ -27,6 +27,13 @@ import org.codelibs.fess.Constants;
import org.codelibs.fess.action.base.FessAdminAction;
import org.codelibs.fess.crud.CommonConstants;
import org.codelibs.fess.crud.CrudMessageException;
<<<<<<< HEAD
=======
<<<<<<< HEAD
=======
import org.codelibs.fess.crud.action.admin.BsJobLogAction;
>>>>>>> 51bcde16892e677a8f00914daaa2b948b12451c6
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
import org.codelibs.fess.crud.util.SAStrutsUtil;
import org.codelibs.fess.db.exentity.JobLog;
import org.codelibs.fess.form.admin.JobLogForm;
@ -44,8 +51,17 @@ import org.slf4j.LoggerFactory;
public class JobLogAction extends FessAdminAction {
<<<<<<< HEAD
private static final Logger logger = LoggerFactory.getLogger(JobLogAction.class);
=======
<<<<<<< HEAD
private static final Logger logger = LoggerFactory.getLogger(JobLogAction.class);
=======
private static final Logger logger = LoggerFactory.getLogger(BsJobLogAction.class);
>>>>>>> 51bcde16892e677a8f00914daaa2b948b12451c6
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
// for list
public List<JobLog> jobLogItems;
@ -68,6 +84,268 @@ public class JobLogAction extends FessAdminAction {
public String getHelpLink() {
return systemHelper.getHelpLink("jobLog");
}
protected String displayList(final boolean redirect) {
// page navi
jobLogItems = jobLogService.getJobLogList(jobLogPager);
// restore from pager
Beans.copy(jobLogPager, jobLogForm.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(jobLogForm.pageNumber)) {
try {
jobLogPager.setCurrentPageNumber(Integer.parseInt(jobLogForm.pageNumber));
} catch (final NumberFormatException e) {
if (logger.isDebugEnabled()) {
logger.debug("Invalid value: " + jobLogForm.pageNumber, e);
}
}
}
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String search() {
Beans.copy(jobLogForm.searchParams, jobLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
.execute();
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String reset() {
jobLogPager.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 (jobLogForm.crudMode != CommonConstants.CONFIRM_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode",
new Object[] { CommonConstants.CONFIRM_MODE, jobLogForm.crudMode });
}
loadJobLog();
return "confirm.jsp";
}
@Token(save = true, validate = false)
@Execute(validator = false, input = "error.jsp")
public String createpage() {
// page navi
jobLogForm.initialize();
jobLogForm.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 (jobLogForm.crudMode != CommonConstants.EDIT_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, jobLogForm.crudMode });
}
loadJobLog();
return "edit.jsp";
}
@Token(save = true, validate = false)
@Execute(validator = false, input = "error.jsp")
public String editfromconfirm() {
jobLogForm.crudMode = CommonConstants.EDIT_MODE;
loadJobLog();
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 (jobLogForm.crudMode != CommonConstants.DELETE_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, jobLogForm.crudMode });
}
loadJobLog();
return "confirm.jsp";
}
@Token(save = true, validate = false)
@Execute(validator = false, input = "error.jsp")
public String deletefromconfirm() {
jobLogForm.crudMode = CommonConstants.DELETE_MODE;
loadJobLog();
return "confirm.jsp";
}
@Token(save = false, validate = true)
@Execute(validator = true, input = "edit.jsp")
public String create() {
try {
final JobLog jobLog = createJobLog();
jobLogService.store(jobLog);
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 JobLog jobLog = createJobLog();
jobLogService.store(jobLog);
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");
}
}
@Token(save = false, validate = true)
@Execute(validator = false, input = "error.jsp")
public String delete() {
if (jobLogForm.crudMode != CommonConstants.DELETE_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, jobLogForm.crudMode });
}
try {
final JobLog jobLog = jobLogService.getJobLog(createKeyMap());
if (jobLog == null) {
// throw an exception
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
new Object[] { jobLogForm.id });
}
jobLogService.delete(jobLog);
SAStrutsUtil.addSessionMessage("success.crud_delete_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_delete_crud_table");
}
}
protected void loadJobLog() {
final JobLog jobLog = jobLogService.getJobLog(createKeyMap());
if (jobLog == null) {
// throw an exception
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
new Object[] { jobLogForm.id });
}
Beans.copy(jobLog, jobLogForm).excludes("searchParams", "mode")
.execute();
}
protected JobLog createJobLog() {
JobLog jobLog;
if (jobLogForm.crudMode == CommonConstants.EDIT_MODE) {
jobLog = jobLogService.getJobLog(createKeyMap());
if (jobLog == null) {
// throw an exception
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
new Object[] { jobLogForm.id });
}
} else {
jobLog = new JobLog();
}
Beans.copy(jobLogForm, jobLog).excludes("searchParams", "mode")
.execute();
return jobLog;
}
protected Map<String, String> createKeyMap() {
final Map<String, String> keys = new HashMap<String, String>();
keys.put("id", jobLogForm.id);
return keys;
}
protected String displayList(final boolean redirect) {
// page navi

View file

@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
public class KeyMatchAction extends FessAdminAction {
private static final Logger logger = LoggerFactory.getLogger(KeyMatchAction.class);
<<<<<<< HEAD
// for list
@ -63,14 +64,32 @@ public class KeyMatchAction extends FessAdminAction {
@Resource
protected KeyMatchPager keyMatchPager;
=======
// for list
public List<KeyMatch> keyMatchItems;
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
// for edit/confirm/delete
@ActionForm
@Resource
protected KeyMatchForm keyMatchForm;
@Resource
protected KeyMatchService keyMatchService;
@Resource
protected KeyMatchPager keyMatchPager;
@Resource
protected SystemHelper systemHelper;
public String getHelpLink() {
return systemHelper.getHelpLink("keyMatch");
}
protected String displayList(final boolean redirect) {
// page navi
keyMatchItems = keyMatchService.getKeyMatchList(keyMatchPager);
@ -164,6 +183,102 @@ public class KeyMatchAction extends FessAdminAction {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, keyMatchForm.crudMode });
}
<<<<<<< HEAD
protected String displayList(final boolean redirect) {
// page navi
keyMatchItems = keyMatchService.getKeyMatchList(keyMatchPager);
// restore from pager
Beans.copy(keyMatchPager, keyMatchForm.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(keyMatchForm.pageNumber)) {
try {
keyMatchPager.setCurrentPageNumber(Integer.parseInt(keyMatchForm.pageNumber));
} catch (final NumberFormatException e) {
if (logger.isDebugEnabled()) {
logger.debug("Invalid value: " + keyMatchForm.pageNumber, e);
}
}
}
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String search() {
Beans.copy(keyMatchForm.searchParams, keyMatchPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
.execute();
return displayList(false);
}
@Execute(validator = false, input = "error.jsp")
public String reset() {
keyMatchPager.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 (keyMatchForm.crudMode != CommonConstants.CONFIRM_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
keyMatchForm.crudMode });
}
loadKeyMatch();
return "confirm.jsp";
}
@Token(save = true, validate = false)
@Execute(validator = false, input = "error.jsp")
public String createpage() {
// page navi
keyMatchForm.initialize();
keyMatchForm.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 (keyMatchForm.crudMode != CommonConstants.EDIT_MODE) {
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, keyMatchForm.crudMode });
}
=======
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
loadKeyMatch();
return "edit.jsp";
@ -221,7 +336,11 @@ public class KeyMatchAction extends FessAdminAction {
return keys;
}
<<<<<<< HEAD
=======
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
protected void loadKeyMatch() {
final KeyMatch keyMatch = keyMatchService.getKeyMatch(createKeyMap());
@ -280,14 +399,22 @@ public class KeyMatchAction extends FessAdminAction {
@Token(save = false, validate = true)
@Execute(validator = true, input = "edit.jsp")
public String update() {
<<<<<<< HEAD
=======
ComponentUtil.getKeyMatchHelper().update();
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
try {
final KeyMatch keyMatch = createKeyMatch();
keyMatchService.store(keyMatch);
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
<<<<<<< HEAD
final String result = displayList(true);
ComponentUtil.getKeyMatchHelper().update();
return result;
=======
return displayList(true);
>>>>>>> 54e5e6c69f136354f051f88cbbd9aa07a3648500
} catch (final ActionMessagesException e) {
logger.error(e.getMessage(), e);
throw e;