本文整理汇总了Java中org.bson.Document.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getString方法的具体用法?Java Document.getString怎么用?Java Document.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLiveUploadID
import org.bson.Document; //导入方法依赖的package包/类
/**
* Returns a string representation of uploadID in the config collection.
* Assumes there is only one liveUploadID in the config collection for any given time.
* @return a string representation of uploadID in the config collection
*/
public String getLiveUploadID() {
try
{
FindIterable<Document> findIterable = configCollection.find(exists("liveUploadID"));
Iterator<Document> iterator = findIterable.iterator();
Document doc = iterator.next();
return doc.getString("liveUploadID");
}
catch(Exception e)
{
e.printStackTrace();
System.err.println(" [hint] Database might be empty? Couldn't getLiveUploadID");
throw e;
}
}
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-dorfner-v2,代码行数:22,代码来源:PlantController.java
示例2: getDataLoader
import org.bson.Document; //导入方法依赖的package包/类
public O2MSyncDataLoader getDataLoader(ObjectId eventId) {
O2MSyncDataLoader loader = null;
Document document = syncEventDoc
.find(Filters.and(Filters.eq(SyncAttrs.ID, eventId))).first();
if (document != null && !document.isEmpty()) {
Object interval = document.get(SyncAttrs.INTERVAL);
String appName = document.getString(SyncAttrs.APPLICATION_NAME);
if(interval!=null && interval instanceof Long){
loader = new O2MSyncDataLoader((Long)interval , appName);
}else{
loader = new O2MSyncDataLoader(120000 , appName);
}
loader.setEventId(document.getObjectId(SyncAttrs.ID));
loader.setDbName(document.getString(SyncAttrs.SOURCE_DB_NAME));
loader.setDbUserName(document.getString(SyncAttrs.SOURCE_USER_NAME));
loader.setStatus(document.getString(SyncAttrs.STATUS));
}
return loader;
}
示例3: initTransformers
import org.bson.Document; //导入方法依赖的package包/类
private void initTransformers() {
for (Object transConfig : documentTransformersConfig) {
if (transConfig instanceof Document) {
Document transConfigDoc = (Document) transConfig;
String className = transConfigDoc.getString("className");
if (className != null) {
try {
Object transformer = Class.forName(className).newInstance();
if (transformer instanceof IDocumentTransformer) {
this.documentTransformers.add((IDocumentTransformer) transformer);
} else {
logger.warn("documentTransformer not instance of IDocumentTransformer, ignoring");
}
} catch (Exception e) {
logger.error("Error instantiating documentTransformer " + className, e);
System.exit(1);
}
}
} else {
logger.warn(
String.format("Invalid documentTransformers config, expected Document but was %s. Ignoring.",
transConfig.getClass().getName()));
}
}
}
示例4: getExpectedResultAsBooleanAssert
import org.bson.Document; //导入方法依赖的package包/类
/**
* Returns a string representing the boolean condition to put as assertTrue
* argument in junit if the method return type is not void, returns an empty
* string otherwise
*
* @param method
* @param methodOutput
* @return
*/
private String getExpectedResultAsBooleanAssert(Method method, Document methodOutput) {
StringBuilder toReturn = new StringBuilder();
// If method's return type is void methodOutput.returnValue should be
// null
if (!void.class.equals(method.getReturnType()) && methodOutput != null) {
String methodReturnValue = methodOutput.getString("returnValue");
Class<?> methodReturnType = method.getReturnType();
if (methodReturnType.isPrimitive()) {
toReturn.append("result == ").append(methodReturnValue);
} else {
toReturn.append("result.equals(")
.append(getValueWithApexIfRequired(methodReturnType, methodReturnValue)).append(")");
}
} else {
toReturn.append("true");
}
return toReturn.toString();
}
示例5: getRSVPClear
import org.bson.Document; //导入方法依赖的package包/类
public String getRSVPClear(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id",cId)).first();
if(settings == null)
{
return "";
}
String emoji = settings.getString("rsvp_clear");
if(emoji == null)
{
return "";
}
return emoji;
}
示例6: convert
import org.bson.Document; //导入方法依赖的package包/类
@Override
protected MongoSession convert(Document sessionWrapper) {
Object maxInterval = sessionWrapper.getOrDefault(MAX_INTERVAL, this.maxInactiveInterval);
Duration maxIntervalDuration = (maxInterval instanceof Duration)
? (Duration) maxInterval
: Duration.parse(maxInterval.toString());
MongoSession session = new MongoSession(
sessionWrapper.getString(ID), maxIntervalDuration.getSeconds());
Object creationTime = sessionWrapper.get(CREATION_TIME);
if (creationTime instanceof Instant) {
session.setCreationTime(((Instant) creationTime).toEpochMilli());
} else if (creationTime instanceof Date) {
session.setCreationTime(((Date) creationTime).getTime());
}
Object lastAccessedTime = sessionWrapper.get(LAST_ACCESSED_TIME);
if (lastAccessedTime instanceof Instant) {
session.setLastAccessedTime((Instant) lastAccessedTime);
} else if (lastAccessedTime instanceof Date) {
session.setLastAccessedTime(Instant.ofEpochMilli(((Date) lastAccessedTime).getTime()));
}
session.setExpireAt((Date) sessionWrapper.get(EXPIRE_AT_FIELD_NAME));
deserializeAttributes(sessionWrapper, session);
return session;
}
示例7: GuildSettings
import org.bson.Document; //导入方法依赖的package包/类
GuildSettings(Document guildDocument)
{
guildId = guildDocument.getString("_id");
commandPrefix = guildDocument.getString("prefix");
commandChannelId = guildDocument.get("command_channel") != null ? guildDocument.getString("command_channel") : null;
unrestrictedCommands = (ArrayList<String>) guildDocument.get("unrestricted_commands");
}
示例8: decodeMatchOperation
import org.bson.Document; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private MatchOperation decodeMatchOperation(Document document) {
String sqlOperation = document.getString(SyncAttrs.SQL_OPERATION);
MatchAble leftHandExpr = decodeExpression((Document) document.get(SyncAttrs.LEFT_HAND_EXPRESSION));
MatchAble rightHandExpr =null;
if(document.get(SyncAttrs.RIGHT_HAND_EXPRESSION)!=null){
rightHandExpr = decodeExpression((Document) document.get(SyncAttrs.RIGHT_HAND_EXPRESSION));
}
return OperationsFactory.getMatchExpression(leftHandExpr, rightHandExpr, sqlOperation);
}
示例9: decodeFilter
import org.bson.Document; //导入方法依赖的package包/类
private SQLFilters decodeFilter(List<Document> filterList) {
logger.debug("decodeFilter called " + filterList);
SQLFilters filters = new SQLFilters();
for (Document doc : filterList) {
String logicalOperator = doc.getString(SyncAttrs.LOGICAL_OPERATOR);
MatchOperation operation = decodeMatchOperation(doc);
filters.addOperation(operation, logicalOperator);
}
return filters;
}
示例10: user
import org.bson.Document; //导入方法依赖的package包/类
private User user(Document doc) {
return new User(
doc.get("_id").toString(),
doc.getString("name"),
doc.getString("email"),
doc.getString("password"));
}
示例11: decodeExpression
import org.bson.Document; //导入方法依赖的package包/类
private MatchAble decodeExpression(Document document) {
MatchAble matchAble = null;
String expressionType = document.getString(SyncAttrs.EXPRESSION_TYPE);
if (expressionType != null && !expressionType.isEmpty()) {
if (SyncAttrs.COLUMN.equalsIgnoreCase(expressionType)) {
Document columDataDoc = (Document) document.get(SyncAttrs.COLUMN_DATA);
matchAble = decodeColumn(columDataDoc);
} else {
matchAble = decodeLiteral(document);
}
}
return matchAble;
}
示例12: getEndAnnounceChan
import org.bson.Document; //导入方法依赖的package包/类
public String getEndAnnounceChan(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id",cId)).first();
if( settings == null )
{
return Main.getBotSettingsManager().getAnnounceChan();
}
String chan = settings.getString("announcement_channel_end");
if(chan == null)
{
return settings.getString("announcement_channel");
}
return chan;
}
示例13: getEndAnnounceFormat
import org.bson.Document; //导入方法依赖的package包/类
public String getEndAnnounceFormat(String cId)
{
Document settings = Main.getDBDriver().getScheduleCollection().find(eq("_id",cId)).first();
if( settings == null )
{
return Main.getBotSettingsManager().getAnnounceFormat();
}
String format = settings.getString("announcement_format_end");
if(format == null)
{
return settings.getString("announcement_format");
}
return format;
}
示例14: decode
import org.bson.Document; //导入方法依赖的package包/类
@Override
public SyncError decode(BsonReader reader, DecoderContext decoderContext) {
Document document = documentCodec.decode(reader, decoderContext);
SyncError error = new SyncError(document.getString(SyncAttrs.ERROR_MESSAGE));
error.setThreadName(document.getString(SyncAttrs.THREAD_NAME));
error.setFullStackTrace(document.getString(SyncAttrs.TRACE));
return error;
}
示例15: login
import org.bson.Document; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@RequestMapping(value = NectarServerApplication.ROOT_PATH + "/auth/login", method = RequestMethod.POST)
public ResponseEntity<String> login(@RequestParam(value = "token") String jwtRaw, @RequestParam(value = "user") String username,
@RequestParam(value = "password") String password, HttpServletRequest request) {
ResponseEntity r = Util.verifyJWT(jwtRaw, request);
if(r != null)
return r;
SessionToken token = SessionToken.fromJSON(Util.getJWTPayload(jwtRaw));
if(token == null)
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid TOKENTYPE.");
if(SessionController.getInstance().checkToken(token)) {
MongoCollection<Document> clients = NectarServerApplication.getDb().getCollection("clients");
MongoCollection<Document> users = NectarServerApplication.getDb().getCollection("users");
Document clientDoc = clients.find(Filters.eq("uuid", token.getUuid())).first();
if(clientDoc == null) {
NectarServerApplication.getLogger().warn("Failed to find Client Entry in database for " + token.getUuid());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to find entry in database for client.");
}
String loggedInUser;
try {
// getString will throw an exception if the key is not present in the document
loggedInUser = clientDoc.getString("loggedInUser");
if(loggedInUser.equals("none")) {
// No user is logged in
throw new RuntimeException(); // Move to catch block
}
NectarServerApplication.getLogger().warn("Attempted duplicate user login to already logged in client: " + token.getUuid());
return ResponseEntity.status(HttpStatus.CONFLICT).body("A User is already logged in under this client!");
} catch(Exception e) {
// No user is logged in
Document userDoc = users.find(Filters.eq("username", username)).first();
if(userDoc == null) {
// The user trying to log in does not exist
NectarServerApplication.getLogger().warn("Attempted user login for \"" + username + "\", from "
+ token.getUuid() + ", user not found in database."
);
NectarServerApplication.getEventLog().addEntry(EventLog.EntryLevel.WARNING, "Attempted user login from non-existent user " + username);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found in database!");
}
// Check their password
if(userDoc.getString("password").equals(Util.computeSHA512(password))) {
// Password check complete, now update the database with the state
clients.updateOne(Filters.eq("uuid", token.getUuid()),
new Document("$set", new Document("loggedInUser", username))
);
NectarServerApplication.getEventLog().logEntry(EventLog.EntryLevel.INFO, "User \"" + username + "\" logged in from " + token.getUuid() + ", traced from " + request.getRemoteAddr());
} else {
NectarServerApplication.getLogger().warn("ATTEMPTED LOGIN TO USER \"" + username + "\": incorrect password from " + token.getUuid() +", address: " + request.getRemoteAddr());
NectarServerApplication.getEventLog().addEntry(EventLog.EntryLevel.WARNING, "Failed login to user " + username + " from " + token.getUuid() + ", traced from " + request.getRemoteAddr());
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Password Incorrect!");
}
}
} else {
return ResponseEntity.status(HttpStatus.FORBIDDEN).body("Token expired/not valid.");
}
return ResponseEntity.status(HttpStatus.NO_CONTENT).body("Success.");
}