Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Merge branch 'imunic-use_uuid_for_author_comparison'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueegg committed Dec 1, 2016
2 parents 0a328ca + 5537d9a commit 02c106e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package ch.mibex.bitbucket.sonar.client

import java.net.{HttpURLConnection, InetSocketAddress, URL}
import java.net.{HttpURLConnection, InetSocketAddress, Proxy, URL}
import javax.ws.rs.core.MediaType

import ch.mibex.bitbucket.sonar.{SonarBBPlugin, SonarBBPluginConfig}
import ch.mibex.bitbucket.sonar.utils.{JsonUtils, LogUtils}
import java.net.Proxy
import ch.mibex.bitbucket.sonar.{SonarBBPlugin, SonarBBPluginConfig}
import com.sun.jersey.api.client.config.{ClientConfig, DefaultClientConfig}
import com.sun.jersey.api.client.filter.LoggingFilter
import com.sun.jersey.api.client.{Client, ClientResponse, UniformInterfaceException}
Expand Down Expand Up @@ -256,13 +255,20 @@ class BitbucketClient(config: SonarBBPluginConfig) extends BatchComponent {
result
}

private def getLoggedInUserUUID = {
val response = client
.resource(s"https://bitbucket.org/api/2.0/user")
.accept(MediaType.APPLICATION_JSON)
.get(classOf[String])
val user = JsonUtils.mapFromJson(response)
user("uuid").asInstanceOf[String]
private def getLoggedInUserUUID: String = {
try {
val response = client
.resource(s"https://bitbucket.org/api/2.0/user")
.accept(MediaType.APPLICATION_JSON)
.get(classOf[String])
val user = JsonUtils.mapFromJson(response)
user("uuid").asInstanceOf[String]
} catch {
case e: UniformInterfaceException =>
throw new IllegalStateException(
s"${SonarBBPlugin.PluginLogPrefix} Couldn't fetch logged in user uuid, got status: ${e.getResponse.getStatus}"
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object SonarUtils {
URLEncoder.encode(url, "UTF-8")
} catch {
case e: UnsupportedEncodingException =>
throw new IllegalStateException("[sonar4bitbucket] Encoding not supported", e)
throw new IllegalStateException(s"${SonarBBPlugin.PluginLogPrefix} Encoding not supported", e)
}
}

Expand Down

0 comments on commit 02c106e

Please sign in to comment.