From f7e74048dae9dd4e4226a67d5464c6c49c5b9607 Mon Sep 17 00:00:00 2001 From: ayybeeshafi Date: Wed, 13 Mar 2019 22:23:26 +0100 Subject: [PATCH] Implementation of refreshToken refs #128 --- .../InstanceRegistryController.scala | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/app/controllers/InstanceRegistryController.scala b/app/controllers/InstanceRegistryController.scala index 9383ccac..452fe6d0 100644 --- a/app/controllers/InstanceRegistryController.scala +++ b/app/controllers/InstanceRegistryController.scala @@ -65,7 +65,6 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma //val token = request.headers.get(HeaderNames.AUTHORIZATION) - /** This method maps list of instances with specific componentType. * * @param componentType @@ -149,7 +148,8 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma } /** - * This method is called to assign a new instance to the instance with specified ID. + * This method is called to assign a new instance to the instance with specified ID. + * * @param from * @param to * @return @@ -226,36 +226,38 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma new Status(response.status) } } - }.getOrElse{ Future(BadRequest("Invalid body"))} + }.getOrElse { + Future(BadRequest("Invalid body")) + } - } + } /** * This function is used to add a label to specific instance. + * * @param instanceID ID of the instance on which label is to be added * @param label * @return */ - def labelInstance(instanceID: String, label: String): Action[AnyContent] = authAction.async - { + def labelInstance(instanceID: String, label: String): Action[AnyContent] = authAction.async { request => - ws.url(instanceRegistryUri + "/instances/" + instanceID + "/label") - .withHttpHeaders(("Authorization", s"Bearer ${AuthProvider.generateJwt()}")) - .post(Json.obj("Label" -> label)) - .map { response => - response.status match { - // scalastyle:off magic.number - case 202 => - // scalastyle:on magic.number - Ok(response.body) - case x: Any => - new Status(x) - } - }(myExecutionContext) + ws.url(instanceRegistryUri + "/instances/" + instanceID + "/label") + .withHttpHeaders(("Authorization", s"Bearer ${AuthProvider.generateJwt()}")) + .post(Json.obj("Label" -> label)) + .map { response => + response.status match { + // scalastyle:off magic.number + case 202 => + // scalastyle:on magic.number + Ok(response.body) + case x: Any => + new Status(x) + } + }(myExecutionContext) } - def refreshToken(token: String): Action[AnyContent] = authAction.async + def refreshToken(): Action[AnyContent] = authAction.async { request => ws.url(instanceRegistryUri + "/users" + "/refreshToken") @@ -270,4 +272,4 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma } }(myExecutionContext) } -} +} \ No newline at end of file