当前位置: 首页>>代码示例>>Java>>正文


Java Status.UNAUTHORIZED属性代码示例

本文整理汇总了Java中com.couchbase.lite.Status.UNAUTHORIZED属性的典型用法代码示例。如果您正苦于以下问题:Java Status.UNAUTHORIZED属性的具体用法?Java Status.UNAUTHORIZED怎么用?Java Status.UNAUTHORIZED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.couchbase.lite.Status的用法示例。


在下文中一共展示了Status.UNAUTHORIZED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

@Override
public void open() throws CouchbaseLiteException {
    // Flag:
    int flags = readOnly ? Database.ReadOnly : Database.Create;
    if (autoCompact)
        flags |= Database.AutoCompact;

    // Encryption:
    int enAlgorithm = Database.NoEncryption;
    byte[] enKey = null;
    if (encryptionKey != null) {
        enAlgorithm = Database.AES256Encryption;
        enKey = encryptionKey.getKey();
    }

    try {
        forest = new Database(forestPath, flags, enAlgorithm, enKey);
    } catch (ForestException e) {
        Log.e(TAG, "Failed to open the forestdb: domain=%d, error=%d", e.domain, e.code, e);
        if (e.domain == ForestDBDomain &&
                (e.code == FDBErrors.FDB_RESULT_NO_DB_HEADERS ||
                        e.code == FDBErrors.FDB_RESULT_CRYPTO_ERROR)) {
            throw new CouchbaseLiteException("Cannot create database", e, Status.UNAUTHORIZED);
        }
        throw new CouchbaseLiteException("Cannot create database", e, Status.DB_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:27,代码来源:ForestDBStore.java

示例2: _err2status

/**
 * in CBLForestBridge.m
 * CBLStatus err2status(C4Error c4err)
 */
public static int _err2status(ForestException ex) {
    if (ex == null || ex.code == 0)
        return Status.OK;

    Log.d(TAG, "[_err2status()] ForestException: domain=%d, code=%d", ex, ex.domain, ex.code);

    switch (ex.domain) {
        case C4ErrorDomain.HTTPDomain:
            return ex.code;
        case C4ErrorDomain.POSIXDomain:
            break;
        case C4ErrorDomain.ForestDBDomain:
            switch (ex.code) {
                case FDBErrors.FDB_RESULT_SUCCESS:
                    return Status.OK;
                case FDBErrors.FDB_RESULT_KEY_NOT_FOUND:
                case FDBErrors.FDB_RESULT_NO_SUCH_FILE:
                    return Status.NOT_FOUND;
                case FDBErrors.FDB_RESULT_RONLY_VIOLATION:
                    return Status.FORBIDDEN;
                case FDBErrors.FDB_RESULT_NO_DB_HEADERS:
                case FDBErrors.FDB_RESULT_CRYPTO_ERROR:
                    return Status.UNAUTHORIZED;
                case FDBErrors.FDB_RESULT_CHECKSUM_ERROR:
                case FDBErrors.FDB_RESULT_FILE_CORRUPTION:
                    return Status.CORRUPT_ERROR;
            }
            break;
        case C4ErrorDomain.C4Domain:
            switch (ex.code) {
                case C4DomainErrorCode.kC4ErrorCorruptRevisionData:
                case C4DomainErrorCode.kC4ErrorCorruptIndexData:
                    return Status.CORRUPT_ERROR;
                case C4DomainErrorCode.kC4ErrorBadRevisionID:
                    return Status.BAD_ID;
                case C4DomainErrorCode.kC4ErrorAssertionFailed:
                    break;
                default:
                    break;
            }
            break;
    }
    return Status.DB_ERROR;
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:48,代码来源:ForestBridge.java

示例3: statusFromBulkDocsResponseItem

@InterfaceAudience.Private
protected static Status statusFromBulkDocsResponseItem(Map<String, Object> item) {

    try {
        if (!item.containsKey("error")) {
            return new Status(Status.OK);
        }
        String errorStr = (String) item.get("error");
        if (errorStr == null || errorStr.isEmpty()) {
            return new Status(Status.OK);
        }

        // 'status' property is nonstandard; Couchbase Lite returns it, others don't.
        Object objStatus = item.get("status");
        if (objStatus instanceof Integer) {
            int status = ((Integer) objStatus).intValue();
            if (status >= 400) {
                return new Status(status);
            }
        }
        // If no 'status' present, interpret magic hardcoded CouchDB error strings:
        if ("unauthorized".equalsIgnoreCase(errorStr)) {
            return new Status(Status.UNAUTHORIZED);
        } else if ("forbidden".equalsIgnoreCase(errorStr)) {
            return new Status(Status.FORBIDDEN);
        } else if ("conflict".equalsIgnoreCase(errorStr)) {
            return new Status(Status.CONFLICT);
        } else if ("missing".equalsIgnoreCase(errorStr)) {
            return new Status(Status.NOT_FOUND);
        } else if ("not_found".equalsIgnoreCase(errorStr)) {
            return new Status(Status.NOT_FOUND);
        } else {
            return new Status(Status.UPSTREAM_ERROR);
        }

    } catch (Exception e) {
        Log.e(Database.TAG, "Exception getting status from " + item, e);
    }
    return new Status(Status.OK);


}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:42,代码来源:ReplicationInternal.java


注:本文中的com.couchbase.lite.Status.UNAUTHORIZED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。