diff --git a/src/main/java/org/codelibs/fess/app/service/DataConfigService.java b/src/main/java/org/codelibs/fess/app/service/DataConfigService.java index 631fbaf0c..76ef7e36e 100644 --- a/src/main/java/org/codelibs/fess/app/service/DataConfigService.java +++ b/src/main/java/org/codelibs/fess/app/service/DataConfigService.java @@ -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 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 getDataConfig(final String id) { + return dataConfigBhv.selectByPK(id).map(entity -> { final List fctrtmList = dataConfigToRoleBhv.selectList(fctrtmCb -> { - fctrtmCb.query().setDataConfigId_Equal(dataConfig.getId()); + fctrtmCb.query().setDataConfigId_Equal(entity.getId()); }); if (!fctrtmList.isEmpty()) { final List roleTypeIds = new ArrayList(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 fctltmList = dataConfigToLabelBhv.selectList(fctltmCb -> { - fctltmCb.query().setDataConfigId_Equal(dataConfig.getId()); + fctltmCb.query().setDataConfigId_Equal(entity.getId()); }); if (!fctltmList.isEmpty()) { final List labelTypeIds = new ArrayList(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 - } - } diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java index 7b6829bfe..2ae39edc3 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java @@ -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 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 createKeyMap(final DataConfigEditForm form) { - final Map keys = new HashMap(); - 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 dataStoreNameList = dataStoreFactory.getDataStoreNameList(); final List> itemList = new ArrayList>(); 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()); } } diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/CreateForm.java new file mode 100644 index 000000000..3d3ce44b1 --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/CreateForm.java @@ -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(); + } +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigEditForm.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigEditForm.java deleted file mode 100644 index 15d75942d..000000000 --- a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigEditForm.java +++ /dev/null @@ -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 searchParams = new HashMap(); - - //@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"; - } -} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/EditForm.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/EditForm.java new file mode 100644 index 000000000..e673e57aa --- /dev/null +++ b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/EditForm.java @@ -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; + +} diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigSearchForm.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/SearchForm.java similarity index 81% rename from src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigSearchForm.java rename to src/main/java/org/codelibs/fess/app/web/admin/dataconfig/SearchForm.java index 4832dd76f..cd4aad5d3 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/DataConfigSearchForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/SearchForm.java @@ -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 searchParams = new HashMap(); + public String id; } diff --git a/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java b/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java index cf3c7ab7b..320d27bed 100644 --- a/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java +++ b/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java @@ -79,7 +79,7 @@ public class CrawlingConfigHelper implements Serializable { 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; } diff --git a/src/main/java/org/codelibs/fess/helper/ViewHelper.java b/src/main/java/org/codelibs/fess/helper/ViewHelper.java index a03242b94..43eab21ff 100644 --- a/src/main/java/org/codelibs/fess/helper/ViewHelper.java +++ b/src/main/java/org/codelibs/fess/helper/ViewHelper.java @@ -502,7 +502,7 @@ public class ViewHelper implements Serializable { 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); diff --git a/src/main/webapp/WEB-INF/view/admin/dataconfig/confirm.jsp b/src/main/webapp/WEB-INF/view/admin/dataconfig/confirm.jsp index ea0d4b0d3..95f5fa475 100644 --- a/src/main/webapp/WEB-INF/view/admin/dataconfig/confirm.jsp +++ b/src/main/webapp/WEB-INF/view/admin/dataconfig/confirm.jsp @@ -169,7 +169,7 @@ <%-- Box Footer --%>