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


Java Status类代码示例

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


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

示例1: revisionObject

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * in CBLForestBridge.m
 * + (CBL_MutableRevision*) revisionObjectFromForestDoc: (VersionedDocument&)doc
 * revID: (NSString*)revID
 * withBody: (BOOL)withBody
 */
public static RevisionInternal revisionObject(
        Document doc,
        String docID,
        String revID,
        boolean withBody) {

    boolean deleted = doc.selectedRevDeleted();
    if (revID == null)
        revID = doc.getSelectedRevID();
    RevisionInternal rev = new RevisionInternal(docID, revID, deleted);
    rev.setSequence(doc.getSelectedSequence());
    if (withBody) {
        Status status = loadBodyOfRevisionObject(rev, doc);
        if (status.isError() && status.getCode() != Status.GONE)
            return null;
    }
    return rev;
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:25,代码来源:ForestBridge.java

示例2: getDocument

import com.couchbase.lite.Status; //导入依赖的package包/类
@Override
public RevisionInternal getDocument(String docID, String inRevID, boolean withBody, Status outStatus) {
    Document doc = getDocument(docID);
    if (doc == null)
        return null;
    try {
        Status res = selectRev(doc, inRevID, withBody);
        outStatus.setCode(res.getCode());
        if (outStatus.isError() && outStatus.getCode() != Status.GONE)
            return null;
        if (inRevID == null && doc.selectedRevDeleted()) {
            outStatus.setCode(Status.DELETED);
            return null;
        }
        return ForestBridge.revisionObject(doc, docID, inRevID, withBody);
    } finally {
        doc.free();
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:20,代码来源:ForestDBStore.java

示例3: _getDocument

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * @note return value should not be null.
 */
private Document _getDocument(String docID) throws CouchbaseLiteException {
    Document doc;
    try {
        doc = forest.getDocument(docID, true);
    } catch (ForestException e) {
        Log.d(TAG, "ForestDB Warning: getDocument(docID, true) docID=[%s] error=[%s]",
                docID, e.toString());
        throw new CouchbaseLiteException(ForestBridge.err2status(e));
    }
    if (!doc.exists()) {
        doc.free();
        throw new CouchbaseLiteException(Status.NOT_FOUND);
    }
    return doc;
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:19,代码来源:ForestDBStore.java

示例4: getParentRevision

import com.couchbase.lite.Status; //导入依赖的package包/类
@Override
public RevisionInternal getParentRevision(RevisionInternal rev) {
    if (rev.getDocID() == null || rev.getRevID() == null)
        return null;
    Document doc = getDocument(rev.getDocID());
    if (doc == null)
        return null;
    try {
        Status status = selectRev(doc, rev.getRevID(), true);
        if (status.isError())
            return null;
        if (!doc.selectParentRev())
            return null;
        return ForestBridge.revisionObject(doc, rev.getDocID(), null, true);
    } finally {
        doc.free();
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:19,代码来源:ForestDBStore.java

示例5: inTransaction

import com.couchbase.lite.Status; //导入依赖的package包/类
private Status inTransaction(Task task) {
    if (inTransaction())
        return task.run();
    else {
        if (!beginTransaction())
            return new Status(Status.DB_ERROR);
        boolean commit = false;
        try {
            Status status = task.run();
            commit = !status.isError();
            return status;
        } finally {
            if (!endTransaction(commit))
                return new Status(Status.DB_ERROR);
        }
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:18,代码来源:ForestDBStore.java

示例6: refreshRemoteCheckpointDoc

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * Variant of -fetchRemoveCheckpointDoc that's used while replication is running, to reload the
 * checkpoint to get its current revision number, if there was an error saving it.
 */
@InterfaceAudience.Private
private void refreshRemoteCheckpointDoc() {
    Log.i(Log.TAG_SYNC, "%s: Refreshing remote checkpoint to get its _rev...", this);
    Future future = sendAsyncRequest("GET", "_local/" + remoteCheckpointDocID(), null, new RemoteRequestCompletion() {
        @Override
        public void onCompletion(RemoteRequest remoteRequest, Response httpResponse, Object result, Throwable e) {
            if (db == null) {
                Log.w(Log.TAG_SYNC, "%s: db == null while refreshing remote checkpoint.  aborting", this);
                return;
            }
            if (e != null && Utils.getStatusFromError(e) != Status.NOT_FOUND) {
                Log.e(Log.TAG_SYNC, "%s: Error refreshing remote checkpoint", e, this);
            } else {
                Log.d(Log.TAG_SYNC, "%s: Refreshed remote checkpoint: %s", this, result);
                remoteCheckpoint = (Map<String, Object>) result;
                lastSequenceChanged = true;
                saveLastSequence();  // try saving again
            }
        }
    });
    pendingFutures.add(future);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:27,代码来源:ReplicationInternal.java

示例7: uploadJsonRevision

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * Fallback to upload a revision if uploadMultipartRevision failed due to the server's rejecting
 * multipart format.
 * - (void) uploadJSONRevision: (CBL_Revision*)originalRev in CBLRestPusher.m
 */
private void uploadJsonRevision(final RevisionInternal rev) {
    // Get the revision's properties:
    if (!db.inlineFollowingAttachmentsIn(rev)) {
        setError(new CouchbaseLiteException(Status.BAD_ATTACHMENT));
        return;
    }

    final String path = String.format(Locale.ENGLISH, "%s?new_edits=false", encodeDocumentId(rev.getDocID()));
    CustomFuture future = sendAsyncRequest("PUT",
            path,
            rev.getProperties(),
            new RemoteRequestCompletion() {
                public void onCompletion(RemoteRequest remoteRequest, Response httpResponse, Object result, Throwable e) {
                    if (e != null) {
                        setError(e);
                    } else {
                        Log.v(TAG, "%s: Sent %s (JSON), response=%s", this, rev, result);
                        removePending(rev);
                    }
                }
            });
    future.setQueue(pendingFutures);
    pendingFutures.add(future);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:30,代码来源:PusherInternal.java

示例8: getBodyAsDictionary

import com.couchbase.lite.Status; //导入依赖的package包/类
private Map<String, Object> getBodyAsDictionary() throws CouchbaseLiteException {
    // check if content-type is `application/json`
    String contentType = getRequestHeaderContentType();
    if (contentType != null && !contentType.equals(CONTENT_TYPE_JSON))
        throw new CouchbaseLiteException(Status.NOT_ACCEPTABLE);

    // parse body text
    // NOTE: contentStream should not be close immediately. It will close Socket connection.
    InputStream contentStream = connection.getRequestInputStream();
    try {
        return Manager.getObjectMapper().readValue(contentStream, Map.class);
    } catch (JsonParseException jpe) {
        throw new CouchbaseLiteException(Status.BAD_JSON);
    } catch (JsonMappingException jme) {
        throw new CouchbaseLiteException(Status.BAD_JSON);
    } catch (IOException ioe) {
        throw new CouchbaseLiteException(Status.REQUEST_TIMEOUT);
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:20,代码来源:Router.java

示例9: openDB

import com.couchbase.lite.Status; //导入依赖的package包/类
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,代码行数:17,代码来源:Router.java

示例10: do_GET_Database

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * 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,代码行数:26,代码来源:Router.java

示例11: do_POST_Document_all_docs

import com.couchbase.lite.Status; //导入依赖的package包/类
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,代码行数:25,代码来源:Router.java

示例12: do_POST_Document_compact

import com.couchbase.lite.Status; //导入依赖的package包/类
@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,代码行数:19,代码来源:Router.java

示例13: do_POST_Document_changes

import com.couchbase.lite.Status; //导入依赖的package包/类
public Status do_POST_Document_changes(Database _db, String docID, String _attachmentName) {
    // Merge the properties from the JSON request body into the URL queries.
    // Note that values in _queries have to be NSStrings or the parsing code will break!
    Map<String, Object> body;
    try {
        body = getBodyAsDictionary();
    } catch (CouchbaseLiteException e) {
        return e.getCBLStatus();
    }
    Iterator<String> keys = body.keySet().iterator();
    while (keys.hasNext()) {
        if (getQueries() == null)
            this.queries = new HashMap<String, String>();
        String key = keys.next();
        Object value = body.get(key);
        if (key != null && value != null)
            getQueries().put(key, value.toString());
    }

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

示例14: derivePBKDF2SHA256Key

import com.couchbase.lite.Status; //导入依赖的package包/类
@Override
public byte[] derivePBKDF2SHA256Key(String password, byte[] salt, int rounds)
        throws CouchbaseLiteException {
    if (storageEngine == null)
        storageEngine = createStorageEngine();

    if (!storageEngine.supportEncryption()) {
        Log.w(TAG, "SQLiteStore: encryption not available (app not built with SQLCipher)");
        throw new CouchbaseLiteException("Encryption not available",
                Status.NOT_IMPLEMENTED);
    }

    byte[] result = storageEngine.derivePBKDF2SHA256Key(password, salt, rounds);
    if (result == null)
        throw new CouchbaseLiteException("Cannot derive key for the password",
                Status.BAD_REQUEST);
    return result;
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:19,代码来源:SQLiteStore.java

示例15: putLocalRevisionNoMVCC

import com.couchbase.lite.Status; //导入依赖的package包/类
/**
 * - (CBL_Revision*) putLocalRevisionNoMVCC: (CBL_Revision*)revision
 * status: (CBLStatus*)outStatus
 */
protected RevisionInternal putLocalRevisionNoMVCC(final RevisionInternal revision)
        throws CouchbaseLiteException {
    RevisionInternal result = null;
    boolean commit = false;

    if (!beginTransaction())
        throw new CouchbaseLiteException("Error in beginTransaction()", Status.DB_ERROR);

    try {
        RevisionInternal prevRev = getLocalDocument(revision.getDocID(), null);
        result = putLocalRevision(revision, prevRev == null ? null : prevRev.getRevID(), true);
        commit = true;
    } finally {
        if (!endTransaction(commit))
            throw new CouchbaseLiteException("Error in endTransaction()", Status.DB_ERROR);
    }
    return result;
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:23,代码来源:SQLiteStore.java


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