![JAR search and dependency download from the Maven repository](/logo.png)
org.codelibs.elasticsearch.configsync.rest.RestConfigSyncAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-configsync Show documentation
Show all versions of elasticsearch-configsync Show documentation
This plugin provides a feature to analyze texts.
The newest version!
/*
* Copyright 2012-2022 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.elasticsearch.configsync.rest;
import static org.elasticsearch.rest.RestStatus.OK;
import java.io.IOException;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
public abstract class RestConfigSyncAction extends BaseRestHandler {
protected Logger logger = LogManager.getLogger(getClass());
protected void sendResponse(final RestChannel channel, final Map params) {
try {
final XContentBuilder builder = JsonXContent.contentBuilder();
builder.startObject();
builder.field("acknowledged", true);
if (params != null) {
for (final Map.Entry entry : params.entrySet()) {
builder.field(entry.getKey(), entry.getValue());
}
}
builder.endObject();
channel.sendResponse(new RestResponse(OK, builder));
} catch (final IOException e) {
throw new ElasticsearchException("Failed to create a resposne.", e);
}
}
protected void sendErrorResponse(final RestChannel channel, final Exception e) {
try {
channel.sendResponse(new RestResponse(channel, e));
} catch (final Exception e1) {
logger.error("Failed to send a failure response.", e1);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy