commit
055e35a684
12 changed files with 1174 additions and 1779 deletions
|
@ -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.LabelType;
|
||||
import org.codelibs.fess.pager.LabelTypePager;
|
||||
import org.codelibs.fess.service.LabelTypeService;
|
||||
import org.codelibs.fess.web.admin.LabelTypeForm;
|
||||
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 BsLabelTypeAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsLabelTypeAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<LabelType> labelTypeItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected LabelTypeForm labelTypeForm;
|
||||
|
||||
@Resource
|
||||
protected LabelTypeService labelTypeService;
|
||||
|
||||
@Resource
|
||||
protected LabelTypePager labelTypePager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
labelTypeItems = labelTypeService.getLabelTypeList(labelTypePager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(labelTypePager, labelTypeForm.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(labelTypeForm.pageNumber)) {
|
||||
try {
|
||||
labelTypePager.setCurrentPageNumber(Integer.parseInt(labelTypeForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + labelTypeForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(labelTypeForm.searchParams, labelTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
labelTypePager.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 (labelTypeForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
labelTypeForm.initialize();
|
||||
labelTypeForm.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 (labelTypeForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.EDIT_MODE, labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
labelTypeForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadLabelType();
|
||||
|
||||
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 (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
labelTypeForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final LabelType labelType = createLabelType();
|
||||
labelTypeService.store(labelType);
|
||||
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 LabelType labelType = createLabelType();
|
||||
labelTypeService.store(labelType);
|
||||
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 (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final LabelType labelType = labelTypeService.getLabelType(createKeyMap());
|
||||
if (labelType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { labelTypeForm.id });
|
||||
|
||||
}
|
||||
|
||||
labelTypeService.delete(labelType);
|
||||
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 loadLabelType() {
|
||||
|
||||
final LabelType labelType = labelTypeService.getLabelType(createKeyMap());
|
||||
if (labelType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { labelTypeForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(labelType, labelTypeForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected LabelType createLabelType() {
|
||||
LabelType labelType;
|
||||
if (labelTypeForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
labelType = labelTypeService.getLabelType(createKeyMap());
|
||||
if (labelType == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { labelTypeForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
labelType = new LabelType();
|
||||
}
|
||||
Beans.copy(labelTypeForm, labelType).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return labelType;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", labelTypeForm.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.OverlappingHost;
|
||||
import org.codelibs.fess.pager.OverlappingHostPager;
|
||||
import org.codelibs.fess.service.OverlappingHostService;
|
||||
import org.codelibs.fess.web.admin.OverlappingHostForm;
|
||||
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 BsOverlappingHostAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsOverlappingHostAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<OverlappingHost> overlappingHostItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected OverlappingHostForm overlappingHostForm;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostService overlappingHostService;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostPager overlappingHostPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
overlappingHostItems = overlappingHostService.getOverlappingHostList(overlappingHostPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(overlappingHostPager, overlappingHostForm.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(overlappingHostForm.pageNumber)) {
|
||||
try {
|
||||
overlappingHostPager.setCurrentPageNumber(Integer.parseInt(overlappingHostForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + overlappingHostForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(overlappingHostForm.searchParams, overlappingHostPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
overlappingHostPager.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 (overlappingHostForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
overlappingHostForm.initialize();
|
||||
overlappingHostForm.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 (overlappingHostForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
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 (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
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 OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
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 (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { overlappingHostForm.id });
|
||||
|
||||
}
|
||||
|
||||
overlappingHostService.delete(overlappingHost);
|
||||
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 loadOverlappingHost() {
|
||||
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { overlappingHostForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(overlappingHost, overlappingHostForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected OverlappingHost createOverlappingHost() {
|
||||
OverlappingHost overlappingHost;
|
||||
if (overlappingHostForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { overlappingHostForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
overlappingHost = new OverlappingHost();
|
||||
}
|
||||
Beans.copy(overlappingHostForm, overlappingHost).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return overlappingHost;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", overlappingHostForm.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.PathMapping;
|
||||
import org.codelibs.fess.pager.PathMappingPager;
|
||||
import org.codelibs.fess.service.PathMappingService;
|
||||
import org.codelibs.fess.web.admin.PathMappingForm;
|
||||
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 BsPathMappingAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsPathMappingAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<PathMapping> pathMappingItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected PathMappingForm pathMappingForm;
|
||||
|
||||
@Resource
|
||||
protected PathMappingService pathMappingService;
|
||||
|
||||
@Resource
|
||||
protected PathMappingPager pathMappingPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
pathMappingItems = pathMappingService.getPathMappingList(pathMappingPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(pathMappingPager, pathMappingForm.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(pathMappingForm.pageNumber)) {
|
||||
try {
|
||||
pathMappingPager.setCurrentPageNumber(Integer.parseInt(pathMappingForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + pathMappingForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(pathMappingForm.searchParams, pathMappingPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
pathMappingPager.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 (pathMappingForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
pathMappingForm.initialize();
|
||||
pathMappingForm.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 (pathMappingForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
pathMappingForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
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 (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
pathMappingForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final PathMapping pathMapping = createPathMapping();
|
||||
pathMappingService.store(pathMapping);
|
||||
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 PathMapping pathMapping = createPathMapping();
|
||||
pathMappingService.store(pathMapping);
|
||||
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 (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap());
|
||||
if (pathMapping == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { pathMappingForm.id });
|
||||
|
||||
}
|
||||
|
||||
pathMappingService.delete(pathMapping);
|
||||
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 loadPathMapping() {
|
||||
|
||||
final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap());
|
||||
if (pathMapping == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { pathMappingForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(pathMapping, pathMappingForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected PathMapping createPathMapping() {
|
||||
PathMapping pathMapping;
|
||||
if (pathMappingForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
pathMapping = pathMappingService.getPathMapping(createKeyMap());
|
||||
if (pathMapping == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { pathMappingForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
pathMapping = new PathMapping();
|
||||
}
|
||||
Beans.copy(pathMappingForm, pathMapping).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return pathMapping;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", pathMappingForm.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.RequestHeader;
|
||||
import org.codelibs.fess.pager.RequestHeaderPager;
|
||||
import org.codelibs.fess.service.RequestHeaderService;
|
||||
import org.codelibs.fess.web.admin.RequestHeaderForm;
|
||||
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 BsRequestHeaderAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsRequestHeaderAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<RequestHeader> requestHeaderItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected RequestHeaderForm requestHeaderForm;
|
||||
|
||||
@Resource
|
||||
protected RequestHeaderService requestHeaderService;
|
||||
|
||||
@Resource
|
||||
protected RequestHeaderPager requestHeaderPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
requestHeaderItems = requestHeaderService.getRequestHeaderList(requestHeaderPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(requestHeaderPager, requestHeaderForm.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(requestHeaderForm.pageNumber)) {
|
||||
try {
|
||||
requestHeaderPager.setCurrentPageNumber(Integer.parseInt(requestHeaderForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + requestHeaderForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(requestHeaderForm.searchParams, requestHeaderPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
requestHeaderPager.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 (requestHeaderForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
requestHeaderForm.initialize();
|
||||
requestHeaderForm.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 (requestHeaderForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
requestHeaderForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
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 (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
requestHeaderForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final RequestHeader requestHeader = createRequestHeader();
|
||||
requestHeaderService.store(requestHeader);
|
||||
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 RequestHeader requestHeader = createRequestHeader();
|
||||
requestHeaderService.store(requestHeader);
|
||||
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 (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap());
|
||||
if (requestHeader == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { requestHeaderForm.id });
|
||||
|
||||
}
|
||||
|
||||
requestHeaderService.delete(requestHeader);
|
||||
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 loadRequestHeader() {
|
||||
|
||||
final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap());
|
||||
if (requestHeader == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { requestHeaderForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(requestHeader, requestHeaderForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected RequestHeader createRequestHeader() {
|
||||
RequestHeader requestHeader;
|
||||
if (requestHeaderForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
requestHeader = requestHeaderService.getRequestHeader(createKeyMap());
|
||||
if (requestHeader == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { requestHeaderForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
requestHeader = new RequestHeader();
|
||||
}
|
||||
Beans.copy(requestHeaderForm, requestHeader).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return requestHeader;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", requestHeaderForm.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.WebCrawlingConfig;
|
||||
import org.codelibs.fess.pager.WebCrawlingConfigPager;
|
||||
import org.codelibs.fess.service.WebCrawlingConfigService;
|
||||
import org.codelibs.fess.web.admin.WebCrawlingConfigForm;
|
||||
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 BsWebCrawlingConfigAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(BsWebCrawlingConfigAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<WebCrawlingConfig> webCrawlingConfigItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected WebCrawlingConfigForm webCrawlingConfigForm;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigService webCrawlingConfigService;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigPager webCrawlingConfigPager;
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
webCrawlingConfigItems = webCrawlingConfigService.getWebCrawlingConfigList(webCrawlingConfigPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(webCrawlingConfigPager, webCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(webCrawlingConfigForm.pageNumber)) {
|
||||
try {
|
||||
webCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(webCrawlingConfigForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + webCrawlingConfigForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(webCrawlingConfigForm.searchParams, webCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
webCrawlingConfigPager.clear();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String back() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editagain() {
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
webCrawlingConfigForm.initialize();
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
||||
webCrawlingConfigService.store(webCrawlingConfig);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
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 WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
||||
webCrawlingConfigService.store(webCrawlingConfig);
|
||||
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 (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
||||
if (webCrawlingConfig == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webCrawlingConfigForm.id });
|
||||
|
||||
}
|
||||
|
||||
webCrawlingConfigService.delete(webCrawlingConfig);
|
||||
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 loadWebCrawlingConfig() {
|
||||
|
||||
final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
||||
if (webCrawlingConfig == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webCrawlingConfigForm.id });
|
||||
|
||||
}
|
||||
|
||||
Beans.copy(webCrawlingConfig, webCrawlingConfigForm).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
}
|
||||
|
||||
protected WebCrawlingConfig createWebCrawlingConfig() {
|
||||
WebCrawlingConfig webCrawlingConfig;
|
||||
if (webCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
||||
if (webCrawlingConfig == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { webCrawlingConfigForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
webCrawlingConfig = new WebCrawlingConfig();
|
||||
}
|
||||
Beans.copy(webCrawlingConfigForm, webCrawlingConfig).excludes("searchParams", "mode")
|
||||
|
||||
.execute();
|
||||
|
||||
return webCrawlingConfig;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", webCrawlingConfigForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -1,69 +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.form.admin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.struts.annotation.DateType;
|
||||
import org.seasar.struts.annotation.IntegerType;
|
||||
import org.seasar.struts.annotation.LongType;
|
||||
import org.seasar.struts.annotation.Maxbytelength;
|
||||
import org.seasar.struts.annotation.Required;
|
||||
|
||||
public abstract class BsCrawlingSessionForm {
|
||||
@IntegerType
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@LongType
|
||||
public String id;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@Maxbytelength(maxbytelength = 20)
|
||||
public String sessionId;
|
||||
|
||||
@Maxbytelength(maxbytelength = 20)
|
||||
public String name;
|
||||
|
||||
@DateType
|
||||
public String expiredTime;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@DateType
|
||||
public String createdTime;
|
||||
|
||||
public void initialize() {
|
||||
|
||||
id = null;
|
||||
sessionId = null;
|
||||
name = null;
|
||||
expiredTime = null;
|
||||
createdTime = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -17,15 +17,57 @@
|
|||
package org.codelibs.fess.web.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.crud.form.admin.BsCrawlingSessionForm;
|
||||
|
||||
public class CrawlingSessionForm extends BsCrawlingSessionForm implements Serializable {
|
||||
import org.seasar.struts.annotation.DateType;
|
||||
import org.seasar.struts.annotation.IntegerType;
|
||||
import org.seasar.struts.annotation.LongType;
|
||||
import org.seasar.struts.annotation.Maxbytelength;
|
||||
import org.seasar.struts.annotation.Required;
|
||||
|
||||
public class CrawlingSessionForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IntegerType
|
||||
public String pageNumber;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@LongType
|
||||
public String id;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@Maxbytelength(maxbytelength = 20)
|
||||
public String sessionId;
|
||||
|
||||
@Maxbytelength(maxbytelength = 20)
|
||||
public String name;
|
||||
|
||||
@DateType
|
||||
public String expiredTime;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@DateType
|
||||
public String createdTime;
|
||||
|
||||
public void initialize() {
|
||||
|
||||
id = null;
|
||||
sessionId = null;
|
||||
name = null;
|
||||
expiredTime = null;
|
||||
createdTime = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,29 +17,52 @@
|
|||
package org.codelibs.fess.web.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.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsLabelTypeAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.LabelType;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.LabelTypePager;
|
||||
import org.codelibs.fess.service.LabelTypeService;
|
||||
import org.codelibs.fess.service.RoleTypeService;
|
||||
import org.codelibs.fess.web.base.FessAdminAction;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class LabelTypeAction extends BsLabelTypeAction {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class LabelTypeAction extends FessAdminAction {
|
||||
|
||||
private static final Log log = LogFactory.getLog(LabelTypeAction.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(LabelTypeAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<LabelType> labelTypeItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected LabelTypeForm labelTypeForm;
|
||||
|
||||
@Resource
|
||||
protected LabelTypeService labelTypeService;
|
||||
|
||||
@Resource
|
||||
protected LabelTypePager labelTypePager;
|
||||
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
|
@ -50,8 +73,201 @@ public class LabelTypeAction extends BsLabelTypeAction {
|
|||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("labelType");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
labelTypeItems = labelTypeService.getLabelTypeList(labelTypePager);
|
||||
|
||||
@Override
|
||||
// restore from pager
|
||||
Beans.copy(labelTypePager, labelTypeForm.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(labelTypeForm.pageNumber)) {
|
||||
try {
|
||||
labelTypePager.setCurrentPageNumber(Integer.parseInt(labelTypeForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + labelTypeForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(labelTypeForm.searchParams, labelTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
labelTypePager.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 (labelTypeForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
labelTypeForm.initialize();
|
||||
labelTypeForm.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 (labelTypeForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.EDIT_MODE, labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
labelTypeForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadLabelType();
|
||||
|
||||
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 (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
labelTypeForm.crudMode });
|
||||
}
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
labelTypeForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadLabelType();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final LabelType labelType = createLabelType();
|
||||
labelTypeService.store(labelType);
|
||||
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 LabelType labelType = createLabelType();
|
||||
labelTypeService.store(labelType);
|
||||
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", labelTypeForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected void loadLabelType() {
|
||||
|
||||
final LabelType labelType = labelTypeService.getLabelType(createKeyMap());
|
||||
|
@ -63,7 +279,6 @@ public class LabelTypeAction extends BsLabelTypeAction {
|
|||
FessBeans.copy(labelType, labelTypeForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LabelType createLabelType() {
|
||||
LabelType labelType;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -86,7 +301,6 @@ public class LabelTypeAction extends BsLabelTypeAction {
|
|||
return labelType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -111,13 +325,13 @@ public class LabelTypeAction extends BsLabelTypeAction {
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,27 +17,50 @@
|
|||
package org.codelibs.fess.web.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.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsOverlappingHostAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.OverlappingHost;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.OverlappingHostPager;
|
||||
import org.codelibs.fess.service.OverlappingHostService;
|
||||
import org.codelibs.fess.web.base.FessAdminAction;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OverlappingHostAction extends BsOverlappingHostAction {
|
||||
public class OverlappingHostAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(OverlappingHostAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
private static final Log log = LogFactory.getLog(OverlappingHostAction.class);
|
||||
public List<OverlappingHost> overlappingHostItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected OverlappingHostForm overlappingHostForm;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostService overlappingHostService;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostPager overlappingHostPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
@ -45,8 +68,201 @@ public class OverlappingHostAction extends BsOverlappingHostAction {
|
|||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("overlappingHost");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
overlappingHostItems = overlappingHostService.getOverlappingHostList(overlappingHostPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(overlappingHostPager, overlappingHostForm.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(overlappingHostForm.pageNumber)) {
|
||||
try {
|
||||
overlappingHostPager.setCurrentPageNumber(Integer.parseInt(overlappingHostForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + overlappingHostForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(overlappingHostForm.searchParams, overlappingHostPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
overlappingHostPager.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 (overlappingHostForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
overlappingHostForm.initialize();
|
||||
overlappingHostForm.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 (overlappingHostForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
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 (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
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 OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
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", overlappingHostForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadOverlappingHost() {
|
||||
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
|
@ -58,7 +274,6 @@ public class OverlappingHostAction extends BsOverlappingHostAction {
|
|||
FessBeans.copy(overlappingHost, overlappingHostForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OverlappingHost createOverlappingHost() {
|
||||
OverlappingHost overlappingHost;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -81,7 +296,6 @@ public class OverlappingHostAction extends BsOverlappingHostAction {
|
|||
return overlappingHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -106,13 +320,13 @@ public class OverlappingHostAction extends BsOverlappingHostAction {
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,28 +17,51 @@
|
|||
package org.codelibs.fess.web.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.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsPathMappingAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.PathMapping;
|
||||
import org.codelibs.fess.helper.PathMappingHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.PathMappingPager;
|
||||
import org.codelibs.fess.service.PathMappingService;
|
||||
import org.codelibs.fess.web.base.FessAdminAction;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PathMappingAction extends BsPathMappingAction {
|
||||
public class PathMappingAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(PathMappingAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
private static final Log log = LogFactory.getLog(PathMappingAction.class);
|
||||
public List<PathMapping> pathMappingItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected PathMappingForm pathMappingForm;
|
||||
|
||||
@Resource
|
||||
protected PathMappingService pathMappingService;
|
||||
|
||||
@Resource
|
||||
protected PathMappingPager pathMappingPager;
|
||||
|
||||
@Resource
|
||||
protected PathMappingHelper pathMappingHelper;
|
||||
|
@ -49,16 +72,205 @@ public class PathMappingAction extends BsPathMappingAction {
|
|||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("pathMapping");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
if (redirect) {
|
||||
if (redirect) {
|
||||
pathMappingHelper.init();
|
||||
}
|
||||
return super.displayList(redirect);
|
||||
|
||||
// page navi
|
||||
pathMappingItems = pathMappingService.getPathMappingList(pathMappingPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(pathMappingPager, pathMappingForm.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(pathMappingForm.pageNumber)) {
|
||||
try {
|
||||
pathMappingPager.setCurrentPageNumber(Integer.parseInt(pathMappingForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + pathMappingForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(pathMappingForm.searchParams, pathMappingPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
pathMappingPager.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 (pathMappingForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
pathMappingForm.initialize();
|
||||
pathMappingForm.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 (pathMappingForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
pathMappingForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
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 (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
pathMappingForm.crudMode });
|
||||
}
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
pathMappingForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadPathMapping();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final PathMapping pathMapping = createPathMapping();
|
||||
pathMappingService.store(pathMapping);
|
||||
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 PathMapping pathMapping = createPathMapping();
|
||||
pathMappingService.store(pathMapping);
|
||||
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", pathMappingForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadPathMapping() {
|
||||
|
||||
final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap());
|
||||
|
@ -70,7 +282,6 @@ public class PathMappingAction extends BsPathMappingAction {
|
|||
FessBeans.copy(pathMapping, pathMappingForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PathMapping createPathMapping() {
|
||||
PathMapping pathMapping;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -93,7 +304,6 @@ public class PathMappingAction extends BsPathMappingAction {
|
|||
return pathMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -118,13 +328,13 @@ public class PathMappingAction extends BsPathMappingAction {
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,28 +24,48 @@ import java.util.Map;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsRequestHeaderAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.RequestHeader;
|
||||
import org.codelibs.fess.db.exentity.WebCrawlingConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.RequestHeaderPager;
|
||||
import org.codelibs.fess.service.RequestHeaderService;
|
||||
import org.codelibs.fess.service.WebCrawlingConfigService;
|
||||
import org.codelibs.fess.web.base.FessAdminAction;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.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.MessageResourcesUtil;
|
||||
import org.seasar.struts.util.RequestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RequestHeaderAction extends BsRequestHeaderAction {
|
||||
public class RequestHeaderAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(RequestHeaderAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
private static final Log log = LogFactory.getLog(RequestHeaderAction.class);
|
||||
public List<RequestHeader> requestHeaderItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected RequestHeaderForm requestHeaderForm;
|
||||
|
||||
@Resource
|
||||
protected RequestHeaderService requestHeaderService;
|
||||
|
||||
@Resource
|
||||
protected RequestHeaderPager requestHeaderPager;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigService webCrawlingConfigService;
|
||||
|
@ -56,8 +76,201 @@ public class RequestHeaderAction extends BsRequestHeaderAction {
|
|||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("requestHeader");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
requestHeaderItems = requestHeaderService.getRequestHeaderList(requestHeaderPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(requestHeaderPager, requestHeaderForm.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(requestHeaderForm.pageNumber)) {
|
||||
try {
|
||||
requestHeaderPager.setCurrentPageNumber(Integer.parseInt(requestHeaderForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + requestHeaderForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(requestHeaderForm.searchParams, requestHeaderPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
requestHeaderPager.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 (requestHeaderForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
requestHeaderForm.initialize();
|
||||
requestHeaderForm.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 (requestHeaderForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
requestHeaderForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
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 (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
requestHeaderForm.crudMode });
|
||||
}
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
requestHeaderForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadRequestHeader();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final RequestHeader requestHeader = createRequestHeader();
|
||||
requestHeaderService.store(requestHeader);
|
||||
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 RequestHeader requestHeader = createRequestHeader();
|
||||
requestHeaderService.store(requestHeader);
|
||||
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", requestHeaderForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadRequestHeader() {
|
||||
|
||||
final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap());
|
||||
|
@ -69,7 +282,6 @@ public class RequestHeaderAction extends BsRequestHeaderAction {
|
|||
FessBeans.copy(requestHeader, requestHeaderForm).commonColumnDateConverter().excludes("searchParams", "mode").execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestHeader createRequestHeader() {
|
||||
RequestHeader requestHeader;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -92,7 +304,6 @@ public class RequestHeaderAction extends BsRequestHeaderAction {
|
|||
return requestHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -117,13 +328,13 @@ public class RequestHeaderAction extends BsRequestHeaderAction {
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,35 +17,57 @@
|
|||
package org.codelibs.fess.web.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.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.action.admin.BsWebCrawlingConfigAction;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.CrawlingConfig;
|
||||
import org.codelibs.fess.db.exentity.LabelType;
|
||||
import org.codelibs.fess.db.exentity.RoleType;
|
||||
import org.codelibs.fess.db.exentity.WebCrawlingConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.WebCrawlingConfigPager;
|
||||
import org.codelibs.fess.service.FailureUrlService;
|
||||
import org.codelibs.fess.service.LabelTypeService;
|
||||
import org.codelibs.fess.service.RoleTypeService;
|
||||
import org.codelibs.fess.service.WebCrawlingConfigService;
|
||||
import org.codelibs.fess.web.base.FessAdminAction;
|
||||
import org.codelibs.sastruts.core.annotation.Token;
|
||||
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
||||
import org.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 WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
||||
public class WebCrawlingConfigAction extends FessAdminAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebCrawlingConfigAction.class);
|
||||
|
||||
private static final Log log = LogFactory.getLog(WebCrawlingConfigAction.class);
|
||||
// for list
|
||||
|
||||
public List<WebCrawlingConfig> webCrawlingConfigItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
@ActionForm
|
||||
@Resource
|
||||
protected WebCrawlingConfigForm webCrawlingConfigForm;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigService webCrawlingConfigService;
|
||||
|
||||
@Resource
|
||||
protected WebCrawlingConfigPager webCrawlingConfigPager;
|
||||
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
|
||||
|
@ -61,8 +83,201 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("webCrawlingConfig");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
webCrawlingConfigItems = webCrawlingConfigService.getWebCrawlingConfigList(webCrawlingConfigPager);
|
||||
|
||||
// restore from pager
|
||||
Beans.copy(webCrawlingConfigPager, webCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(webCrawlingConfigForm.pageNumber)) {
|
||||
try {
|
||||
webCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(webCrawlingConfigForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + webCrawlingConfigForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
Beans.copy(webCrawlingConfigForm.searchParams, webCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
||||
|
||||
.execute();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
webCrawlingConfigPager.clear();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String back() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editagain() {
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
webCrawlingConfigForm.initialize();
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
webCrawlingConfigForm.crudMode });
|
||||
}
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
webCrawlingConfigForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadWebCrawlingConfig();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
||||
webCrawlingConfigService.store(webCrawlingConfig);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
try {
|
||||
final WebCrawlingConfig webCrawlingConfig = createWebCrawlingConfig();
|
||||
webCrawlingConfigService.store(webCrawlingConfig);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", webCrawlingConfigForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadWebCrawlingConfig() {
|
||||
|
||||
final CrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap());
|
||||
|
@ -79,7 +294,6 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WebCrawlingConfig createWebCrawlingConfig() {
|
||||
WebCrawlingConfig webCrawlingConfig;
|
||||
final String username = systemHelper.getUsername();
|
||||
|
@ -102,7 +316,6 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|||
return webCrawlingConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
|
@ -129,13 +342,13 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction {
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue