本文整理汇总了Java中org.elasticsearch.rest.RestRequest.Method类的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于org.elasticsearch.rest.RestRequest包,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEsMethod
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
private Method getEsMethod(final String method) {
if ("get".equalsIgnoreCase(method)) {
return Method.GET;
} else if ("post".equalsIgnoreCase(method)) {
return Method.POST;
} else if ("put".equalsIgnoreCase(method)) {
return Method.PUT;
} else if ("delete".equalsIgnoreCase(method)) {
return Method.DELETE;
} else if ("options".equalsIgnoreCase(method)) {
return Method.OPTIONS;
} else if ("head".equalsIgnoreCase(method)) {
return Method.HEAD;
}
return null;
}
示例2: createMethods
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
private Method[] createMethods(final String[] methodValues) {
final List<Method> methodList = new ArrayList<Method>();
for (final String method : methodValues) {
if ("get".equalsIgnoreCase(method)) {
methodList.add(Method.GET);
} else if ("post".equalsIgnoreCase(method)) {
methodList.add(Method.POST);
} else if ("head".equalsIgnoreCase(method)) {
methodList.add(Method.HEAD);
} else if ("options".equalsIgnoreCase(method)) {
methodList.add(Method.OPTIONS);
} else if ("put".equalsIgnoreCase(method)) {
methodList.add(Method.PUT);
} else if ("delete".equalsIgnoreCase(method)) {
methodList.add(Method.DELETE);
}
}
return methodList.toArray(new Method[methodList.size()]);
}
示例3: testSetupRestHandlerContainsKnownBuiltin
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
public void testSetupRestHandlerContainsKnownBuiltin() {
SettingsModule settings = new SettingsModule(Settings.EMPTY);
ActionModule actionModule = new ActionModule(false, settings.getSettings(), new IndexNameExpressionResolver(Settings.EMPTY),
settings.getIndexScopedSettings(), settings.getClusterSettings(), settings.getSettingsFilter(), null, emptyList(), null,
null);
actionModule.initRestHandlers(null);
// At this point the easiest way to confirm that a handler is loaded is to try to register another one on top of it and to fail
Exception e = expectThrows(IllegalArgumentException.class, () ->
actionModule.getRestController().registerHandler(Method.GET, "/", null));
assertThat(e.getMessage(), startsWith("Path [/] already has a value [" + RestMainAction.class.getName()));
}
示例4: RocchioExpandRestAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public RocchioExpandRestAction(Settings settings, RestController controller) {
super(settings);
// Register your handlers here
controller.registerHandler(Method.GET, "/{index}/{type}/_expand", this);
controller.registerHandler(Method.GET, "/{index}/_expand", this);
}
示例5: generateLocalSearchRequest
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
private static SearchRequest generateLocalSearchRequest(String source, String indexName, String type) {
LocalRestRequest localRestRequest = new LocalRestRequest("/_search", Method.POST);
localRestRequest.setContent(source, null);
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices(Strings.splitStringByCommaToArray(indexName));
// get the content, and put it in the body
// add content/source as template if template flag is set
searchRequest.source(localRestRequest.content());
searchRequest.searchType(SearchType.QUERY_AND_FETCH);
searchRequest.extraSource(RestSearchAction.parseSearchSource(localRestRequest));
searchRequest.types(Strings.splitStringByCommaToArray(type));
searchRequest.putHeader("search_source", "reindex");
return searchRequest;
}
示例6: RestConsoleAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
public RestConsoleAction(Settings settings, RestController controller, ClusterSettings clusterSettings, SettingsFilter settingsFilter) {
super(settings);
// TODO Auto-generated constructor stub
controller.registerHandler(Method.GET, "/_console", this);
controller.registerHandler(Method.GET, "/_console/{action}", this);
String path = Common.getPathResources(settings);
this.getPath = path;
log(9, path);
}
示例7: HelloWorldHandler
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public HelloWorldHandler(Settings settings, RestController controller, Client client) {
super(settings, controller, client);
//将该Handler绑定到某访问路径
controller.registerHandler(Method.GET, "/hello/", this);
controller.registerHandler(Method.GET, "/hello/{name}", this);
}
示例8: AuditRestAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public AuditRestAction(final Settings settings, final Client client, final RestController controller) {
super(settings, controller, client);
controller.registerHandler(Method.GET, "/_cluster/_auditflush", this);
controller.registerHandler(Method.POST, "/_cluster/_auditflush", this);
}
示例9: isNtlmType1PostAuthorizationHeader
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
/**
* When using NTLM authentication and the browser is making a POST request, it preemptively sends a Type 2
* authentication message (without the POSTed data). The server responds with a 401, and the browser sends a Type 3
* request with the POSTed data. This is to avoid the situation where user's credentials might be potentially
* invalid, and all this data is being POSTed across the wire.
*
* @return True if request is an NTLM POST or PUT with an Authorization header and no data.
* @throws AuthException
*/
public boolean isNtlmType1PostAuthorizationHeader() throws AuthException {
if (this.request.method() != Method.POST && this.request.method() != Method.PUT) {
return false;
}
if (this.request.content() != null && this.request.content().length() > 0) {
return false;
}
return isNtlmType1Message() || isSPNegoMessage();
}
示例10: RestClearQRCacheAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public RestClearQRCacheAction(final Settings settings, final Client client,
final RestController controller,
final QueryResultCache queryResultCache) {
super(settings, controller, client);
this.queryResultCache = queryResultCache;
this.logger = Loggers.getLogger(
QueryResultCachePlugin.REST_LOGGER_NAME, settings);
controller.registerHandler(Method.POST, "/_qrc/clear", this);
controller.registerHandler(Method.POST, "/{index}/_qrc/clear", this);
}
示例11: RestStatsQRCacheAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public RestStatsQRCacheAction(final Settings settings, final Client client,
final RestController controller,
final QueryResultCache queryResultCache) {
super(settings, controller, client);
this.queryResultCache = queryResultCache;
this.logger = Loggers.getLogger(
QueryResultCachePlugin.REST_LOGGER_NAME, settings);
controller.registerHandler(Method.GET, "/_qrc/stats", this);
}
示例12: S3ManageAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
@Inject
public S3ManageAction(Settings settings, Client client, RestController controller){
super(settings, controller, client);
// Define S3 REST endpoints.
controller.registerHandler(Method.GET, "/_s3/{rivername}/{command}", this);
}
示例13: getRoles
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
public String[] getRoles(final Method method) {
final Set<String> roleSet = methodMap.get(method);
if (roleSet != null) {
return roleSet.toArray(new String[roleSet.size()]);
}
return new String[0];
}
示例14: addRoles
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
private void addRoles(final Method method, final String[] roles) {
synchronized (methodMap) {
Set<String> roleSet = methodMap.get(method);
if (roleSet == null) {
roleSet = new HashSet<String>();
methodMap.put(method, roleSet);
}
for (final String role : roles) {
roleSet.add(role);
}
}
}
示例15: RestListAlgorithmsAction
import org.elasticsearch.rest.RestRequest.Method; //导入依赖的package包/类
public RestListAlgorithmsAction(
Settings settings,
RestController controller) {
super(settings);
controller.registerHandler(Method.POST, "/" + NAME, this);
controller.registerHandler(Method.GET, "/" + NAME, this);
}