本文整理汇总了Java中com.couchbase.lite.Status.INTERNAL_SERVER_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Status.INTERNAL_SERVER_ERROR属性的具体用法?Java Status.INTERNAL_SERVER_ERROR怎么用?Java Status.INTERNAL_SERVER_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.couchbase.lite.Status
的用法示例。
在下文中一共展示了Status.INTERNAL_SERVER_ERROR属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
示例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);
}
}
示例4: dbClosing
private void dbClosing() {
Log.d(TAG, "Database closing! Returning error 500");
Status status = new Status(Status.INTERNAL_SERVER_ERROR);
status = sendResponseHeaders(status);
connection.setResponseCode(status.getCode());
setResponse();
sendResponse();
}
示例5: 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);
}
示例6: createStorageEngine
private SQLiteStorageEngine createStorageEngine() throws CouchbaseLiteException {
SQLiteStorageEngineFactory factory =
manager.getContext().getSQLiteStorageEngineFactory();
SQLiteStorageEngine engine = factory.createStorageEngine();
if (engine == null) {
String message = "Unable to create a storage engine, fatal error";
Log.e(TAG, message);
throw new CouchbaseLiteException(message, Status.INTERNAL_SERVER_ERROR);
}
return engine;
}
示例7: winningRevIDOfDocNumericID
/**
* Returns the rev ID of the 'winning' revision of this document, and whether it's deleted.
* <p/>
* in CBLDatabase+Internal.m
* - (NSString*) winningRevIDOfDocNumericID: (SInt64)docNumericID
* isDeleted: (BOOL*)outIsDeleted
* isConflict: (BOOL*)outIsConflict // optional
* status: (CBLStatus*)outStatus
*/
protected String winningRevIDOfDocNumericID(long docNumericId,
AtomicBoolean outIsDeleted,
AtomicBoolean outIsConflict) // optional
throws CouchbaseLiteException {
assert (docNumericId > 0);
Cursor cursor = null;
String sql = "SELECT revid, deleted FROM revs" +
" WHERE doc_id=? and current=1" +
" ORDER BY deleted asc, revid desc LIMIT ?";
long limit = outIsConflict != null ? 2 : 1;
String[] args = {Long.toString(docNumericId), Long.toString(limit)};
String revID = null;
try {
cursor = storageEngine.rawQuery(sql, args);
if (cursor.moveToNext()) {
revID = cursor.getString(0);
outIsDeleted.set(cursor.getInt(1) > 0);
// The document is in conflict if there are two+ result rows that are not deletions.
if (outIsConflict != null)
outIsConflict.set(!outIsDeleted.get() && cursor.moveToNext() && !(cursor.getInt(1) > 0));
} else {
outIsDeleted.set(false);
if (outIsConflict != null)
outIsConflict.set(false);
}
} catch (SQLException e) {
Log.e(TAG, "Error", e);
throw new CouchbaseLiteException("Error", e, new Status(Status.INTERNAL_SERVER_ERROR));
} finally {
if (cursor != null) {
cursor.close();
}
}
return revID;
}
示例8: 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;
}
}
示例9: 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;
}