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


Java Status.NOT_FOUND属性代码示例

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


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

示例1: _getDocument

/**
 * @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,代码行数:18,代码来源:ForestDBStore.java

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

示例3: deleteLocalDocument

private void deleteLocalDocument(String docID, String revID) throws CouchbaseLiteException {
    if (docID == null) {
        throw new CouchbaseLiteException(Status.BAD_REQUEST);
    }
    if (revID == null) {
        // Didn't specify a revision to delete: 404 or a 409, depending
        if (getLocalDocument(docID, null) != null) {
            throw new CouchbaseLiteException(Status.CONFLICT);
        } else {
            throw new CouchbaseLiteException(Status.NOT_FOUND);
        }
    }
    String[] whereArgs = {docID, revID};
    try {
        int rowsDeleted = storageEngine.delete("localdocs", "docid=? AND revid=?", whereArgs);
        if (rowsDeleted == 0) {
            if (getLocalDocument(docID, null) != null) {
                throw new CouchbaseLiteException(Status.CONFLICT);
            } else {
                throw new CouchbaseLiteException(Status.NOT_FOUND);
            }
        }
    } catch (SQLException e) {
        throw new CouchbaseLiteException(e, Status.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:26,代码来源:SQLiteStore.java

示例4: deleteLocalDocument

/**
 * CBLDatabase+LocalDocs.m
 * - (CBLStatus) deleteLocalDocumentWithID: (NSString*)docID
 * revisionID: (NSString*)revID
 * obeyMVCC: (BOOL)obeyMVCC;
 */
