fix #2654 add validation
This commit is contained in:
parent
995c26a888
commit
5762adcf9c
6 changed files with 60 additions and 0 deletions
|
@ -278,6 +278,7 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE, form.dictId);
|
||||
validate(form, messages -> {}, this::asEditHtml);
|
||||
verifyForm(form);
|
||||
verifyToken(this::asEditHtml);
|
||||
createKuromojiItem(form, this::asEditHtml).ifPresent(entity -> {
|
||||
try {
|
||||
|
@ -298,6 +299,7 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT, form.dictId);
|
||||
validate(form, messages -> {}, this::asEditHtml);
|
||||
verifyForm(form);
|
||||
verifyToken(this::asEditHtml);
|
||||
createKuromojiItem(form, this::asEditHtml).ifPresent(entity -> {
|
||||
try {
|
||||
|
@ -384,6 +386,19 @@ public class AdminDictKuromojiAction extends FessAdminAction {
|
|||
}
|
||||
}
|
||||
|
||||
protected void verifyForm(final CreateForm form) {
|
||||
if (form.token != null && form.token.split(" ").length > 1) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsInvalidKuromojiToken("token", form.token);
|
||||
}, this::asEditHtml);
|
||||
}
|
||||
if (form.segmentation != null && form.reading != null && form.segmentation.split(" ").length != form.reading.split(" ").length) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsInvalidKuromojiSegmentation("segmentation", form.segmentation, form.reading);
|
||||
}, this::asEditHtml);
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
|
|
|
@ -293,6 +293,12 @@ public class FessMessages extends FessLabels {
|
|||
/** The key of the message: Failed to upload the Mapping file. */
|
||||
public static final String ERRORS_failed_to_upload_mapping_file = "{errors.failed_to_upload_mapping_file}";
|
||||
|
||||
/** The key of the message: {0} is invalid. */
|
||||
public static final String ERRORS_invalid_kuromoji_token = "{errors.invalid_kuromoji_token}";
|
||||
|
||||
/** The key of the message: The number of segmentations {0} does not the match number of readings {1}. */
|
||||
public static final String ERRORS_invalid_kuromoji_segmentation = "{errors.invalid_kuromoji_segmentation}";
|
||||
|
||||
/** The key of the message: "{1}" in "{0}" is invalid. */
|
||||
public static final String ERRORS_invalid_str_is_included = "{errors.invalid_str_is_included}";
|
||||
|
||||
|
@ -1809,6 +1815,37 @@ public class FessMessages extends FessLabels {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.invalid_kuromoji_token' with parameters.
|
||||
* <pre>
|
||||
* message: {0} is invalid.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @param arg0 The parameter arg0 for message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
*/
|
||||
public FessMessages addErrorsInvalidKuromojiToken(String property, String arg0) {
|
||||
assertPropertyNotNull(property);
|
||||
add(property, new UserMessage(ERRORS_invalid_kuromoji_token, arg0));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.invalid_kuromoji_segmentation' with parameters.
|
||||
* <pre>
|
||||
* message: The number of segmentations {0} does not the match number of readings {1}.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @param arg0 The parameter arg0 for message. (NotNull)
|
||||
* @param arg1 The parameter arg1 for message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
*/
|
||||
public FessMessages addErrorsInvalidKuromojiSegmentation(String property, String arg0, String arg1) {
|
||||
assertPropertyNotNull(property);
|
||||
add(property, new UserMessage(ERRORS_invalid_kuromoji_segmentation, arg0, arg1));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.invalid_str_is_included' with parameters.
|
||||
* <pre>
|
||||
|
|
|
@ -119,6 +119,8 @@ errors.failed_to_download_badword_file=Failed to download the Badword file.
|
|||
errors.failed_to_upload_badword_file=Failed to upload the Badword file.
|
||||
errors.failed_to_download_mapping_file=Failed to download the Mapping file.
|
||||
errors.failed_to_upload_mapping_file=Failed to upload the Mapping file.
|
||||
errors.invalid_kuromoji_token={0} is invalid.
|
||||
errors.invalid_kuromoji_segmentation=The number of segmentations {0} does not the match number of readings {1}.
|
||||
errors.invalid_str_is_included="{1}" in "{0}" is invalid.
|
||||
errors.blank_password=Password is required.
|
||||
errors.invalid_confirm_password=Confirm Password does not match.
|
||||
|
|
|
@ -115,6 +115,8 @@ errors.failed_to_download_badword_file=Failed to download the Badword file.
|
|||
errors.failed_to_upload_badword_file=Failed to upload the Badword file.
|
||||
errors.failed_to_download_mapping_file=Failed to download the Mapping file.
|
||||
errors.failed_to_upload_mapping_file=Failed to upload the Mapping file.
|
||||
errors.invalid_kuromoji_token={0} is invalid.
|
||||
errors.invalid_kuromoji_segmentation=The number of segmentations {0} does not the match number of readings {1}.
|
||||
errors.invalid_str_is_included="{1}" in "{0}" is invalid.
|
||||
errors.blank_password=Password is required.
|
||||
errors.invalid_confirm_password=Confirm Password does not match.
|
||||
|
|
|
@ -111,6 +111,8 @@ errors.failed_to_download_badword_file = 除外ワードファイルのダウン
|
|||
errors.failed_to_upload_badword_file = 除外ワードファイルのアップロードに失敗しました。
|
||||
errors.failed_to_download_mapping_file = マッピングファイルのダウンロードに失敗しました。
|
||||
errors.failed_to_upload_mapping_file = マッピングファイルのアップロードに失敗しました。
|
||||
errors.invalid_kuromoji_token={0} はトークンとして正しくありません。
|
||||
errors.invalid_kuromoji_segmentation={0} の分割数と {1}の分割数が一致しません。
|
||||
errors.invalid_str_is_included = {0}では{1}は無効です。
|
||||
errors.blank_password = パスワードが必要になります。
|
||||
errors.invalid_confirm_password = パスワードの確認と一致しません。
|
||||
|
|
|
@ -111,6 +111,8 @@ errors.failed_to_download_protwords_file=Failed to download the Protwords file.
|
|||
errors.failed_to_upload_protwords_file=Failed to upload the Protwords file.
|
||||
errors.failed_to_download_mapping_file=Failed to download the Mapping file.
|
||||
errors.failed_to_upload_mapping_file=Failed to upload the Mapping file.
|
||||
errors.invalid_kuromoji_token={0} is invalid.
|
||||
errors.invalid_kuromoji_segmentation=The number of segmentations {0} does not the match number of readings {1}.
|
||||
errors.invalid_str_is_included="{1}" in "{0}" is invalid.
|
||||
errors.blank_password=Password is required.
|
||||
errors.invalid_confirm_password=Confirm Password does not match.
|
||||
|
|
Loading…
Add table
Reference in a new issue