Merge pull request #266 from nullpos/issue-250
merge some files for issue #250
This commit is contained in:
commit
1a6ee859bd
14 changed files with 1659 additions and 2411 deletions
|
@ -17,36 +17,58 @@
|
|||
package org.codelibs.fess.action.admin;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsRoleTypeAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.form.admin.RoleTypeForm;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.RoleTypePager;
|
||||
import org.codelibs.fess.service.RoleTypeService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
import org.seasar.struts.annotation.ActionForm;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RoleTypeAction extends BsRoleTypeAction {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(RoleTypeAction.class);
|
||||
public class RoleTypeAction extends FessAdminAction {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RoleTypeAction.class);
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
// for list
|
||||
|
||||
public List<RoleType> roleTypeItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected RoleTypeForm roleTypeForm;
|
||||
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
|
||||
@Resource
|
||||
protected RoleTypePager roleTypePager;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("roleType");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
|
@ -54,7 +76,6 @@ public class RoleTypeAction extends BsRoleTypeAction {
|
|||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
|
@ -62,9 +83,164 @@ public class RoleTypeAction extends BsRoleTypeAction {
|
|||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRoleType() {
|
||||
@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(roleTypeForm.pageNumber)) {
|
||||
try {
|
||||
roleTypePager.setCurrentPageNumber(Integer.parseInt(roleTypeForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + roleTypeForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(roleTypeForm.searchParams, roleTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
roleTypePager.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 (roleTypeForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
roleTypeForm.initialize();
|
||||
roleTypeForm.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 (roleTypeForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
roleTypeForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
roleTypeForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final RoleType roleType = createRoleType();
|
||||
roleTypeService.store(roleType);
|
||||
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 RoleType roleType = createRoleType();
|
||||
roleTypeService.store(roleType);
|
||||
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 void loadRoleType() {
|
||||
final RoleType roleType = roleTypeService.getRoleType(createKeyMap());
|
||||
if (roleType == null) {
|
||||
// throw an exception
|
||||
|
@ -74,7 +250,14 @@ public class RoleTypeAction extends BsRoleTypeAction {
|
|||
FessBeans.copy(roleType, roleTypeForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", roleTypeForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected RoleType createRoleType() {
|
||||
RoleType roleType;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -98,7 +281,6 @@ public class RoleTypeAction extends BsRoleTypeAction {
|
|||
return roleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
|
@ -124,14 +306,30 @@ public class RoleTypeAction extends BsRoleTypeAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
roleTypeItems = roleTypeService.getRoleTypeList(roleTypePager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(roleTypePager, roleTypeForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,33 +17,41 @@
|
|||
package org.codelibs.fess.action.admin;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsScheduledJobAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.db.exentity.ScheduledJob;
|
||||
import org.codelibs.fess.form.admin.ScheduledJobForm;
|
||||
import org.codelibs.fess.pager.ScheduledJobPager;
|
||||
import org.codelibs.fess.service.ScheduledJobService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.helper.JobHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.job.JobExecutor;
|
||||
import org.codelibs.fess.service.RoleTypeService;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ScheduledJobAction extends BsScheduledJobAction {
|
||||
public class ScheduledJobAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(ScheduledJobAction.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScheduledJobAction.class);
|
||||
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
|
@ -54,13 +62,28 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
@Resource
|
||||
protected JobHelper jobHelper;
|
||||
|
||||
// for list
|
||||
|
||||
public List<ScheduledJob> scheduledJobItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected ScheduledJobForm scheduledJobForm;
|
||||
|
||||
@Resource
|
||||
protected ScheduledJobService scheduledJobService;
|
||||
|
||||
@Resource
|
||||
protected ScheduledJobPager scheduledJobPager;
|
||||
|
||||
public boolean running = false;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("scheduledJob");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadScheduledJob() {
|
||||
|
||||
final ScheduledJob scheduledJob = getScheduledJob();
|
||||
|
@ -72,7 +95,6 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
running = scheduledJob.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScheduledJob createScheduledJob() {
|
||||
ScheduledJob scheduledJob;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -98,7 +120,6 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
return scheduledJob;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -118,13 +139,13 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +158,7 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
SAStrutsUtil.addSessionMessage("success.job_started", scheduledJob.getName());
|
||||
return displayList(true);
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_start_job", scheduledJob.getName());
|
||||
}
|
||||
|
||||
|
@ -152,7 +173,7 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
SAStrutsUtil.addSessionMessage("success.job_stopped", scheduledJob.getName());
|
||||
return displayList(true);
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_stop_job", scheduledJob.getName());
|
||||
}
|
||||
}
|
||||
|
@ -169,4 +190,198 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|||
}
|
||||
return scheduledJob;
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
scheduledJobItems = scheduledJobService.getScheduledJobList(scheduledJobPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(scheduledJobPager, scheduledJobForm.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(scheduledJobForm.pageNumber)) {
|
||||
try {
|
||||
scheduledJobPager.setCurrentPageNumber(Integer.parseInt(scheduledJobForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + scheduledJobForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(scheduledJobForm.searchParams, scheduledJobPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
scheduledJobPager.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 (scheduledJobForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
scheduledJobForm.initialize();
|
||||
scheduledJobForm.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 (scheduledJobForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
scheduledJobForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
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 (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
scheduledJobForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final ScheduledJob scheduledJob = createScheduledJob();
|
||||
scheduledJobService.store(scheduledJob);
|
||||
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 ScheduledJob scheduledJob = createScheduledJob();
|
||||
scheduledJobService.store(scheduledJob);
|
||||
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", scheduledJobForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,31 +30,313 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.core.util.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.action.admin.BsSearchLogAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.db.exentity.SearchLog;
|
||||
import org.codelibs.fess.form.admin.SearchLogForm;
|
||||
import org.codelibs.fess.pager.SearchLogPager;
|
||||
import org.codelibs.fess.service.SearchLogService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
import org.seasar.struts.util.RequestUtil;
|
||||
import org.seasar.struts.util.ResponseUtil;
|
||||
import org.seasar.struts.annotation.ActionForm;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
|
||||
public class SearchLogAction extends BsSearchLogAction {
|
||||
private static final Log log = LogFactory.getLog(SearchLogAction.class);
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class SearchLogAction extends FessAdminAction {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SearchLogAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<SearchLog> searchLogItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SearchLogForm searchLogForm;
|
||||
|
||||
@Resource
|
||||
protected SearchLogService searchLogService;
|
||||
|
||||
@Resource
|
||||
protected SearchLogPager searchLogPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
searchLogItems = searchLogService.getSearchLogList(searchLogPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(searchLogPager, searchLogForm.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(searchLogForm.pageNumber)) {
|
||||
try {
|
||||
searchLogPager.setCurrentPageNumber(Integer.parseInt(searchLogForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + searchLogForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
searchLogPager.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 (searchLogForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
searchLogForm.initialize();
|
||||
searchLogForm.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 (searchLogForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.EDIT_MODE, searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
searchLogForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
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 (searchLogForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
searchLogForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SearchLog searchLog = createSearchLog();
|
||||
searchLogService.store(searchLog);
|
||||
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 SearchLog searchLog = createSearchLog();
|
||||
searchLogService.store(searchLog);
|
||||
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 (searchLogForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
|
||||
searchLogService.delete(searchLog);
|
||||
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 loadSearchLog() {
|
||||
|
||||
final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(searchLog, searchLogForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected SearchLog createSearchLog() {
|
||||
SearchLog searchLog;
|
||||
if (searchLogForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
searchLog = new SearchLog();
|
||||
}
|
||||
Beans.copy(searchLogForm, searchLog).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return searchLog;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", searchLogForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("searchLog");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
final Map<String, String> searchParams = searchLogForm.searchParams;
|
||||
|
@ -86,7 +368,7 @@ public class SearchLogAction extends BsSearchLogAction {
|
|||
searchLogService.dump(writer, searchLogPager);
|
||||
writer.flush();
|
||||
} catch (final Exception e) {
|
||||
log.error("Could not create FessSearchLog.csv.", e);
|
||||
logger.error("Could not create FessSearchLog.csv.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.could_not_create_search_log_csv");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(writer);
|
||||
|
|
|
@ -27,36 +27,59 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.core.util.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.FessSystemException;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsSuggestBadWordAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.SuggestBadWord;
|
||||
import org.codelibs.fess.form.admin.SuggestBadWordForm;
|
||||
import org.codelibs.fess.helper.SuggestHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.SuggestBadWordPager;
|
||||
import org.codelibs.fess.service.SuggestBadWordService;
|
||||
import org.codelibs.robot.util.StreamUtil;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
import org.seasar.struts.util.ResponseUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
||||
public class SuggestBadWordAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SuggestBadWordAction.class);
|
||||
|
||||
private static final Log log = LogFactory.getLog(SuggestBadWordAction.class);
|
||||
// for list
|
||||
|
||||
public List<SuggestBadWord> suggestBadWordItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SuggestBadWordForm suggestBadWordForm;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordService suggestBadWordService;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordPager suggestBadWordPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
@ -67,11 +90,162 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
suggestBadWordItems = suggestBadWordService.getSuggestBadWordList(suggestBadWordPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(suggestBadWordPager, suggestBadWordForm.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(suggestBadWordForm.pageNumber)) {
|
||||
try {
|
||||
suggestBadWordPager.setCurrentPageNumber(Integer.parseInt(suggestBadWordForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + suggestBadWordForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(suggestBadWordForm.searchParams, suggestBadWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
suggestBadWordPager.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 (suggestBadWordForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
suggestBadWordForm.initialize();
|
||||
suggestBadWordForm.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 (suggestBadWordForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
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 (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", suggestBadWordForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("suggestBadWord");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSuggestBadWord() {
|
||||
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
|
@ -83,7 +257,6 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
FessBeans.copy(suggestBadWord, suggestBadWordForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuggestBadWord createSuggestBadWord() {
|
||||
SuggestBadWord suggestBadWord;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -106,7 +279,6 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
return suggestBadWord;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -133,18 +305,17 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
|
@ -157,18 +328,17 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
|
@ -181,13 +351,13 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +381,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestBadWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to export data.", e);
|
||||
logger.error("Failed to export data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_export_data");
|
||||
}
|
||||
return null;
|
||||
|
@ -242,9 +412,9 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
StreamUtil.drain(is, fos);
|
||||
} catch (final Exception e) {
|
||||
if (tempFile != null && !tempFile.delete()) {
|
||||
log.warn("Could not delete " + tempFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + tempFile.getAbsolutePath());
|
||||
}
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
|
@ -255,23 +425,22 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
try {
|
||||
final String head = new String(b, Constants.UTF_8);
|
||||
if (!(head.startsWith("\"BadWord\"") || head.startsWith("BadWord"))) {
|
||||
log.error("Unknown file: " + suggestBadWordForm.suggestBadWordFile);
|
||||
logger.error("Unknown file: " + suggestBadWordForm.suggestBadWordFile);
|
||||
throw new SSCActionMessagesException("errors.unknown_import_file");
|
||||
}
|
||||
final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Reader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc));
|
||||
suggestBadWordService.importCsv(reader);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new FessSystemException("Failed to import data.", e);
|
||||
} finally {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
suggestHelper.deleteAllBadWord();
|
||||
|
@ -281,14 +450,14 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction {
|
|||
}).start();
|
||||
} catch (final ActionMessagesException e) {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.upload_suggest_bad_word");
|
||||
|
|
|
@ -27,6 +27,9 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -37,26 +40,32 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.codelibs.core.util.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.FessSystemException;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsSuggestElevateWordAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.form.admin.SuggestElevateWordForm;
|
||||
import org.codelibs.fess.helper.SuggestHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.SuggestElevateWordPager;
|
||||
import org.codelibs.fess.service.SuggestElevateWordService;
|
||||
import org.codelibs.robot.util.StreamUtil;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
import org.seasar.struts.util.ResponseUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
||||
public class SuggestElevateWordAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(SuggestElevateWordAction.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(SuggestElevateWordAction.class);
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
@ -67,11 +76,178 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
// for list
|
||||
|
||||
public List<SuggestElevateWord> suggestElevateWordItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SuggestElevateWordForm suggestElevateWordForm;
|
||||
|
||||
@Resource
|
||||
protected SuggestElevateWordService suggestElevateWordService;
|
||||
|
||||
@Resource
|
||||
protected SuggestElevateWordPager suggestElevateWordPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
suggestElevateWordItems = suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(suggestElevateWordPager, suggestElevateWordForm.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(suggestElevateWordForm.pageNumber)) {
|
||||
try {
|
||||
suggestElevateWordPager.setCurrentPageNumber(Integer.parseInt(suggestElevateWordForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + suggestElevateWordForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(suggestElevateWordForm.searchParams, suggestElevateWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
suggestElevateWordPager.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 (suggestElevateWordForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
suggestElevateWordForm.initialize();
|
||||
suggestElevateWordForm.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 (suggestElevateWordForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
suggestElevateWordForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
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 (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
suggestElevateWordForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", suggestElevateWordForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("suggestElevateWord");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSuggestElevateWord() {
|
||||
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap());
|
||||
|
@ -83,7 +259,6 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
FessBeans.copy(suggestElevateWord, suggestElevateWordForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuggestElevateWord createSuggestElevateWord() {
|
||||
SuggestElevateWord suggestElevateWord;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -106,7 +281,6 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
|
@ -118,18 +292,17 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
|
@ -141,18 +314,17 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -178,13 +350,13 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +380,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) {
|
||||
suggestElevateWordService.exportCsv(writer);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to export data.", e);
|
||||
logger.error("Failed to export data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_export_data");
|
||||
}
|
||||
return null;
|
||||
|
@ -239,9 +411,9 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
StreamUtil.drain(is, fos);
|
||||
} catch (final Exception e) {
|
||||
if (tempFile != null && !tempFile.delete()) {
|
||||
log.warn("Could not delete " + tempFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + tempFile.getAbsolutePath());
|
||||
}
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
|
@ -252,23 +424,22 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
try {
|
||||
final String head = new String(b, Constants.UTF_8);
|
||||
if (!(head.startsWith("\"SuggestWord\"") || head.startsWith("SuggestWord"))) {
|
||||
log.error("Unknown file: " + suggestElevateWordForm.suggestElevateWordFile);
|
||||
logger.error("Unknown file: " + suggestElevateWordForm.suggestElevateWordFile);
|
||||
throw new SSCActionMessagesException("errors.unknown_import_file");
|
||||
}
|
||||
final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Reader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc));
|
||||
suggestElevateWordService.importCsv(reader);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new FessSystemException("Failed to import data.", e);
|
||||
} finally {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
IOUtils.closeQuietly(reader);
|
||||
suggestHelper.storeAllElevateWords();
|
||||
|
@ -277,14 +448,14 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction {
|
|||
}).start();
|
||||
} catch (final ActionMessagesException e) {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
throw e;
|
||||
} catch (final Exception e) {
|
||||
if (!oFile.delete()) {
|
||||
log.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
logger.warn("Could not delete " + oFile.getAbsolutePath());
|
||||
}
|
||||
log.error("Failed to import data.", e);
|
||||
logger.error("Failed to import data.", e);
|
||||
throw new SSCActionMessagesException(e, "errors.failed_to_import_data");
|
||||
}
|
||||
SAStrutsUtil.addSessionMessage("success.upload_suggest_elevate_word");
|
||||
|
|
|
@ -16,20 +16,318 @@
|
|||
|
||||
package org.codelibs.fess.action.admin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.crud.action.admin.BsUserInfoAction;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.UserInfo;
|
||||
import org.codelibs.fess.form.admin.UserInfoForm;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.UserInfoPager;
|
||||
import org.codelibs.fess.service.UserInfoService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UserInfoAction extends BsUserInfoAction {
|
||||
public class UserInfoAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserInfoAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<UserInfo> userInfoItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected UserInfoForm userInfoForm;
|
||||
|
||||
@Resource
|
||||
protected UserInfoService userInfoService;
|
||||
|
||||
@Resource
|
||||
protected UserInfoPager userInfoPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
userInfoItems = userInfoService.getUserInfoList(userInfoPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(userInfoPager, userInfoForm.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(userInfoForm.pageNumber)) {
|
||||
try {
|
||||
userInfoPager.setCurrentPageNumber(Integer.parseInt(userInfoForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + userInfoForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(userInfoForm.searchParams, userInfoPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
userInfoPager.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 (userInfoForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
userInfoForm.initialize();
|
||||
userInfoForm.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 (userInfoForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
userInfoForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
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 (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
userInfoForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final UserInfo userInfo = createUserInfo();
|
||||
userInfoService.store(userInfo);
|
||||
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 UserInfo userInfo = createUserInfo();
|
||||
userInfoService.store(userInfo);
|
||||
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 (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
|
||||
userInfoService.delete(userInfo);
|
||||
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 loadUserInfo() {
|
||||
|
||||
final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(userInfo, userInfoForm).excludes("searchParams", "mode")
|
||||
|
||||
.timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
||||
}
|
||||
|
||||
protected UserInfo createUserInfo() {
|
||||
UserInfo userInfo;
|
||||
if (userInfoForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
userInfo = new UserInfo();
|
||||
}
|
||||
Beans.copy(userInfoForm, userInfo).excludes("searchParams", "mode")
|
||||
|
||||
.timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", userInfoForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("userInfo");
|
||||
}
|
||||
|
|
|
@ -24,31 +24,50 @@ import java.util.Map;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.core.util.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.action.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsWebAuthenticationAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.WebAuthentication;
|
||||
import org.codelibs.fess.db.exentity.WebCrawlingConfig;
|
||||
import org.codelibs.fess.form.admin.WebAuthenticationForm;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.WebAuthenticationPager;
|
||||
import org.codelibs.fess.service.WebAuthenticationService;
|
||||
import org.codelibs.fess.service.WebCrawlingConfigService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
import org.seasar.struts.annotation.ActionForm;
|
||||
import org.seasar.struts.annotation.Execute;
|
||||
import org.seasar.struts.exception.ActionMessagesException;
|
||||
import org.seasar.struts.util.MessageResourcesUtil;
|
||||
import org.seasar.struts.util.RequestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class WebAuthenticationAction extends BsWebAuthenticationAction {
|
||||
public class WebAuthenticationAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebAuthenticationAction.class);
|
||||
|
||||
private static final Log log = LogFactory.getLog(WebAuthenticationAction.class);
|
||||
// for list
|
||||
|
||||
public List<WebAuthentication> webAuthenticationItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected WebAuthenticationForm webAuthenticationForm;
|
||||
|
||||
@Resource
|
||||
protected WebAuthenticationService webAuthenticationService;
|
||||
|
||||
@Resource
|
||||
protected WebAuthenticationPager webAuthenticationPager;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigService webCrawlingConfigService;
|
||||
|
@ -56,11 +75,204 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction {
|
|||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
webAuthenticationItems = webAuthenticationService.getWebAuthenticationList(webAuthenticationPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(webAuthenticationPager, webAuthenticationForm.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(webAuthenticationForm.pageNumber)) {
|
||||
try {
|
||||
webAuthenticationPager.setCurrentPageNumber(Integer.parseInt(webAuthenticationForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + webAuthenticationForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(webAuthenticationForm.searchParams, webAuthenticationPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
webAuthenticationPager.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 (webAuthenticationForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
webAuthenticationForm.initialize();
|
||||
webAuthenticationForm.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 (webAuthenticationForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
webAuthenticationForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
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 (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
webAuthenticationForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final WebAuthentication webAuthentication = createWebAuthentication();
|
||||
webAuthenticationService.store(webAuthentication);
|
||||
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 WebAuthentication webAuthentication = createWebAuthentication();
|
||||
webAuthenticationService.store(webAuthentication);
|
||||
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", webAuthenticationForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("webAuthentication");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadWebAuthentication() {
|
||||
|
||||
final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap());
|
||||
|
@ -75,7 +287,6 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebAuthentication createWebAuthentication() {
|
||||
WebAuthentication webAuthentication;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -101,7 +312,6 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction {
|
|||
return webAuthentication;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
|
@ -127,13 +337,13 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction {
|
|||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,327 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.form.admin.RoleTypeForm;
|
||||
import org.codelibs.fess.pager.RoleTypePager;
|
||||
import org.codelibs.fess.service.RoleTypeService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsRoleTypeAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsRoleTypeAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<RoleType> roleTypeItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected RoleTypeForm roleTypeForm;
|
||||
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
|
||||
@Resource
|
||||
protected RoleTypePager roleTypePager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
roleTypeItems = roleTypeService.getRoleTypeList(roleTypePager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(roleTypePager, roleTypeForm.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(roleTypeForm.pageNumber)) {
|
||||
try {
|
||||
roleTypePager.setCurrentPageNumber(Integer.parseInt(roleTypeForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + roleTypeForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(roleTypeForm.searchParams, roleTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
roleTypePager.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 (roleTypeForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
roleTypeForm.initialize();
|
||||
roleTypeForm.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 (roleTypeForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
roleTypeForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadRoleType();
|
||||
|
||||
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 (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
roleTypeForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadRoleType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final RoleType roleType = createRoleType();
|
||||
roleTypeService.store(roleType);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 RoleType roleType = createRoleType();
|
||||
roleTypeService.store(roleType);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, roleTypeForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final RoleType roleType = roleTypeService.getRoleType(createKeyMap());
|
||||
if (roleType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { roleTypeForm.id });
|
||||
|
||||
}
|
||||
|
||||
roleTypeService.delete(roleType);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadRoleType() {
|
||||
|
||||
final RoleType roleType = roleTypeService.getRoleType(createKeyMap());
|
||||
if (roleType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { roleTypeForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(roleType, roleTypeForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected RoleType createRoleType() {
|
||||
RoleType roleType;
|
||||
if (roleTypeForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
roleType = roleTypeService.getRoleType(createKeyMap());
|
||||
if (roleType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { roleTypeForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
roleType = new RoleType();
|
||||
}
|
||||
Beans.copy(roleTypeForm, roleType).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return roleType;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", roleTypeForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.ScheduledJob;
|
||||
import org.codelibs.fess.form.admin.ScheduledJobForm;
|
||||
import org.codelibs.fess.pager.ScheduledJobPager;
|
||||
import org.codelibs.fess.service.ScheduledJobService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsScheduledJobAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsScheduledJobAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<ScheduledJob> scheduledJobItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected ScheduledJobForm scheduledJobForm;
|
||||
|
||||
@Resource
|
||||
protected ScheduledJobService scheduledJobService;
|
||||
|
||||
@Resource
|
||||
protected ScheduledJobPager scheduledJobPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
scheduledJobItems = scheduledJobService.getScheduledJobList(scheduledJobPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(scheduledJobPager, scheduledJobForm.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(scheduledJobForm.pageNumber)) {
|
||||
try {
|
||||
scheduledJobPager.setCurrentPageNumber(Integer.parseInt(scheduledJobForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + scheduledJobForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(scheduledJobForm.searchParams, scheduledJobPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
scheduledJobPager.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 (scheduledJobForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
scheduledJobForm.initialize();
|
||||
scheduledJobForm.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 (scheduledJobForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
scheduledJobForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
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 (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
scheduledJobForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadScheduledJob();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final ScheduledJob scheduledJob = createScheduledJob();
|
||||
scheduledJobService.store(scheduledJob);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 ScheduledJob scheduledJob = createScheduledJob();
|
||||
scheduledJobService.store(scheduledJob);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
scheduledJobForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap());
|
||||
if (scheduledJob == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { scheduledJobForm.id });
|
||||
|
||||
}
|
||||
|
||||
scheduledJobService.delete(scheduledJob);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadScheduledJob() {
|
||||
|
||||
final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap());
|
||||
if (scheduledJob == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { scheduledJobForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(scheduledJob, scheduledJobForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected ScheduledJob createScheduledJob() {
|
||||
ScheduledJob scheduledJob;
|
||||
if (scheduledJobForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
scheduledJob = scheduledJobService.getScheduledJob(createKeyMap());
|
||||
if (scheduledJob == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { scheduledJobForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
scheduledJob = new ScheduledJob();
|
||||
}
|
||||
Beans.copy(scheduledJobForm, scheduledJob).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return scheduledJob;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", scheduledJobForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.SearchLog;
|
||||
import org.codelibs.fess.form.admin.SearchLogForm;
|
||||
import org.codelibs.fess.pager.SearchLogPager;
|
||||
import org.codelibs.fess.service.SearchLogService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsSearchLogAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsSearchLogAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<SearchLog> searchLogItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SearchLogForm searchLogForm;
|
||||
|
||||
@Resource
|
||||
protected SearchLogService searchLogService;
|
||||
|
||||
@Resource
|
||||
protected SearchLogPager searchLogPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
searchLogItems = searchLogService.getSearchLogList(searchLogPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(searchLogPager, searchLogForm.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(searchLogForm.pageNumber)) {
|
||||
try {
|
||||
searchLogPager.setCurrentPageNumber(Integer.parseInt(searchLogForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + searchLogForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(searchLogForm.searchParams, searchLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
searchLogPager.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 (searchLogForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
searchLogForm.initialize();
|
||||
searchLogForm.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 (searchLogForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.EDIT_MODE, searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
searchLogForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
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 (searchLogForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
searchLogForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSearchLog();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SearchLog searchLog = createSearchLog();
|
||||
searchLogService.store(searchLog);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 SearchLog searchLog = createSearchLog();
|
||||
searchLogService.store(searchLog);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (searchLogForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
searchLogForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
|
||||
searchLogService.delete(searchLog);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadSearchLog() {
|
||||
|
||||
final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(searchLog, searchLogForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected SearchLog createSearchLog() {
|
||||
SearchLog searchLog;
|
||||
if (searchLogForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
searchLog = searchLogService.getSearchLog(createKeyMap());
|
||||
if (searchLog == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { searchLogForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
searchLog = new SearchLog();
|
||||
}
|
||||
Beans.copy(searchLogForm, searchLog).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return searchLog;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", searchLogForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.SuggestBadWord;
|
||||
import org.codelibs.fess.form.admin.SuggestBadWordForm;
|
||||
import org.codelibs.fess.pager.SuggestBadWordPager;
|
||||
import org.codelibs.fess.service.SuggestBadWordService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsSuggestBadWordAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsSuggestBadWordAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<SuggestBadWord> suggestBadWordItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SuggestBadWordForm suggestBadWordForm;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordService suggestBadWordService;
|
||||
|
||||
@Resource
|
||||
protected SuggestBadWordPager suggestBadWordPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
suggestBadWordItems = suggestBadWordService.getSuggestBadWordList(suggestBadWordPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(suggestBadWordPager, suggestBadWordForm.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(suggestBadWordForm.pageNumber)) {
|
||||
try {
|
||||
suggestBadWordPager.setCurrentPageNumber(Integer.parseInt(suggestBadWordForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + suggestBadWordForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(suggestBadWordForm.searchParams, suggestBadWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
suggestBadWordPager.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 (suggestBadWordForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
suggestBadWordForm.initialize();
|
||||
suggestBadWordForm.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 (suggestBadWordForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
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 (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
suggestBadWordForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSuggestBadWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SuggestBadWord suggestBadWord = createSuggestBadWord();
|
||||
suggestBadWordService.store(suggestBadWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 SuggestBadWord suggestBadWord = createSuggestBadWord();
|
||||
suggestBadWordService.store(suggestBadWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestBadWordForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestBadWordForm.id });
|
||||
|
||||
}
|
||||
|
||||
suggestBadWordService.delete(suggestBadWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadSuggestBadWord() {
|
||||
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestBadWordForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(suggestBadWord, suggestBadWordForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected SuggestBadWord createSuggestBadWord() {
|
||||
SuggestBadWord suggestBadWord;
|
||||
if (suggestBadWordForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap());
|
||||
if (suggestBadWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestBadWordForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
suggestBadWord = new SuggestBadWord();
|
||||
}
|
||||
Beans.copy(suggestBadWordForm, suggestBadWord).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", suggestBadWordForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.form.admin.SuggestElevateWordForm;
|
||||
import org.codelibs.fess.pager.SuggestElevateWordPager;
|
||||
import org.codelibs.fess.service.SuggestElevateWordService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsSuggestElevateWordAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsSuggestElevateWordAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<SuggestElevateWord> suggestElevateWordItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected SuggestElevateWordForm suggestElevateWordForm;
|
||||
|
||||
@Resource
|
||||
protected SuggestElevateWordService suggestElevateWordService;
|
||||
|
||||
@Resource
|
||||
protected SuggestElevateWordPager suggestElevateWordPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
suggestElevateWordItems = suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(suggestElevateWordPager, suggestElevateWordForm.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(suggestElevateWordForm.pageNumber)) {
|
||||
try {
|
||||
suggestElevateWordPager.setCurrentPageNumber(Integer.parseInt(suggestElevateWordForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + suggestElevateWordForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(suggestElevateWordForm.searchParams, suggestElevateWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
suggestElevateWordPager.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 (suggestElevateWordForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
suggestElevateWordForm.initialize();
|
||||
suggestElevateWordForm.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 (suggestElevateWordForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
suggestElevateWordForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
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 (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
suggestElevateWordForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSuggestElevateWord();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SuggestElevateWord suggestElevateWord = createSuggestElevateWord();
|
||||
suggestElevateWordService.store(suggestElevateWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 SuggestElevateWord suggestElevateWord = createSuggestElevateWord();
|
||||
suggestElevateWordService.store(suggestElevateWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
suggestElevateWordForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap());
|
||||
if (suggestElevateWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestElevateWordForm.id });
|
||||
|
||||
}
|
||||
|
||||
suggestElevateWordService.delete(suggestElevateWord);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadSuggestElevateWord() {
|
||||
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap());
|
||||
if (suggestElevateWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestElevateWordForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(suggestElevateWord, suggestElevateWordForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected SuggestElevateWord createSuggestElevateWord() {
|
||||
SuggestElevateWord suggestElevateWord;
|
||||
if (suggestElevateWordForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap());
|
||||
if (suggestElevateWord == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { suggestElevateWordForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
suggestElevateWord = new SuggestElevateWord();
|
||||
}
|
||||
Beans.copy(suggestElevateWordForm, suggestElevateWord).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", suggestElevateWordForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.UserInfo;
|
||||
import org.codelibs.fess.form.admin.UserInfoForm;
|
||||
import org.codelibs.fess.pager.UserInfoPager;
|
||||
import org.codelibs.fess.service.UserInfoService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsUserInfoAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsUserInfoAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<UserInfo> userInfoItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected UserInfoForm userInfoForm;
|
||||
|
||||
@Resource
|
||||
protected UserInfoService userInfoService;
|
||||
|
||||
@Resource
|
||||
protected UserInfoPager userInfoPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
userInfoItems = userInfoService.getUserInfoList(userInfoPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(userInfoPager, userInfoForm.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(userInfoForm.pageNumber)) {
|
||||
try {
|
||||
userInfoPager.setCurrentPageNumber(Integer.parseInt(userInfoForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + userInfoForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(userInfoForm.searchParams, userInfoPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
userInfoPager.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 (userInfoForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
userInfoForm.initialize();
|
||||
userInfoForm.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 (userInfoForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
userInfoForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
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 (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
userInfoForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadUserInfo();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final UserInfo userInfo = createUserInfo();
|
||||
userInfoService.store(userInfo);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 UserInfo userInfo = createUserInfo();
|
||||
userInfoService.store(userInfo);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (userInfoForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
|
||||
userInfoService.delete(userInfo);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadUserInfo() {
|
||||
|
||||
final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(userInfo, userInfoForm).excludes("searchParams", "mode")
|
||||
|
||||
.timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
||||
}
|
||||
|
||||
protected UserInfo createUserInfo() {
|
||||
UserInfo userInfo;
|
||||
if (userInfoForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
userInfo = userInfoService.getUserInfo(createKeyMap());
|
||||
if (userInfo == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { userInfoForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
userInfo = new UserInfo();
|
||||
}
|
||||
Beans.copy(userInfoForm, userInfo).excludes("searchParams", "mode")
|
||||
|
||||
.timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute();
|
||||
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", userInfoForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,328 +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.crud.action.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.WebAuthentication;
|
||||
import org.codelibs.fess.form.admin.WebAuthenticationForm;
|
||||
import org.codelibs.fess.pager.WebAuthenticationPager;
|
||||
import org.codelibs.fess.service.WebAuthenticationService;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
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.exception.ActionMessagesException;
|
||||
|
||||
public class BsWebAuthenticationAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsWebAuthenticationAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<WebAuthentication> webAuthenticationItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected WebAuthenticationForm webAuthenticationForm;
|
||||
|
||||
@Resource
|
||||
protected WebAuthenticationService webAuthenticationService;
|
||||
|
||||
@Resource
|
||||
protected WebAuthenticationPager webAuthenticationPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
webAuthenticationItems = webAuthenticationService.getWebAuthenticationList(webAuthenticationPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(webAuthenticationPager, webAuthenticationForm.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(webAuthenticationForm.pageNumber)) {
|
||||
try {
|
||||
webAuthenticationPager.setCurrentPageNumber(Integer.parseInt(webAuthenticationForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + webAuthenticationForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(webAuthenticationForm.searchParams, webAuthenticationPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
webAuthenticationPager.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 (webAuthenticationForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
webAuthenticationForm.initialize();
|
||||
webAuthenticationForm.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 (webAuthenticationForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
webAuthenticationForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
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 (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
webAuthenticationForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadWebAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final WebAuthentication webAuthentication = createWebAuthentication();
|
||||
webAuthenticationService.store(webAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 WebAuthentication webAuthentication = createWebAuthentication();
|
||||
webAuthenticationService.store(webAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.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 (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap());
|
||||
if (webAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webAuthenticationForm.id });
|
||||
|
||||
}
|
||||
|
||||
webAuthenticationService.delete(webAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadWebAuthentication() {
|
||||
|
||||
final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap());
|
||||
if (webAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webAuthenticationForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(webAuthentication, webAuthenticationForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected WebAuthentication createWebAuthentication() {
|
||||
WebAuthentication webAuthentication;
|
||||
if (webAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap());
|
||||
if (webAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webAuthenticationForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
webAuthentication = new WebAuthentication();
|
||||
}
|
||||
Beans.copy(webAuthenticationForm, webAuthentication).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return webAuthentication;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", webAuthenticationForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue