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


Java Status.OK属性代码示例

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


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

示例1: openDB

private Status openDB() {
    if (db == null) {
        return new Status(Status.INTERNAL_SERVER_ERROR);
    }
    if (!db.exists()) {
        return new Status(Status.NOT_FOUND);
    }

    try {
        db.open();
    } catch (CouchbaseLiteException e) {
        return e.getCBLStatus();
    }

    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:16,代码来源:Router.java

示例2: do_GET_Database

/**
 * DATABASE REQUESTS: *
 */

public Status do_GET_Database(Database _db, String _docID, String _attachmentName) {
    // http://wiki.apache.org/couchdb/HTTP_database_API#Database_Information
    Status status = openDB();
    if (!status.isSuccessful()) {
        return status;
    }
    // NOTE: all methods are read operation. not necessary to be synchronized
    int num_docs = db.getDocumentCount();
    long update_seq = db.getLastSequenceNumber();
    long instanceStartTimeMicroseconds = db.getStartTime() * 1000;
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("db_name", db.getName());
    result.put("db_uuid", db.publicUUID());
    result.put("doc_count", num_docs);
    result.put("update_seq", update_seq);
    result.put("disk_size", db.totalDataSize());
    result.put("instance_start_time", instanceStartTimeMicroseconds);

    connection.setResponseBody(new Body(result));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:25,代码来源:Router.java

示例3: do_POST_Document_all_docs

public Status do_POST_Document_all_docs(Database _db, String _docID, String _attachmentName)
        throws CouchbaseLiteException {
    QueryOptions options = new QueryOptions();
    if (!getQueryOptions(options)) {
        return new Status(Status.BAD_REQUEST);
    }

    Map<String, Object> body = getBodyAsDictionary();
    if (body == null) {
        return new Status(Status.BAD_REQUEST);
    }

    List<Object> keys = (List<Object>) body.get("keys");
    options.setKeys(keys);

    Map<String, Object> result = db.getAllDocs(options);
    if (result == null) {
        return new Status(Status.INTERNAL_SERVER_ERROR);
    } else {
        convertCBLQueryRowsToMaps(result);
    }
    connection.setResponseBody(new Body(result));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:24,代码来源:Router.java

示例4: do_POST_Document_compact

@SuppressWarnings("MethodMayBeStatic")
public Status do_POST_Document_compact(Database _db, String _docID, String _attachmentName) {
    Status status = new Status(Status.OK);
    try {
        // Make Database.compact() thread-safe
        _db.compact();
    } catch (CouchbaseLiteException e) {
        status = e.getCBLStatus();
    }

    if (status.getCode() < 300) {
        Status outStatus = new Status();
        outStatus.setCode(202);    // CouchDB returns 202 'cause it's an async operation
        return outStatus;
    } else {
        return status;
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:18,代码来源:Router.java

示例5: loadBodyOfRevisionObject

/**
 * in CBLForestBridge.m
 * + (BOOL) loadBodyOfRevisionObject: (CBL_MutableRevision*)rev
 * doc: (VersionedDocument&)doc
 */
public static Status loadBodyOfRevisionObject(RevisionInternal rev, Document doc) {
    try {
        rev.setSequence(doc.getSelectedSequence());
        doc.selectRevID(rev.getRevID(), true);
        rev.setJSON(doc.getSelectedBody());
        return new Status(Status.OK);
    } catch (ForestException ex) {
        rev.setMissing(true);
        return err2status(ex);
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:16,代码来源:ForestBridge.java

示例6: do_GETRoot

/**
 * SERVER REQUESTS: *
 */

public Status do_GETRoot(Database _db, String _docID, String _attachmentName) {
    Map<String, Object> info = new HashMap<String, Object>();
    info.put("CBLite", "Welcome");
    info.put("couchdb", "Welcome"); // for compatibility
    info.put("version", getVersionString());
    connection.setResponseBody(new Body(info));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:12,代码来源:Router.java

示例7: do_GET_session

public Status do_GET_session(Database _db, String _docID, String _attachmentName) {
    // Send back an "Admin Party"-like response
    Map<String, Object> session = new HashMap<String, Object>();
    Map<String, Object> userCtx = new HashMap<String, Object>();
    String[] roles = {"_admin"};
    session.put("ok", true);
    userCtx.put("name", null);
    userCtx.put("roles", roles);
    session.put("userCtx", userCtx);
    connection.setResponseBody(new Body(session));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:12,代码来源:Router.java

示例8: do_GET_uuids

public Status do_GET_uuids(Database _db, String _docID, String _attachmentName) {
    int count = Math.min(1000, getIntQuery("count", 1));
    List<String> uuids = new ArrayList<String>(count);
    for (int i = 0; i < count; i++) {
        uuids.add(Misc.CreateUUID());
    }
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("uuids", uuids);
    connection.setResponseBody(new Body(result));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:11,代码来源:Router.java

示例9: do_DELETE_Database

public Status do_DELETE_Database(Database _db, String _docID, String _attachmentName) {
    if (getQuery("rev") != null) {
        return new Status(Status.BAD_REQUEST);
        // CouchDB checks for this; probably meant to be a document deletion
    }
    try {
        db.delete();
    } catch (CouchbaseLiteException e) {
        Log.w(TAG, "Failed to delete database: do_DELETE_Database()", e);
        return e.getCBLStatus();
    }
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:13,代码来源:Router.java

示例10: do_GET_Document_all_docs

public Status do_GET_Document_all_docs(Database _db, String _docID, String _attachmentName)
        throws CouchbaseLiteException {
    QueryOptions options = new QueryOptions();
    if (!getQueryOptions(options)) {
        return new Status(Status.BAD_REQUEST);
    }
    Map<String, Object> result = db.getAllDocs(options);
    convertCBLQueryRowsToMaps(result);
    if (result == null) {
        return new Status(Status.INTERNAL_SERVER_ERROR);
    }
    connection.setResponseBody(new Body(result));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:14,代码来源:Router.java

示例11: do_GET_Attachment

public Status do_GET_Attachment(Database _db, String docID, String _attachmentName) {
    try {
        // http://wiki.apache.org/couchdb/HTTP_Document_API#GET
        EnumSet<TDContentOptions> options = getContentOptions();
        options.add(TDContentOptions.TDNoBody);
        String revID = getQuery("rev");  // often null
        RevisionInternal rev = db.getDocument(docID, revID, false);
        if (rev == null) {
            return new Status(Status.NOT_FOUND);
        }
        if (cacheWithEtag(rev.getRevID())) {
            return new Status(Status.NOT_MODIFIED);  // set ETag and check conditional GET
        }

        String acceptEncoding = connection.getRequestProperty("accept-encoding");
        // getAttachment is safe. this could be static method??
        AttachmentInternal attachment = db.getAttachment(rev, _attachmentName);
        if (attachment == null) {
            return new Status(Status.NOT_FOUND);
        }

        String type = attachment.getContentType();
        if (type != null) {
            connection.getResHeader().add("Content-Type", type);
        }
        if (acceptEncoding != null && acceptEncoding.contains("gzip") &&
                attachment.getEncoding() == AttachmentInternal.AttachmentEncoding.AttachmentEncodingGZIP) {
            connection.getResHeader().add("Content-Encoding", "gzip");
            connection.setResponseInputStream(attachment.getEncodedContentInputStream());
        } else {
            connection.setResponseInputStream(attachment.getContentInputStream());
        }
        dontOverwriteBody = true;
        return new Status(Status.OK);

    } catch (CouchbaseLiteException e) {
        return e.getCBLStatus();
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:39,代码来源:Router.java

示例12: setInfo

@Override
public long setInfo(String key, String info) {
    ContentValues args = new ContentValues();
    args.put("key", key);
    args.put("value", info);
    if (storageEngine.insertWithOnConflict("info", null, args,
            SQLiteStorageEngine.CONFLICT_REPLACE) == -1)
        return Status.DB_ERROR;
    else
        return Status.OK;
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:11,代码来源:SQLiteStore.java

示例13: _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

示例14: 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

示例15: do_GET_all_dbs

public Status do_GET_all_dbs(Database _db, String _docID, String _attachmentName) {
    List<String> dbs = manager.getAllDatabaseNames();
    connection.setResponseBody(new Body(dbs));
    return new Status(Status.OK);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:5,代码来源:Router.java


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