commit
50765f0073
41 changed files with 1561 additions and 1180 deletions
|
@ -34,6 +34,7 @@ import org.codelibs.fess.es.exentity.DataConfig;
|
|||
import org.codelibs.fess.es.exentity.DataConfigToLabel;
|
||||
import org.codelibs.fess.es.exentity.DataConfigToRole;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class DataConfigService implements Serializable {
|
||||
|
||||
|
@ -103,40 +104,33 @@ public class DataConfigService implements Serializable {
|
|||
return list;
|
||||
}
|
||||
|
||||
public DataConfig getDataConfig(final Map<String, String> keys) {
|
||||
|
||||
final DataConfig dataConfig = dataConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
|
||||
if (dataConfig != null) {
|
||||
public OptionalEntity<DataConfig> getDataConfig(final String id) {
|
||||
return dataConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
final List<DataConfigToRole> fctrtmList = dataConfigToRoleBhv.selectList(fctrtmCb -> {
|
||||
fctrtmCb.query().setDataConfigId_Equal(dataConfig.getId());
|
||||
fctrtmCb.query().setDataConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!fctrtmList.isEmpty()) {
|
||||
final List<String> roleTypeIds = new ArrayList<String>(fctrtmList.size());
|
||||
for (final DataConfigToRole mapping : fctrtmList) {
|
||||
roleTypeIds.add(mapping.getRoleTypeId());
|
||||
}
|
||||
dataConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
entity.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
}
|
||||
|
||||
final List<DataConfigToLabel> fctltmList = dataConfigToLabelBhv.selectList(fctltmCb -> {
|
||||
fctltmCb.query().setDataConfigId_Equal(dataConfig.getId());
|
||||
fctltmCb.query().setDataConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!fctltmList.isEmpty()) {
|
||||
final List<String> labelTypeIds = new ArrayList<String>(fctltmList.size());
|
||||
for (final DataConfigToLabel mapping : fctltmList) {
|
||||
labelTypeIds.add(mapping.getLabelTypeId());
|
||||
}
|
||||
dataConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
entity.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dataConfig;
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
public void store(final DataConfig dataConfig) {
|
||||
|
@ -273,10 +267,4 @@ public class DataConfigService implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public DataConfig getDataConfig(final String id) {
|
||||
return dataConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(id);
|
||||
}).orElse(null);//TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.codelibs.fess.es.exentity.FileConfig;
|
|||
import org.codelibs.fess.es.exentity.FileConfigToLabel;
|
||||
import org.codelibs.fess.es.exentity.FileConfigToRole;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class FileConfigService implements Serializable {
|
||||
|
||||
|
@ -102,39 +103,32 @@ public class FileConfigService implements Serializable {
|
|||
return list;
|
||||
}
|
||||
|
||||
public FileConfig getFileConfig(final Map<String, String> keys) {
|
||||
final FileConfig fileConfig = fileConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
|
||||
if (fileConfig != null) {
|
||||
public OptionalEntity<FileConfig> getFileConfig(final String id) {
|
||||
return fileConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
final List<FileConfigToRole> fctrtmList = fileConfigToRoleBhv.selectList(fctrtmCb -> {
|
||||
fctrtmCb.query().setFileConfigId_Equal(fileConfig.getId());
|
||||
fctrtmCb.query().setFileConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!fctrtmList.isEmpty()) {
|
||||
final List<String> roleTypeIds = new ArrayList<String>(fctrtmList.size());
|
||||
for (final FileConfigToRole mapping : fctrtmList) {
|
||||
roleTypeIds.add(mapping.getRoleTypeId());
|
||||
}
|
||||
fileConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
entity.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
}
|
||||
|
||||
final List<FileConfigToLabel> fctltmList = fileConfigToLabelBhv.selectList(fctltmCb -> {
|
||||
fctltmCb.query().setFileConfigId_Equal(fileConfig.getId());
|
||||
fctltmCb.query().setFileConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!fctltmList.isEmpty()) {
|
||||
final List<String> labelTypeIds = new ArrayList<String>(fctltmList.size());
|
||||
for (final FileConfigToLabel mapping : fctltmList) {
|
||||
labelTypeIds.add(mapping.getLabelTypeId());
|
||||
}
|
||||
fileConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
entity.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return fileConfig;
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
public void store(final FileConfig fileConfig) {
|
||||
|
@ -271,10 +265,4 @@ public class FileConfigService implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public FileConfig getFileConfig(final String id) {
|
||||
return fileConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(id);
|
||||
}).orElse(null);//TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.codelibs.fess.es.cbean.PathMappingCB;
|
|||
import org.codelibs.fess.es.exbhv.PathMappingBhv;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class PathMappingService implements Serializable {
|
||||
|
||||
|
@ -54,18 +55,8 @@ public class PathMappingService implements Serializable {
|
|||
return pathMappingList;
|
||||
}
|
||||
|
||||
public PathMapping getPathMapping(final Map<String, String> keys) {
|
||||
final PathMapping pathMapping = pathMappingBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
cb.request().setVersion(true);
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (pathMapping == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return pathMapping;
|
||||
public OptionalEntity<PathMapping> getPathMapping(final String id) {
|
||||
return pathMappingBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final PathMapping pathMapping) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.codelibs.fess.es.cbean.RequestHeaderCB;
|
|||
import org.codelibs.fess.es.exbhv.RequestHeaderBhv;
|
||||
import org.codelibs.fess.es.exentity.RequestHeader;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class RequestHeaderService implements Serializable {
|
||||
|
||||
|
@ -57,17 +58,8 @@ public class RequestHeaderService implements Serializable {
|
|||
return requestHeaderList;
|
||||
}
|
||||
|
||||
public RequestHeader getRequestHeader(final Map<String, String> keys) {
|
||||
final RequestHeader requestHeader = requestHeaderBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (requestHeader == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return requestHeader;
|
||||
public OptionalEntity<RequestHeader> getRequestHeader(final String id) {
|
||||
return requestHeaderBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final RequestHeader requestHeader) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.codelibs.fess.es.exentity.WebConfig;
|
|||
import org.codelibs.fess.es.exentity.WebConfigToLabel;
|
||||
import org.codelibs.fess.es.exentity.WebConfigToRole;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class WebConfigService implements Serializable {
|
||||
|
||||
|
@ -103,37 +104,32 @@ public class WebConfigService implements Serializable {
|
|||
return list;
|
||||
}
|
||||
|
||||
public WebConfig getWebConfig(final Map<String, String> keys) {
|
||||
final WebConfig webConfig = webConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
|
||||
if (webConfig != null) {
|
||||
final List<WebConfigToLabel> wctltmList = webConfigToLabelBhv.selectList(wctltmCb -> {
|
||||
wctltmCb.query().setWebConfigId_Equal(webConfig.getId());
|
||||
});
|
||||
if (!wctltmList.isEmpty()) {
|
||||
final List<String> labelTypeIds = new ArrayList<String>(wctltmList.size());
|
||||
for (final WebConfigToLabel mapping : wctltmList) {
|
||||
labelTypeIds.add(mapping.getLabelTypeId());
|
||||
}
|
||||
webConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
}
|
||||
public OptionalEntity<WebConfig> getWebConfig(final String id) {
|
||||
return webConfigBhv.selectByPK(id).map(entity -> {
|
||||
|
||||
final List<WebConfigToRole> wctrtmList = webConfigToRoleBhv.selectList(wctrtmCb -> {
|
||||
wctrtmCb.query().setWebConfigId_Equal(webConfig.getId());
|
||||
wctrtmCb.query().setWebConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!wctrtmList.isEmpty()) {
|
||||
final List<String> roleTypeIds = new ArrayList<String>(wctrtmList.size());
|
||||
for (final WebConfigToRole mapping : wctrtmList) {
|
||||
roleTypeIds.add(mapping.getRoleTypeId());
|
||||
}
|
||||
webConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
entity.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
return webConfig;
|
||||
final List<WebConfigToLabel> wctltmList = webConfigToLabelBhv.selectList(wctltmCb -> {
|
||||
wctltmCb.query().setWebConfigId_Equal(entity.getId());
|
||||
});
|
||||
if (!wctltmList.isEmpty()) {
|
||||
final List<String> labelTypeIds = new ArrayList<String>(wctltmList.size());
|
||||
for (final WebConfigToLabel mapping : wctltmList) {
|
||||
labelTypeIds.add(mapping.getLabelTypeId());
|
||||
}
|
||||
entity.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()]));
|
||||
}
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
public void store(final WebConfig webConfig) {
|
||||
|
@ -270,10 +266,4 @@ public class WebConfigService implements Serializable {
|
|||
// setup condition
|
||||
|
||||
}
|
||||
|
||||
public WebConfig getWebConfig(final String id) {
|
||||
return webConfigBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(id);
|
||||
}).orElse(null);//TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,14 @@ import org.codelibs.fess.app.service.DataConfigService;
|
|||
import org.codelibs.fess.app.service.LabelTypeService;
|
||||
import org.codelibs.fess.app.service.RoleTypeService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.dataconfig.CreateForm;
|
||||
import org.codelibs.fess.app.web.admin.dataconfig.EditForm;
|
||||
import org.codelibs.fess.app.web.admin.dataconfig.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.ds.DataStoreFactory;
|
||||
import org.codelibs.fess.es.exentity.DataConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -54,13 +58,13 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
@Resource
|
||||
private DataConfigPager dataConfigPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
private RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
protected LabelTypeService labelTypeService;
|
||||
private LabelTypeService labelTypeService;
|
||||
@Resource
|
||||
protected DataStoreFactory dataStoreFactory;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
|
@ -75,14 +79,14 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final DataConfigSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminDataconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final DataConfigSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
dataConfigPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminDataconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -90,15 +94,15 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final DataConfigSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, dataConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, dataConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminDataconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final DataConfigSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
dataConfigPager.clear();
|
||||
return asHtml(path_AdminDataconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -106,17 +110,17 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final DataConfigSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminDataconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final DataConfigSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("dataConfigItems", dataConfigService.getDataConfigList(dataConfigPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(dataConfigPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(dataConfigPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -127,9 +131,44 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final DataConfigEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminDataconfig_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminDataconfig_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminDataconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -138,11 +177,9 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final DataConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadDataConfig(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminDataconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -151,18 +188,15 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final DataConfigEditForm form) {
|
||||
return asHtml(path_AdminDataconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final DataConfigEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadDataConfig(form);
|
||||
final String id = form.id;
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminDataconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -171,12 +205,20 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final DataConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadDataConfig(form);
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).renderWith(data -> {
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
|
@ -184,9 +226,15 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final DataConfigEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadDataConfig(form);
|
||||
final String id = form.id;
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -197,26 +245,30 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final DataConfigEditForm form) {
|
||||
try {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadDataConfig(form);
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp);
|
||||
}
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final DataConfigEditForm form) {
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -225,8 +277,9 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final DataConfigEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminDataconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
registerHandlerNames(data);
|
||||
|
@ -238,66 +291,78 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final DataConfigEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
dataConfigService.store(createDataConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createDataConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
dataConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final DataConfigEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
dataConfigService.store(createDataConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createDataConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
dataConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final DataConfigEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
dataConfigService.delete(getDataConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
dataConfigService.getDataConfig(id).ifPresent(entity -> {
|
||||
dataConfigService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadDataConfig(final DataConfigEditForm form) {
|
||||
copyBeanToBean(getDataConfig(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected DataConfig getDataConfig(final DataConfigEditForm form) {
|
||||
final DataConfig dataConfig = dataConfigService.getDataConfig(createKeyMap(form));
|
||||
if (dataConfig == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return dataConfig;
|
||||
}
|
||||
|
||||
protected DataConfig createDataConfig(final DataConfigEditForm form) {
|
||||
DataConfig dataConfig;
|
||||
protected OptionalEntity<DataConfig> createDataConfig(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
dataConfig = getDataConfig(form);
|
||||
} else {
|
||||
dataConfig = new DataConfig();
|
||||
dataConfig.setCreatedBy(username);
|
||||
dataConfig.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final DataConfig entity = new DataConfig();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return dataConfigService.getDataConfig(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dataConfig.setUpdatedBy(username);
|
||||
dataConfig.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, dataConfig, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return dataConfig;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final DataConfigEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected void registerRolesAndLabels(final RenderData data) {
|
||||
|
@ -305,7 +370,7 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
data.register("labelTypeItems", labelTypeService.getLabelTypeList());
|
||||
}
|
||||
|
||||
public void registerHandlerNames(final RenderData data) {
|
||||
protected void registerHandlerNames(final RenderData data) {
|
||||
final List<String> dataStoreNameList = dataStoreFactory.getDataStoreNameList();
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
for (final String name : dataStoreNameList) {
|
||||
|
@ -320,10 +385,10 @@ public class AdminDataconfigAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final DataConfigEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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.app.web.admin.dataconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 200)
|
||||
public String name;
|
||||
|
||||
@Required
|
||||
@Size(max = 4000)
|
||||
public String handlerName;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String handlerParameter;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String handlerScript;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
public String available;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer sortOrder;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -1,113 +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.app.web.admin.dataconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class DataConfigEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
//@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")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 200)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String handlerName;
|
||||
|
||||
public String handlerParameter;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String handlerScript;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 5)
|
||||
public String available;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String sortOrder;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
handlerName = null;
|
||||
handlerParameter = null;
|
||||
handlerScript = null;
|
||||
boost = "1";
|
||||
available = null;
|
||||
sortOrder = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
sortOrder = "0";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.app.web.admin.dataconfig;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -17,16 +17,14 @@
|
|||
package org.codelibs.fess.app.web.admin.dataconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class DataConfigSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.codelibs.fess.app.web.admin.fileconfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -28,9 +25,13 @@ import org.codelibs.fess.app.service.FileConfigService;
|
|||
import org.codelibs.fess.app.service.LabelTypeService;
|
||||
import org.codelibs.fess.app.service.RoleTypeService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.fileconfig.CreateForm;
|
||||
import org.codelibs.fess.app.web.admin.fileconfig.EditForm;
|
||||
import org.codelibs.fess.app.web.admin.fileconfig.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.FileConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -51,11 +52,11 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
@Resource
|
||||
private FileConfigPager fileConfigPager;
|
||||
@Resource
|
||||
private RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
private LabelTypeService labelTypeService;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
protected LabelTypeService labelTypeService;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
|
@ -70,14 +71,14 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final FileConfigSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminFileconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final FileConfigSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
fileConfigPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminFileconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -85,15 +86,15 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final FileConfigSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, fileConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, fileConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminFileconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final FileConfigSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
fileConfigPager.clear();
|
||||
return asHtml(path_AdminFileconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -101,17 +102,17 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final FileConfigSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminFileconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final FileConfigSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("fileConfigItems", fileConfigService.getFileConfigList(fileConfigPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(fileConfigPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(fileConfigPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -122,9 +123,42 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final FileConfigEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminFileconfig_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminFileconfig_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminFileconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -132,11 +166,9 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final FileConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadFileConfig(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminFileconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -144,17 +176,15 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final FileConfigEditForm form) {
|
||||
return asHtml(path_AdminFileconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final FileConfigEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadFileConfig(form);
|
||||
final String id = form.id;
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminFileconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -162,21 +192,35 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final FileConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadFileConfig(form);
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).renderWith(data -> {
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final FileConfigEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadFileConfig(form);
|
||||
final String id = form.id;
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -186,25 +230,29 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final FileConfigEditForm form) {
|
||||
try {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadFileConfig(form);
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp);
|
||||
}
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final FileConfigEditForm form) {
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -212,8 +260,9 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final FileConfigEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminFileconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -224,66 +273,78 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final FileConfigEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
fileConfigService.store(createFileConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createFileConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
fileConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final FileConfigEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
fileConfigService.store(createFileConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createFileConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
fileConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final FileConfigEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
fileConfigService.delete(getFileConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
fileConfigService.getFileConfig(id).ifPresent(entity -> {
|
||||
fileConfigService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadFileConfig(final FileConfigEditForm form) {
|
||||
copyBeanToBean(getFileConfig(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected FileConfig getFileConfig(final FileConfigEditForm form) {
|
||||
final FileConfig fileConfig = fileConfigService.getFileConfig(createKeyMap(form));
|
||||
if (fileConfig == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return fileConfig;
|
||||
}
|
||||
|
||||
protected FileConfig createFileConfig(final FileConfigEditForm form) {
|
||||
FileConfig fileConfig;
|
||||
protected OptionalEntity<FileConfig> createFileConfig(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
fileConfig = getFileConfig(form);
|
||||
} else {
|
||||
fileConfig = new FileConfig();
|
||||
fileConfig.setCreatedBy(username);
|
||||
fileConfig.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final FileConfig entity = new FileConfig();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return fileConfigService.getFileConfig(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fileConfig.setUpdatedBy(username);
|
||||
fileConfig.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, fileConfig, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return fileConfig;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final FileConfigEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected void registerRolesAndLabels(final RenderData data) {
|
||||
|
@ -294,10 +355,10 @@ public class AdminFileconfigAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final FileConfigEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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.app.web.admin.fileconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 200)
|
||||
public String name;
|
||||
|
||||
@Required
|
||||
@UriType(protocols = "file:,smb:")
|
||||
@Size(max = 4000)
|
||||
public String paths;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String includedPaths;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String excludedPaths;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String includedDocPaths;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String excludedDocPaths;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String configParameter;
|
||||
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer depth;
|
||||
|
||||
@Min(value = 0)
|
||||
@Max(value = 9223372036854775807l)
|
||||
public Long maxAccessCount;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer numOfThread;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer intervalTime;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
public String available;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer sortOrder;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
numOfThread = Constants.DEFAULT_NUM_OF_THREAD_FOR_FS;
|
||||
intervalTime = Constants.DEFAULT_INTERVAL_TIME_FOR_FS;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.app.web.admin.fileconfig;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -1,138 +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.app.web.admin.fileconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileConfigEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 200)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
@UriType(protocols = "file:,smb:")
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String paths;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String includedPaths;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String excludedPaths;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String includedDocPaths;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String excludedDocPaths;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String configParameter;
|
||||
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String depth;
|
||||
|
||||
//@LongRange(min = 0, max = 9223372036854775807l)
|
||||
public String maxAccessCount;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String numOfThread;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String intervalTime;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 5)
|
||||
public String available;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String sortOrder;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
paths = null;
|
||||
includedPaths = null;
|
||||
excludedPaths = null;
|
||||
includedDocPaths = null;
|
||||
excludedDocPaths = null;
|
||||
configParameter = null;
|
||||
depth = null;
|
||||
maxAccessCount = null;
|
||||
numOfThread = null;
|
||||
intervalTime = null;
|
||||
boost = "1";
|
||||
available = null;
|
||||
sortOrder = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
sortOrder = "0";
|
||||
numOfThread = Integer.toString(Constants.DEFAULT_NUM_OF_THREAD_FOR_FS);
|
||||
intervalTime = Integer.toString(Constants.DEFAULT_INTERVAL_TIME_FOR_FS);
|
||||
}
|
||||
}
|
|
@ -17,16 +17,14 @@
|
|||
package org.codelibs.fess.app.web.admin.fileconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class FileConfigSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -128,7 +128,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminLabeltype_EditJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminLabeltype_EditJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminLabeltype_EditJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminLabeltype_ConfirmJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminLabeltype_ConfirmJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminLabeltype_ConfirmJsp).renderWith(data -> {
|
||||
registerItems(data);
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected void registerItems(final RenderData data) {
|
||||
protected void registerRoleTypeItems(final RenderData data) {
|
||||
data.register("roleTypeItems", roleTypeService.getRoleTypeList());
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,9 @@ public class AdminLabeltypeAction extends FessAdminAction {
|
|||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminLabeltype_EditJsp);
|
||||
return asHtml(path_AdminLabeltype_EditJsp).renderWith(data -> {
|
||||
registerRoleTypeItems(data);
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.codelibs.fess.app.web.admin.pathmapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -29,6 +26,7 @@ import org.codelibs.fess.app.web.CrudMode;
|
|||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.PathMapping;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -38,6 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
/**
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminPathmappingAction extends FessAdminAction {
|
||||
|
||||
|
@ -64,14 +63,14 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final PathMappingSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminPathmapping_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final PathMappingSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
pathMappingPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminPathmapping_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -79,15 +78,15 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final PathMappingSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, pathMappingPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, pathMappingPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminPathmapping_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final PathMappingSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
pathMappingPager.clear();
|
||||
return asHtml(path_AdminPathmapping_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -95,17 +94,17 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final PathMappingSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminPathmapping_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final PathMappingSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("pathMappingItems", pathMappingService.getPathMappingList(pathMappingPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(pathMappingPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(pathMappingPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -116,51 +115,92 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final PathMappingEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminPathmapping_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminPathmapping_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminPathmapping_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final PathMappingEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadPathMapping(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminPathmapping_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final PathMappingEditForm form) {
|
||||
return asHtml(path_AdminPathmapping_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final PathMappingEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadPathMapping(form);
|
||||
final String id = form.id;
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminPathmapping_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final PathMappingEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadPathMapping(form);
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final PathMappingEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadPathMapping(form);
|
||||
final String id = form.id;
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -168,25 +208,35 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final PathMappingEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadPathMapping(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final PathMappingEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final PathMappingEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminPathmapping_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -195,75 +245,87 @@ public class AdminPathmappingAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final PathMappingEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
pathMappingService.store(createPathMapping(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createPathMapping(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
pathMappingService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final PathMappingEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
pathMappingService.store(createPathMapping(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createPathMapping(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
pathMappingService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final PathMappingEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
pathMappingService.delete(getPathMapping(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
pathMappingService.getPathMapping(id).ifPresent(entity -> {
|
||||
pathMappingService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadPathMapping(final PathMappingEditForm form) {
|
||||
copyBeanToBean(getPathMapping(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected PathMapping getPathMapping(final PathMappingEditForm form) {
|
||||
final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap(form));
|
||||
if (pathMapping == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return pathMapping;
|
||||
}
|
||||
|
||||
protected PathMapping createPathMapping(final PathMappingEditForm form) {
|
||||
PathMapping pathMapping;
|
||||
protected OptionalEntity<PathMapping> createPathMapping(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
pathMapping = getPathMapping(form);
|
||||
} else {
|
||||
pathMapping = new PathMapping();
|
||||
pathMapping.setCreatedBy(username);
|
||||
pathMapping.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final PathMapping entity = new PathMapping();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return pathMappingService.getPathMapping(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pathMapping.setUpdatedBy(username);
|
||||
pathMapping.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, pathMapping, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return pathMapping;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final PathMappingEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final PathMappingEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.app.web.admin.pathmapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String regex;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String replacement;
|
||||
|
||||
@Required
|
||||
public String processType;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer sortOrder;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.app.web.admin.pathmapping;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -1,84 +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.app.web.admin.pathmapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class PathMappingEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String regex;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String replacement;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
public String processType;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String sortOrder;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
regex = null;
|
||||
replacement = null;
|
||||
processType = null;
|
||||
sortOrder = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
sortOrder = "0";
|
||||
}
|
||||
}
|
|
@ -17,16 +17,14 @@
|
|||
package org.codelibs.fess.app.web.admin.pathmapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class PathMappingSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -30,11 +30,15 @@ import org.codelibs.fess.app.pager.RequestHeaderPager;
|
|||
import org.codelibs.fess.app.service.RequestHeaderService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.requestheader.CreateForm;
|
||||
import org.codelibs.fess.app.web.admin.requestheader.EditForm;
|
||||
import org.codelibs.fess.app.web.admin.requestheader.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.RequestHeader;
|
||||
import org.codelibs.fess.es.exentity.WebConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -45,6 +49,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
/**
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminRequestheaderAction extends FessAdminAction {
|
||||
|
||||
|
@ -56,9 +61,9 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
@Resource
|
||||
private RequestHeaderPager requestHeaderPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected WebConfigService webConfigService;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
|
@ -73,14 +78,14 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final RequestHeaderSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminRequestheader_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final RequestHeaderSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
requestHeaderPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminRequestheader_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -88,15 +93,15 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final RequestHeaderSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, requestHeaderPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, requestHeaderPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminRequestheader_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final RequestHeaderSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
requestHeaderPager.clear();
|
||||
return asHtml(path_AdminRequestheader_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -104,18 +109,18 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final RequestHeaderSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminRequestheader_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final RequestHeaderSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("requestHeaderItems", requestHeaderService.getRequestHeaderList(requestHeaderPager)); // page navi
|
||||
data.register("displayCreateLink", !webConfigService.getAllWebConfigList(false, false, false, null).isEmpty());
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(requestHeaderPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(requestHeaderPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -126,9 +131,44 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final RequestHeaderEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminRequestheader_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminRequestheader_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRequestheader_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
|
@ -137,11 +177,9 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final RequestHeaderEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadRequestHeader(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRequestheader_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
|
@ -150,18 +188,15 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final RequestHeaderEditForm form) {
|
||||
return asHtml(path_AdminRequestheader_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadRequestHeader(form);
|
||||
final String id = form.id;
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminRequestheader_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
|
@ -170,12 +205,20 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final RequestHeaderEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadRequestHeader(form);
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).renderWith(data -> {
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
|
@ -183,9 +226,15 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadRequestHeader(form);
|
||||
final String id = form.id;
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
|
@ -196,26 +245,45 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final RequestHeaderEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadRequestHeader(form);
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp);
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp);
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminRequestheader_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -223,66 +291,78 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
requestHeaderService.store(createRequestHeader(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createRequestHeader(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
requestHeaderService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final RequestHeaderEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
requestHeaderService.store(createRequestHeader(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createRequestHeader(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
requestHeaderService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final RequestHeaderEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
requestHeaderService.delete(getRequestHeader(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
requestHeaderService.getRequestHeader(id).ifPresent(entity -> {
|
||||
requestHeaderService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadRequestHeader(final RequestHeaderEditForm form) {
|
||||
copyBeanToBean(getRequestHeader(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected RequestHeader getRequestHeader(final RequestHeaderEditForm form) {
|
||||
final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap(form));
|
||||
if (requestHeader == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return requestHeader;
|
||||
}
|
||||
|
||||
protected RequestHeader createRequestHeader(final RequestHeaderEditForm form) {
|
||||
RequestHeader requestHeader;
|
||||
protected OptionalEntity<RequestHeader> createRequestHeader(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
requestHeader = getRequestHeader(form);
|
||||
} else {
|
||||
requestHeader = new RequestHeader();
|
||||
requestHeader.setCreatedBy(username);
|
||||
requestHeader.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final RequestHeader entity = new RequestHeader();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return requestHeaderService.getRequestHeader(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
requestHeader.setUpdatedBy(username);
|
||||
requestHeader.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, requestHeader, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return requestHeader;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final RequestHeaderEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected void registerProtocolSchemeItems(final RenderData data) {
|
||||
|
@ -316,10 +396,10 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final RequestHeaderEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
@ -327,6 +407,7 @@ public class AdminRequestheaderAction extends FessAdminAction {
|
|||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminRequestheader_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.app.web.admin.requestheader;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String name;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String value;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String webConfigId;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.app.web.admin.requestheader;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -1,79 +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.app.web.admin.requestheader;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class RequestHeaderEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String value;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String webConfigId;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
value = null;
|
||||
webConfigId = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
}
|
||||
}
|
|
@ -17,16 +17,15 @@
|
|||
package org.codelibs.fess.app.web.admin.requestheader;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class RequestHeaderSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -16,21 +16,22 @@
|
|||
|
||||
package org.codelibs.fess.app.web.admin.webconfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.WebConfigPager;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
import org.codelibs.fess.app.service.LabelTypeService;
|
||||
import org.codelibs.fess.app.service.RoleTypeService;
|
||||
import org.codelibs.fess.app.service.WebConfigService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.webconfig.CreateForm;
|
||||
import org.codelibs.fess.app.web.admin.webconfig.EditForm;
|
||||
import org.codelibs.fess.app.web.admin.webconfig.SearchForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.WebConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -40,6 +41,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
/**
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminWebconfigAction extends FessAdminAction {
|
||||
|
||||
|
@ -51,11 +53,11 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Resource
|
||||
private WebConfigPager webConfigPager;
|
||||
@Resource
|
||||
private RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
private LabelTypeService labelTypeService;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected RoleTypeService roleTypeService;
|
||||
@Resource
|
||||
protected LabelTypeService labelTypeService;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
|
@ -70,14 +72,14 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final WebConfigSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminWebconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final WebConfigSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
webConfigPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminWebconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -85,15 +87,15 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final WebConfigSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, webConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, webConfigPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminWebconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final WebConfigSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
webConfigPager.clear();
|
||||
return asHtml(path_AdminWebconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -101,17 +103,17 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final WebConfigSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminWebconfig_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final WebConfigSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("webConfigItems", webConfigService.getWebConfigList(webConfigPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(webConfigPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(webConfigPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -122,9 +124,42 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final WebConfigEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminWebconfig_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminWebconfig_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -132,11 +167,9 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final WebConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadWebConfig(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -144,17 +177,15 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final WebConfigEditForm form) {
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final WebConfigEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadWebConfig(form);
|
||||
final String id = form.id;
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -162,21 +193,35 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final WebConfigEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadWebConfig(form);
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final WebConfigEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadWebConfig(form);
|
||||
final String id = form.id;
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -186,26 +231,29 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final WebConfigEditForm form) {
|
||||
try {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadWebConfig(form);
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp);
|
||||
}
|
||||
|
||||
}).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final WebConfigEditForm form) {
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -213,8 +261,9 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final WebConfigEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
|
@ -225,66 +274,78 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final WebConfigEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
webConfigService.store(createWebConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createWebConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
webConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final WebConfigEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
webConfigService.store(createWebConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createWebConfig(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
webConfigService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final WebConfigEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
webConfigService.delete(getWebConfig(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
webConfigService.getWebConfig(id).ifPresent(entity -> {
|
||||
webConfigService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadWebConfig(final WebConfigEditForm form) {
|
||||
copyBeanToBean(getWebConfig(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected WebConfig getWebConfig(final WebConfigEditForm form) {
|
||||
final WebConfig webConfig = webConfigService.getWebConfig(createKeyMap(form));
|
||||
if (webConfig == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return webConfig;
|
||||
}
|
||||
|
||||
protected WebConfig createWebConfig(final WebConfigEditForm form) {
|
||||
WebConfig webConfig;
|
||||
protected OptionalEntity<WebConfig> createWebConfig(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
webConfig = getWebConfig(form);
|
||||
} else {
|
||||
webConfig = new WebConfig();
|
||||
webConfig.setCreatedBy(username);
|
||||
webConfig.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final WebConfig entity = new WebConfig();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return webConfigService.getWebConfig(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
webConfig.setUpdatedBy(username);
|
||||
webConfig.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, webConfig, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return webConfig;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final WebConfigEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
protected void registerRolesAndLabels(final RenderData data) {
|
||||
|
@ -295,10 +356,10 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final WebConfigEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* 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.app.web.admin.webconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
public Integer crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 200)
|
||||
public String name;
|
||||
|
||||
@Required
|
||||
@UriType(protocols = "http:,https:")
|
||||
@Size(max = 4000)
|
||||
public String urls;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String includedUrls;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String excludedUrls;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String includedDocUrls;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String excludedDocUrls;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String configParameter;
|
||||
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer depth;
|
||||
|
||||
@Min(value = 0)
|
||||
@Max(value = 9223372036854775807l)
|
||||
public Long maxAccessCount;
|
||||
|
||||
@Required
|
||||
@Size(max = 200)
|
||||
public String userAgent;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer numOfThread;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer intervalTime;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
public String available;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public Integer sortOrder;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
if (StringUtil.isBlank(userAgent)) {
|
||||
userAgent = "FessCrawler/" + Constants.FESS_VERSION;
|
||||
}
|
||||
numOfThread = Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB;
|
||||
intervalTime = Constants.DEFAULT_INTERVAL_TIME_FOR_WEB;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.app.web.admin.webconfig;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -17,16 +17,15 @@
|
|||
package org.codelibs.fess.app.web.admin.webconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class WebConfigSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -1,147 +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.app.web.admin.webconfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.UriType;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class WebConfigEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String[] roleTypeIds;
|
||||
|
||||
public String[] labelTypeIds;
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 200)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
@UriType(protocols = "http:,https:")
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String urls;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String includedUrls;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String excludedUrls;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String includedDocUrls;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String excludedDocUrls;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String configParameter;
|
||||
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String depth;
|
||||
|
||||
//@LongRange(min = 0, max = 9223372036854775807l)
|
||||
public String maxAccessCount;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 200)
|
||||
public String userAgent;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String numOfThread;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String intervalTime;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 5)
|
||||
public String available;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String sortOrder;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
urls = null;
|
||||
includedUrls = null;
|
||||
excludedUrls = null;
|
||||
includedDocUrls = null;
|
||||
excludedDocUrls = null;
|
||||
configParameter = null;
|
||||
depth = null;
|
||||
maxAccessCount = null;
|
||||
userAgent = null;
|
||||
numOfThread = null;
|
||||
intervalTime = null;
|
||||
boost = "1";
|
||||
available = null;
|
||||
sortOrder = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
sortOrder = "0";
|
||||
userAgent = ComponentUtil.getUserAgentName();
|
||||
if (StringUtil.isBlank(userAgent)) {
|
||||
userAgent = "FessCrawler/" + Constants.FESS_VERSION;
|
||||
}
|
||||
numOfThread = Integer.toString(Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB);
|
||||
intervalTime = Integer.toString(Constants.DEFAULT_INTERVAL_TIME_FOR_WEB);
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ public class FileAuthentication extends BsFileAuthentication {
|
|||
public FileConfig getFileConfig() {
|
||||
if (fileConfig == null) {
|
||||
final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
|
||||
fileConfig = fileConfigService.getFileConfig(getFileConfigId());
|
||||
fileConfig = fileConfigService.getFileConfig(getFileConfigId()).get();
|
||||
}
|
||||
return fileConfig;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RequestHeader extends BsRequestHeader {
|
|||
public WebConfig getWebConfig() {
|
||||
if (webConfig == null) {
|
||||
final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
|
||||
webConfig = webConfigService.getWebConfig(getWebConfigId());
|
||||
webConfig = webConfigService.getWebConfig(getWebConfigId()).get();
|
||||
}
|
||||
return webConfig;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class WebAuthentication extends BsWebAuthentication {
|
|||
public WebConfig getWebConfig() {
|
||||
if (webConfig == null) {
|
||||
final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
|
||||
webConfig = webConfigService.getWebConfig(getWebConfigId());
|
||||
webConfig = webConfigService.getWebConfig(getWebConfigId()).get();
|
||||
}
|
||||
return webConfig;
|
||||
}
|
||||
|
|
|
@ -73,13 +73,13 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
switch (configType) {
|
||||
case WEB:
|
||||
final WebConfigService webConfigService = SingletonLaContainer.getComponent(WebConfigService.class);
|
||||
return webConfigService.getWebConfig(id);
|
||||
return webConfigService.getWebConfig(id).get();
|
||||
case FILE:
|
||||
final FileConfigService fileConfigService = SingletonLaContainer.getComponent(FileConfigService.class);
|
||||
return fileConfigService.getFileConfig(id);
|
||||
return fileConfigService.getFileConfig(id).get();
|
||||
case DATA:
|
||||
final DataConfigService dataConfigService = SingletonLaContainer.getComponent(DataConfigService.class);
|
||||
return dataConfigService.getDataConfig(id);
|
||||
return dataConfigService.getDataConfig(id).get();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -496,13 +496,13 @@ public class ViewHelper implements Serializable {
|
|||
}
|
||||
if (ConfigType.WEB == configType) {
|
||||
final WebConfigService webConfigService = SingletonLaContainer.getComponent(WebConfigService.class);
|
||||
config = webConfigService.getWebConfig(crawlingConfigHelper.getId(configId));
|
||||
config = webConfigService.getWebConfig(crawlingConfigHelper.getId(configId)).get();
|
||||
} else if (ConfigType.FILE == configType) {
|
||||
final FileConfigService fileConfigService = SingletonLaContainer.getComponent(FileConfigService.class);
|
||||
config = fileConfigService.getFileConfig(crawlingConfigHelper.getId(configId));
|
||||
config = fileConfigService.getFileConfig(crawlingConfigHelper.getId(configId)).get();
|
||||
} else if (ConfigType.DATA == configType) {
|
||||
final DataConfigService dataConfigService = SingletonLaContainer.getComponent(DataConfigService.class);
|
||||
config = dataConfigService.getDataConfig(crawlingConfigHelper.getId(configId));
|
||||
config = dataConfigService.getDataConfig(crawlingConfigHelper.getId(configId)).get();
|
||||
}
|
||||
if (config == null) {
|
||||
throw new FessSystemException("No crawlingConfig: " + configIdObj);
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
<%-- Box Footer --%>
|
||||
<div class="box-footer">
|
||||
<c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn" name="editagain" value="<la:message key="labels.data_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn" name="createagain" value="<la:message key="labels.data_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="<la:message key="labels.data_crawling_button_create"/>"
|
||||
/>
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
<%-- Box Footer --%>
|
||||
<div class="box-footer">
|
||||
<c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn" name="editagain" value="<la:message key="labels.file_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn" name="createagain" value="<la:message key="labels.file_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="<la:message key="labels.file_crawling_button_create"/>"
|
||||
/>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<jsp:param name="menuCategoryType" value="crawl" />
|
||||
<jsp:param name="menuType" value="pathMapping" />
|
||||
</jsp:include>
|
||||
|
||||
|
||||
<div class="content-wrapper">
|
||||
<%-- Content Header --%>
|
||||
<section class="content-header">
|
||||
|
@ -20,7 +20,7 @@
|
|||
<la:message key="labels.path_mapping_title_details" />
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
|
||||
|
||||
<li><la:link href="index">
|
||||
<la:message key="labels.path_mapping_link_list" />
|
||||
</la:link></li>
|
||||
|
@ -102,13 +102,13 @@
|
|||
<td>
|
||||
<c:if test="${processType=='C'}">
|
||||
<la:message key="labels.path_mapping_pt_crawling" />
|
||||
</c:if>
|
||||
</c:if>
|
||||
<c:if test="${processType=='D'}">
|
||||
<la:message key="labels.path_mapping_pt_displaying" />
|
||||
</c:if>
|
||||
<c:if test="${processType=='B'}">
|
||||
<la:message key="labels.path_mapping_pt_both" />
|
||||
</c:if>
|
||||
</c:if>
|
||||
<la:hidden property="processType" />
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<%-- Box Footer --%>
|
||||
<div class="box-footer">
|
||||
<c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn" name="editagain" value="<la:message key="labels.path_mapping_button_back"/>" />
|
||||
<input type="submit" class="btn" name="createagain" value="<la:message key="labels.path_mapping_button_back"/>" />
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="<la:message key="labels.path_mapping_button_create"/>"
|
||||
/>
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<%-- Box Footer --%>
|
||||
<div class="box-footer">
|
||||
<c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn" name="editagain" value="<la:message key="labels.request_header_button_back"/>" />
|
||||
<input type="submit" class="btn" name="createagain" value="<la:message key="labels.request_header_button_back"/>" />
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="<la:message key="labels.request_header_button_create"/>"
|
||||
/>
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
<%-- Box Footer --%>
|
||||
<div class="box-footer">
|
||||
<c:if test="${crudMode == 1}">
|
||||
<input type="submit" class="btn" name="editagain" value="<la:message key="labels.web_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn" name="createagain" value="<la:message key="labels.web_crawling_button_back"/>" />
|
||||
<input type="submit" class="btn btn-primary" name="create"
|
||||
value="<la:message key="labels.web_crawling_button_create"/>"
|
||||
/>
|
||||
|
|
Loading…
Add table
Reference in a new issue