本文整理汇总了Java中org.bson.Document.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getBoolean方法的具体用法?Java Document.getBoolean怎么用?Java Document.getBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.getBoolean方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSyncNeeded
import org.bson.Document; //导入方法依赖的package包/类
private boolean isSyncNeeded(Document doc, BsonTimestamp oplogTs) {
syncFlg = doc.getBoolean(SyncConstants.SYNC_FLAG, false);
syncTime = doc.get(SyncConstants.SYNC_TIME);
boolean syncNeeded = false;
if (syncFlg) {
syncNeeded = true;
} else {
if (!isRestrictedSyncEnabled) {
if (syncTime != null) {
if (oplogTs.getTime() - (Long.valueOf(String.valueOf(syncTime)) / 1000) > SYNC_DIFF) {
syncNeeded = true;
}
} else {
syncNeeded = true;
}
}
}
return syncNeeded;
}
示例2: checkUserAdmin
import org.bson.Document; //导入方法依赖的package包/类
protected static ResponseEntity checkUserAdmin(SessionToken token, MongoCollection<Document> users, Document doc) {
// getString will throw an exception if the key is not present in the document
String loggedInUser = doc.getString("loggedInUser");
if(loggedInUser.equals("none")) {
// No user is logged in
throw new RuntimeException(); // Move to catch block
}
Document userDoc = users.find(Filters.eq("username", loggedInUser)).first();
if(userDoc == null) { // We can't find the logged in user in the users database, strange
NectarServerApplication.getLogger().warn("Failed to find logged in user \"" + loggedInUser + "\" for session "
+ token.getUuid() + " while processing user registration"
);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to find current logged in user in DB.");
} else { // User found, check admin now
if(!userDoc.getBoolean("admin", false)) {
NectarServerApplication.getLogger().warn("ATTEMPTED CLIENT REGISTRATION BY NON_ADMIN USER \"" + loggedInUser + "\""
+ " from session " + token.getUuid()
);
NectarServerApplication.getEventLog().addEntry(EventLog.EntryLevel.WARNING, "A non-admin user attempted to register a client from " + token.getUuid());
throw new RuntimeException(); // Move to catch block
}
// User is confirmed logged in and admin, all checks passed.
}
return null;
}
示例3: isRSVPEnabled
import org.bson.Document; //导入方法依赖的package包/类
public boolean isRSVPEnabled(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id",cId)).first();
if( settings == null )
{
return false;
}
return settings.getBoolean("rsvp_enabled", false);
}
示例4: isRSVPConfirmationsEnabled
import org.bson.Document; //导入方法依赖的package包/类
public boolean isRSVPConfirmationsEnabled(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id",cId)).first();
if( settings == null )
{
return false;
}
return settings.getBoolean("rsvp_confirmations", false);
}
示例5: isRSVPExclusive
import org.bson.Document; //导入方法依赖的package包/类
public boolean isRSVPExclusive(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id", cId)).first();
return settings == null || settings.getBoolean("rsvp_exclusivity", true);
}