List of usage examples for com.mongodb BasicDBObject getString
public String getString(final String key)
From source file:com.linuxbox.enkive.workspace.searchResult.mongo.MongoSearchResult.java
License:Open Source License
@Override public void saveSearchResult() throws WorkspaceException { BasicDBObject searchResultObject = new BasicDBObject(); searchResultObject.put(SEARCHRESULTS, BasicDBObjectBuilder.start(getMessageIds()).get()); searchResultObject.put(SEARCHQUERYID, getSearchQueryId()); if (getId() != null && !getId().isEmpty()) { DBObject toUpdate = searchResultsColl.findOne(ObjectId.massageToObjectId(getId())); if (toUpdate != null) { searchResultsColl.update(toUpdate, searchResultObject); searchResultObject.put(UUID, toUpdate.get(UUID)); }//from w w w.j av a 2 s . c o m } if (searchResultObject.getString(UUID) == null) { searchResultsColl.insert(searchResultObject); setId(searchResultObject.getString(UUID)); } if (LOGGER.isInfoEnabled()) LOGGER.info("Saved Search Results - " + getId()); }
From source file:com.mobileman.kuravis.core.ws.treatment_review.TreatmentReviewController.java
License:Apache License
/** * @param body/* w ww . j a v a 2s . c o m*/ * @return entities data collection */ @RequestMapping(value = "/" + TreatmentReview.ENTITY_NAME + "/existsforuser", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody @RequiresAuthentication public ResponseEntity<DBObject> reviewExistsForUser(@RequestBody BasicDBObject body) { log.debug("reviewExistsForUser(" + body + ")"); String diseaseId = body.getString("diseaseId"); String treatmentId = body.getString("treatmentId"); String reviewId = treatmentReviewService.getReviewId(UserUtils.getLoggedUserId(), diseaseId, treatmentId); boolean exists = !StringUtils.isEmpty(reviewId); ResponseEntity<DBObject> response = new ResponseEntity<DBObject>( new BasicDBObject("exists", exists).append("reviewId", reviewId), HttpStatus.OK); log.debug("end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.InvitationController.java
License:Apache License
/** * User existence check/*from w w w . j a va 2s . c o m*/ * @param body * @return error message in case of error */ @RequestMapping(value = "/user/invitations/canberegistered", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody public ResponseEntity<DBObject> canBeRegistered(@RequestBody BasicDBObject body) { log.info("canBeRegistered(" + body + ") - start"); DBObject result = this.invitationService.inviteeData(body.getString("email")); ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, HttpStatus.OK); log.info("canBeRegistered(...) - end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * process sign-in//from w ww .j ava 2 s. c o m * @param body sign-in data * @return error message in case of error */ @RequestMapping(value = "/user/signin", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody public ResponseEntity<DBObject> signin(@RequestBody BasicDBObject body) { if (log.isDebugEnabled()) { log.debug("signin(" + body + ") - start"); } String userName = body.getString("login"); String password = body.getString("password"); String captcha_answer = body.getString("captcha_answer"); boolean rememberMe = body.getBoolean("rememberMe"); DBObject result = this.userService.signin(userName, password, captcha_answer, rememberMe); ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, new HttpHeaders(), ErrorUtils.getStatus(result)); if (log.isDebugEnabled()) { log.debug("return " + response); } return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * UC17 Forgot password - reset/*from w w w . j a v a 2 s . c om*/ * * @param body * @return result ok if password was successfuly recreated, error */ @RequestMapping(value = "/user/resetpassword", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody public ResponseEntity<DBObject> resetPassword(@RequestBody BasicDBObject body) { log.info("resetPassword(" + body + ") - start"); DBObject result = null; String email = body.getString("email"); if (StringUtils.isEmpty(email)) { result = ErrorUtils.error("Email unknown", ErrorCodes.UNKNOWN_EMAIL); } else { result = userService.resetCredentials(email); } ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, new HttpHeaders(), ErrorUtils.getStatus(result)); log.info("resetPassword(...) - end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * UC18 Change Password/*from w w w .j a v a 2 s. c o m*/ * * @param body * @return result ok if password was successfuly recreated, error */ @RequestMapping(value = "/user/changepassword", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody @RequiresAuthentication public ResponseEntity<DBObject> changePassword(@RequestBody BasicDBObject body) { log.info("changePassword(" + body + ") - start"); DBObject result = null; String password = body.getString("password"); String password2 = body.getString("password2"); if (StringUtils.isEmpty(password) || StringUtils.isEmpty(password2)) { result = ErrorUtils.error("Incorrect parameter", ErrorCodes.INCORRECT_PARAMETER); } else { result = userService.changePassword(password, password2); } ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, new HttpHeaders(), ErrorUtils.getStatus(result)); log.info("changePassword(...) - end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * UC1020 Email - update email/*ww w . j a va2s .c o m*/ * * @param body * @return result ok if password was successfuly recreated, error */ @RequestMapping(value = "/user/changeemail", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody @RequiresAuthentication public ResponseEntity<DBObject> updateEmail(@RequestBody BasicDBObject body) { log.info("updateEmail(" + body + ") - start"); DBObject result = null; String email = body.getString("email"); if (StringUtils.isEmpty(email)) { result = ErrorUtils.error("Incorrect parameter", ErrorCodes.INCORRECT_PARAMETER); } else { result = userService.updateEmail(email); } ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, ErrorUtils.getStatus(result)); log.info("updateEmail(...) - end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * UC18 Change Password/* w ww . ja va2 s . c om*/ * * @param body * @return result ok if password was successfuly recreated, error */ @RequestMapping(value = "/user/changeresetedpassword", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody public ResponseEntity<DBObject> changeResetedPassword(@RequestBody BasicDBObject body) { log.info("changeResetedPassword(" + body + ") - start"); String resetPasswordUuid = body.getString("resetPasswordUuid"); String password = body.getString("password"); DBObject result = userService.changeResetedPassword(resetPasswordUuid, password); ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(result, ErrorUtils.getStatus(result)); log.info("changeResetedPassword(...) - end: " + response); return response; }
From source file:com.mobileman.kuravis.core.ws.user.UserController.java
License:Apache License
/** * Feedback from the user on the page//from w ww .jav a 2s. c o m * * @param body * @return result ok if email was sent */ @RequestMapping(value = "/user/feedback", method = RequestMethod.POST, produces = { JsonUtil.MEDIA_TYPE_APPLICATION_JSON }) @ResponseBody public ResponseEntity<DBObject> userFeedback(@RequestBody BasicDBObject body) { log.info("resetPassword(" + body + ") - start"); String result = null; String userComment = body.getString("comment"); String email = body.getString("email"); result = userService.userFeedback(userComment, email); HttpStatus status = HttpStatus.OK; ResponseEntity<DBObject> response = new ResponseEntity<DBObject>(new BasicDBObject("result", result), new HttpHeaders(), status); log.info("resetPassword(...) - end: " + response); return response; }
From source file:com.mongodash.dao.mapper.SettingsDBObjectMapper.java
@Override public Settings mapDBObject(BasicDBObject object) { Settings settings = null;// ww w .j av a 2 s . c o m String _id = object.getString(Config.COMMON_FIELDS._id.name()); if (SETTINGS_KEY.email.name().equals(_id)) { settings = new EmailSettings(); if (object != null) { ((EmailSettings) settings).setEnabled(object.getBoolean("enabled")); ((EmailSettings) settings).setServer(object.getString("server")); ((EmailSettings) settings).setPort(object.getString("port")); ((EmailSettings) settings).setSender(object.getString("sender")); if (object.containsField("username") && object.containsField("password")) { ((EmailSettings) settings).setUsername(object.getString("username")); ((EmailSettings) settings).setPassword(PasswordUtil.decrypt(object.getString("password"))); } ((EmailSettings) settings).setSsl(object.getBoolean("ssl")); } } else if (SETTINGS_KEY.ldap.name().equals(_id)) { settings = new LdapSettings(); if (object != null) { ((LdapSettings) settings).setEnabled(object.getBoolean("enabled")); ((LdapSettings) settings).setHost(object.getString("host")); ((LdapSettings) settings).setPort(object.getString("port")); ((LdapSettings) settings).setAdminDn(object.getString("adminDn")); ((LdapSettings) settings).setAdminPassword(object.getString("adminPassword")); ((LdapSettings) settings).setBaseDn(object.getString("baseDn")); ((LdapSettings) settings).setLoginAttribute(object.getString("loginAttr")); ((LdapSettings) settings).setSecure(object.getBoolean("secure")); } } else if (SETTINGS_KEY.alerts.name().equals(_id)) { settings = new AlertSettings(); if (object != null) { ((AlertSettings) settings).setEnabled(object.getBoolean("enabled")); ((AlertSettings) settings).setEmailSubject(object.getString("emailSubject")); ((AlertSettings) settings).setEmailRecipients(object.getString("emailRecipients")); } } else if (SETTINGS_KEY.notifications.name().equals(_id)) { settings = new NotificationSettings(); if (object != null) { ((NotificationSettings) settings).setEnabled(object.getBoolean("enabled")); ((NotificationSettings) settings).setEmailEnabled(object.getBoolean("emailEnabled")); ((NotificationSettings) settings).setEmailSubject(object.getString("emailSubject")); ((NotificationSettings) settings).setEmailRecipients(object.getString("emailRecipients")); if (object.containsField("enabledNotifications")) { BasicDBList list = (BasicDBList) object.get("enabledNotifications"); List<String> enabledNotifications = new ArrayList<String>(); for (int i = 0; i < list.size(); i++) { enabledNotifications.add((String) list.get(i)); } ((NotificationSettings) settings).setEnabledNotifications(enabledNotifications); } } } else if (SETTINGS_KEY.licenseKey.name().equals(_id)) { settings = new LicenseKeySettings(); if (object != null) { ((LicenseKeySettings) settings).setPrivateKey(object.getString("privateKey")); ((LicenseKeySettings) settings).setPublicKey(object.getString("publicKey")); } } return settings; }