refactoring for web config
This commit is contained in:
parent
6f28da6f92
commit
005999c56f
11 changed files with 354 additions and 283 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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,7 +73,7 @@ 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);
|
||||
|
|
|
@ -496,7 +496,7 @@ 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));
|
||||
|
|
|
@ -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