當前位置: 首頁>>代碼示例>>Java>>正文


Java RestStatus.CONFLICT屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:VersionConflictEngineException.java

示例2: restStatus

public RestStatus restStatus() {
    return failedShards() == 0 ? RestStatus.OK : RestStatus.CONFLICT;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:3,代碼來源:SyncedFlushResponse.java

示例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());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:59,代碼來源:TransportBaseSQLAction.java


注:本文中的org.elasticsearch.rest.RestStatus.CONFLICT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。