本文整理汇总了Java中com.couchbase.lite.CouchbaseLiteException.getCBLStatus方法的典型用法代码示例。如果您正苦于以下问题:Java CouchbaseLiteException.getCBLStatus方法的具体用法?Java CouchbaseLiteException.getCBLStatus怎么用?Java CouchbaseLiteException.getCBLStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.lite.CouchbaseLiteException
的用法示例。
在下文中一共展示了CouchbaseLiteException.getCBLStatus方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openDB
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的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);
}
示例2: do_POST_Document_compact
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的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;
}
}
示例3: do_POST_Document_changes
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的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);
}
示例4: do_PUT_Database
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的package包/类
public Status do_PUT_Database(Database _db, String _docID, String _attachmentName) {
if (db.exists()) {
return new Status(Status.DUPLICATE);
}
try {
// note: synchronized
db.open();
} catch (CouchbaseLiteException e) {
return e.getCBLStatus();
}
setResponseLocation(connection.getURL());
return new Status(Status.CREATED);
}
示例5: do_DELETE_Database
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的package包/类
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);
}
示例6: do_POST_Database
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的package包/类
public Status do_POST_Database(Database _db, String _docID, String _attachmentName) {
Status status = openDB();
if (!status.isSuccessful()) {
return status;
}
Map<String, Object> body;
try {
body = getBodyAsDictionary();
} catch (CouchbaseLiteException e) {
return e.getCBLStatus();
}
return update(db, null, new Body(body), false);
}
示例7: do_GET_Attachment
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的package包/类
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();
}
}
示例8: queryDesignDoc
import com.couchbase.lite.CouchbaseLiteException; //导入方法依赖的package包/类
private Status queryDesignDoc(String designDoc, String viewName, List<Object> keys)
throws CouchbaseLiteException {
View view;
try {
// return value should not be null.
view = compileView(designDoc, viewName);
} catch (CouchbaseLiteException e) {
return e.getCBLStatus();
}
long lastSequenceIndexed;
// according to functional test, view updateIndex() and query should be in sequence.
synchronized (view) {
// updateIndex() uses transaction internally, not necessary to apply syncrhonized.
view.updateIndex();
lastSequenceIndexed = view.getLastSequenceIndexed();
}
QueryOptions options = new QueryOptions();
//if the view contains a reduce block, it should default to reduce=true
if (view.getReduce() != null)
options.setReduce(true);
if (!getQueryOptions(options))
return new Status(Status.BAD_REQUEST);
if (keys != null)
options.setKeys(keys);
// Check for conditional GET and set response Etag header:
if (keys == null) {
long eTag = options.isIncludeDocs() ? db.getLastSequenceNumber() : lastSequenceIndexed;
if (cacheWithEtag(String.format(Locale.ENGLISH, "%d", eTag))) {
return new Status(Status.NOT_MODIFIED);
}
}
// convert from QueryRow -> Map
List<QueryRow> queryRows = view.query(options);
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
for (QueryRow queryRow : queryRows) {
rows.add(queryRow.asJSONDictionary());
}
Map<String, Object> responseBody = new HashMap<String, Object>();
responseBody.put("rows", rows);
responseBody.put("total_rows", view.getCurrentTotalRows());
responseBody.put("offset", options.getSkip());
if (options.isUpdateSeq()) {
responseBody.put("update_seq", lastSequenceIndexed);
}
connection.setResponseBody(new Body(responseBody));
return new Status(Status.OK);
}