本文整理汇总了Java中org.elasticsearch.rest.RestStatus.CONFLICT属性的典型用法代码示例。如果您正苦于以下问题:Java RestStatus.CONFLICT属性的具体用法?Java RestStatus.CONFLICT怎么用?Java RestStatus.CONFLICT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.elasticsearch.rest.RestStatus
的用法示例。
在下文中一共展示了RestStatus.CONFLICT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: status
@Override
public RestStatus status() {
return RestStatus.CONFLICT;
}
示例2: restStatus
public RestStatus restStatus() {
return failedShards() == 0 ? RestStatus.OK : RestStatus.CONFLICT;
}
示例3: buildSQLActionException
/**
* Create a {@link io.crate.action.sql.SQLActionException} out of a {@link java.lang.Throwable}.
* If concrete {@link org.elasticsearch.ElasticsearchException} is found, first transform it
* to a {@link io.crate.exceptions.CrateException}
*/
private SQLActionException buildSQLActionException(Throwable e) {
logger.error("errors while processing sql", e);
if (e instanceof SQLActionException) {
return (SQLActionException) e;
}
e = esToCrateException(e);
int errorCode = 5000;
RestStatus restStatus = RestStatus.INTERNAL_SERVER_ERROR;
if (e instanceof CrateException) {
CrateException crateException = (CrateException) e;
if (e instanceof ValidationException) {
errorCode = 4000 + crateException.errorCode();
restStatus = RestStatus.BAD_REQUEST;
} else if (e instanceof NoPermissionException) {
errorCode = 4000 + crateException.errorCode();
restStatus = RestStatus.UNAUTHORIZED;
e.setStackTrace(new StackTraceElement[0]);
} else if (e instanceof ForbiddenException) {
errorCode = 4030 + crateException.errorCode();
restStatus = RestStatus.FORBIDDEN;
} else if (e instanceof ResourceUnknownException) {
errorCode = 4040 + crateException.errorCode();
restStatus = RestStatus.NOT_FOUND;
} else if (e instanceof ConflictException) {
errorCode = 4090 + crateException.errorCode();
restStatus = RestStatus.CONFLICT;
} else if (e instanceof UnhandledServerException) {
errorCode = 5000 + crateException.errorCode();
}
} else if (e instanceof ParsingException) {
errorCode = 4000;
restStatus = RestStatus.BAD_REQUEST;
} else if (e instanceof MapperParsingException) {
errorCode = 4000;
restStatus = RestStatus.BAD_REQUEST;
}
String message = e.getMessage();
if (message == null) {
if (e instanceof CrateException && e.getCause() != null) {
e = e.getCause(); // use cause because it contains a more meaningful error in most cases
}
StackTraceElement[] stackTraceElements = e.getStackTrace();
if (stackTraceElements.length > 0) {
message = String.format(Locale.ENGLISH, "%s in %s", e.getClass().getSimpleName(), stackTraceElements[0]);
} else {
message = "Error in " + e.getClass().getSimpleName();
}
} else {
message = e.getClass().getSimpleName() + ": " + message;
}
return new SQLActionException(message, errorCode, restStatus, e.getStackTrace());
}