Guest User

Untitled

a guest
Dec 17th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. def issueOrderCreditRequest(locale: String, orderId: Int): Action[AnyContent] = Action { implicit request => {
  2. val requestPattern = request.attrs.get(Router.Attrs.HandlerDef)
  3. requestPattern.get.path
  4. request.path;
  5. Logger.info("Testing info")
  6. Logger.warn("Testing warn")
  7. Logger.debug("Testing debug")
  8. Logger.trace("Testing trace")
  9. val requestBody: JsValue = request.body.asJson.get;
  10. val pathVairableResult = super.validateRequestPathParams(Schemas.orderSchemaFilePath, Json.toJson(Map("orderId" -> orderId)))
  11. pathVairableResult.fold(
  12. invalid = { errors =>
  13. BadRequest(JsonHelper.convertToJson(JsonHelper.throwValidationException(errors))).as("application/json")
  14. },
  15. valid = { post => {
  16. val schemaResult = super.validateRequestBody(Schemas.orderSchemaFilePath, requestBody)
  17. schemaResult.fold(requestBodyErrors => {
  18. BadRequest(JsonHelper.convertToJson(JsonHelper.throwValidationException(requestBodyErrors))).as("application/json")
  19. },
  20. post => {})
  21. }
  22. })
  23. audit(request)
  24. val foo= JsonHelper.getJsonValue(requestBody, "foo").toInt;
  25. val bar = JsonHelper.getJsonValue(requestBody, "bar");
  26. val result = FOOBAR.GETFOOBAR(BAZ, locale);
  27. if (result == 0 || foo> result) {
  28.  
  29. BadRequest(JsonHelper.convertToJson("")).as("application/json")
  30. }
  31. //... somecode
  32. .
  33. .
  34. .
  35. Ok(JsonHelper.convertToJson("OK")).as("application/json")
Add Comment
Please, Sign In to add comment