private Status deleteLocalDocument(
        final String inDocID, String inRevID, final boolean obeyMVCC) {
    final String docID = inDocID;
    final String revID = inRevID;

    if (docID == null || !docID.startsWith("_local/"))
        return new Status(Status.BAD_ID);
    if (obeyMVCC && revID == null)
        // Didn't specify a revision to delete: 404 or a 409, depending
        return new Status(getLocalDocument(docID, null) != null ?
                Status.CONFLICT : Status.NOT_FOUND);

    return inTransaction(new Task() {
        @Override
        public Status run() {
            try {
                byte[][] metaNbody = forest.rawGet("_local", docID);
                if (metaNbody == null) {
                    return new Status(Status.NOT_FOUND);
                } else if (obeyMVCC && revID != null &&
                        !revID.equals(new String(metaNbody[0]))) {
                    return new Status(Status.CONFLICT);
                } else {
                    forest.rawPut("_local", docID, null, null);
                    return new Status(Status.OK);
                }
            } catch (ForestException e) {
                return ForestBridge.err2status(e);
            }
        }
    });
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:38,代码来源:ForestDBStore.java

示例5: ForestDBViewStore

protected ForestDBViewStore(ForestDBStore dbStore, String name, boolean create)
        throws CouchbaseLiteException {
    this._dbStore = dbStore;
    this.name = name;
    this._path = new File(dbStore.directory, viewNameToFileName(name)).getPath();

    // Somewhat of a hack: There probably won't be a file at the exact _path because ForestDB
    // likes to append ".0" etc., but there will be a file with a ".meta" extension:
    File metaFile = new File(this._path + ".meta");
    if (!metaFile.exists()) {
        // migration: CBL Android/Java specific
        {
            // NOTE: .0, .1, etc is created by forestdb if auto compact is enabled.
            // renaming forestdb file name with .0 etc with different name could cause problem.
            // Following migration could work because forestdb filename is without .0 etc.
            // Once filename has .0 etc, do not rename file.

            // if old index file exists, rename it to new name
            File file = new File(this._path);
            File oldFile = new File(dbStore.directory, oldViewNameToFileName(name));
            if (oldFile.exists() && !oldFile.equals(file)) {
                if (oldFile.renameTo(file))
                    return;
                // if fail to rename, delete it and create new one from scratch.
                oldFile.delete();
            }
        }
        if (!create)
            throw new CouchbaseLiteException(Status.NOT_FOUND);
        try {
            openIndex(Database.Create, true);
        } catch (ForestException e) {
            throw new CouchbaseLiteException(e.code);
        }
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-java-forestdb,代码行数:36,代码来源:ForestDBViewStore.java

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

示例7: SQLiteViewStore

protected SQLiteViewStore(SQLiteStore store, String name, boolean create) throws CouchbaseLiteException {
    this.store = store;
    this.name = name;
    this.viewID = -1; // means 'unknown'
    this.collation = View.TDViewCollation.TDViewCollationUnicode;
    if (!create && getViewID() <= 0)
        throw new CouchbaseLiteException(Status.NOT_FOUND);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:8,代码来源:SQLiteViewStore.java

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

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

示例10: isDocumentError

public static boolean isDocumentError(int statusCode) {
    return (statusCode == Status.NOT_FOUND || statusCode == Status.FORBIDDEN || statusCode == Status.GONE) ? true : false;
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:3,代码来源:Utils.java

示例11: do_UNKNOWN

public Status do_UNKNOWN(Database db, String docID, String attachmentName) {
    return new Status(Status.NOT_FOUND);
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:3,代码来源:Router.java

示例12: compileView

private View compileView(String designDoc, String viewName) throws CouchbaseLiteException {
    // make sure only one view instance per same view.
    synchronized (db) {

        // First check if there's a CouchDB view definition we can compile:

        String tdViewName = String.format(Locale.ENGLISH, "%s/%s", designDoc, viewName);

        View view = db.getExistingView(tdViewName);

        // Get design document
        RevisionInternal rev = db.getDocument(String.format(Locale.ENGLISH, "_design/%s", designDoc), null, true);
        if (rev == null) {
            if (view != null)
                return view;
            throw new CouchbaseLiteException(Status.NOT_FOUND);
        }

        // get views
        Map<String, Object> views = (Map<String, Object>) rev.getProperties().get("views");
        if (views == null) {
            if (view != null)
                return view;
            throw new CouchbaseLiteException(Status.NOT_FOUND);
        }

        // get view
        Map<String, Object> viewProps = (Map<String, Object>) views.get(viewName);
        if (viewProps == null) {
            if (view != null)
                return view;
            throw new CouchbaseLiteException(Status.NOT_FOUND);
        }

        // calc view version of stored view definition
        String version = Misc.HexSHA1Digest(viewProps.toString().getBytes());

        // No View is compiled, or new map functions are stored in the document,
        // compile map/reduce function and assign it to the view.
        // NOTE: // https://github.com/couchbase/couchbase-lite-android/issues/1139
        if (view == null || view.getMapVersion() == null || !view.getMapVersion().equals(version)) {
            view = compileView(tdViewName, viewProps);
            if (view == null)
                throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
        }

        return view;
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-core,代码行数:49,代码来源:Router.java

示例13: loadRevisionBody

@Override
public RevisionInternal loadRevisionBody(RevisionInternal rev)
        throws CouchbaseLiteException {
    if (rev.getBody() != null && rev.getSequence() != 0) // no-op
        return rev;

    assert (rev.getDocID() != null && rev.getRevID() != null);

    // SQLite read operation
    long docNumericID = getDocNumericID(rev.getDocID());
    if (docNumericID <= 0)
        throw new CouchbaseLiteException(Status.NOT_FOUND);

    Cursor cursor = null;
    Status result = new Status(Status.NOT_FOUND);
    try {
        String sql = "SELECT sequence, json FROM revs WHERE doc_id=? AND revid=? LIMIT 1";
        String[] args = {String.valueOf(docNumericID), rev.getRevID()};
        cursor = storageEngine.rawQuery(sql, args);
        if (cursor.moveToNext()) {
            byte[] json = cursor.getBlob(1);
            if (json != null) {
                result.setCode(Status.OK);
                rev.setSequence(cursor.getLong(0));
                rev.setJSON(json);
            }
        }
    } catch (SQLException e) {
        Log.e(TAG, "Error loading revision body", e);
        throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    if (result.getCode() == Status.NOT_FOUND) {
        throw new CouchbaseLiteException(result);
    }

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


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