modify searchlist page
This commit is contained in:
parent
b58fae8193
commit
7037bdb037
5 changed files with 79 additions and 28 deletions
|
@ -186,34 +186,21 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmDelete(final ListForm form) {
|
||||
return asHtml(path_AdminSearchlist_ConfirmDeleteJsp);
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final ListForm form) {
|
||||
return deleteByQuery(form);
|
||||
}
|
||||
|
||||
private HtmlResponse deleteByQuery(final ListForm form) {
|
||||
public HtmlResponse delete(final DeleteForm form) {
|
||||
validate(form, messages -> {}, () -> asHtml(path_AdminSearchlist_IndexJsp));
|
||||
final String docId = form.docId;
|
||||
if (jobHelper.isCrawlProcessRunning()) {
|
||||
// TODO Error
|
||||
throwValidationError(messages -> messages.addErrorsCannotDeleteDocBecauseOfRunning(GLOBAL), () -> asHtml(path_AdminSearchlist_IndexJsp));
|
||||
}
|
||||
final Thread thread = new Thread(() -> {
|
||||
if (!jobHelper.isCrawlProcessRunning()) {
|
||||
System.currentTimeMillis();
|
||||
try {
|
||||
final QueryBuilder query = QueryBuilders.termQuery(fieldHelper.docIdField, docId);
|
||||
fessEsClient.deleteByQuery(fieldHelper.docIndex, fieldHelper.docType, query);
|
||||
} catch (final Exception e) {
|
||||
// TODO Log
|
||||
}
|
||||
try {
|
||||
final QueryBuilder query = QueryBuilders.termQuery(fieldHelper.docIdField, docId);
|
||||
fessEsClient.deleteByQuery(fieldHelper.docIndex, fieldHelper.docType, query);
|
||||
saveInfo(messages -> messages.addSuccessDeleteSolrIndex(GLOBAL));
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> messages.addErrorsFailedToDeleteDocInAdmin(GLOBAL), () -> asHtml(path_AdminSearchlist_IndexJsp));
|
||||
}
|
||||
} );
|
||||
thread.start();
|
||||
saveInfo(messages -> messages.addSuccessDeleteSolrIndex(GLOBAL));
|
||||
return redirectWith(getClass(), moreUrl("search").params("query", form.query));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2012-2015 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.searchlist;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
public class DeleteForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String query;
|
||||
|
||||
@Required
|
||||
public String docId;
|
||||
|
||||
}
|
|
@ -53,12 +53,6 @@ public class ListForm implements SearchRequestParams, Serializable {
|
|||
|
||||
public String[] lang;
|
||||
|
||||
// @Required
|
||||
public String docId;
|
||||
|
||||
// @Required
|
||||
public String url;
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
return query;
|
||||
|
|
|
@ -324,6 +324,12 @@ public class FessMessages extends FessLabels {
|
|||
/** The key of the message: Invalid password. */
|
||||
public static final String ERRORS_password_does_not_exist_in_session = "{errors.password_does_not_exist_in_session}";
|
||||
|
||||
/** The key of the message: Crawler is running. The document cannot be deteled. */
|
||||
public static final String ERRORS_cannot_delete_doc_because_of_running = "{errors.cannot_delete_doc_because_of_running}";
|
||||
|
||||
/** The key of the message: Failed to delete document. */
|
||||
public static final String ERRORS_failed_to_delete_doc_in_admin = "{errors.failed_to_delete_doc_in_admin}";
|
||||
|
||||
/** The key of the message: The given query has unknown condition. */
|
||||
public static final String ERRORS_invalid_query_unknown = "{errors.invalid_query_unknown}";
|
||||
|
||||
|
@ -1924,6 +1930,34 @@ public class FessMessages extends FessLabels {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.cannot_delete_doc_because_of_running' with parameters.
|
||||
* <pre>
|
||||
* message: Crawler is running. The document cannot be deteled.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
*/
|
||||
public FessMessages addErrorsCannotDeleteDocBecauseOfRunning(String property) {
|
||||
assertPropertyNotNull(property);
|
||||
add(property, new ActionMessage(ERRORS_cannot_delete_doc_because_of_running));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.failed_to_delete_doc_in_admin' with parameters.
|
||||
* <pre>
|
||||
* message: Failed to delete document.
|
||||
* </pre>
|
||||
* @param property The property name for the message. (NotNull)
|
||||
* @return this. (NotNull)
|
||||
*/
|
||||
public FessMessages addErrorsFailedToDeleteDocInAdmin(String property) {
|
||||
assertPropertyNotNull(property);
|
||||
add(property, new ActionMessage(ERRORS_failed_to_delete_doc_in_admin));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the created action message for the key 'errors.invalid_query_unknown' with parameters.
|
||||
* <pre>
|
||||
|
|
|
@ -129,6 +129,8 @@ errors.failed_to_reload_core=Failed to reload core. Check log files.
|
|||
errors.blank_password=Password is required.
|
||||
errors.invalid_confirm_password=Confirm Password does not match.
|
||||
errors.password_does_not_exist_in_session=Invalid password.
|
||||
errors.cannot_delete_doc_because_of_running=Crawler is running. The document cannot be deteled.
|
||||
errors.failed_to_delete_doc_in_admin=Failed to delete document.
|
||||
|
||||
errors.invalid_query_unknown=The given query has unknown condition.
|
||||
errors.invalid_query_quoted=An invalid quote character is used.
|
||||
|
|
Loading…
Add table
Reference in a new issue