remove the plantIds fetch
This commit is contained in:
parent
09bc25346d
commit
3b5a0379cb
@ -75,27 +75,27 @@ object Auth {
|
|||||||
val roles = ((jwtClaims.jwtClaims.claimsMap["realm_access"] as Map<String, Any>)["roles"]) as List<String>
|
val roles = ((jwtClaims.jwtClaims.claimsMap["realm_access"] as Map<String, Any>)["roles"]) as List<String>
|
||||||
val date = Date(jwtClaims.jwtClaims.expirationTime.valueInMillis)
|
val date = Date(jwtClaims.jwtClaims.expirationTime.valueInMillis)
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
HttpClients.createDefault().use { h ->
|
// HttpClients.createDefault().use { h ->
|
||||||
//sync plant's from rmc to here, just name and id
|
// //sync plant's from rmc to here, just name and id
|
||||||
for (plantId in plantIds) {
|
// for (plantId in plantIds) {
|
||||||
|
//
|
||||||
val existing = Session.database.find(Plant::class.java).where().eq("plantId", plantId).findOne()
|
// val existing = Session.database.find(Plant::class.java).where().eq("plantId", plantId).findOne()
|
||||||
if (existing == null) {
|
// if (existing == null) {
|
||||||
h.execute(HttpGet("${appConfig.integrationRmc()}/plant?id=${plantId}")).use { r ->
|
// h.execute(HttpGet("${appConfig.integrationRmc()}/plant?id=${plantId}")).use { r ->
|
||||||
if (r.statusLine.statusCode == 200) {
|
// if (r.statusLine.statusCode == 200) {
|
||||||
Session.database.save(Plant().apply {
|
// Session.database.save(Plant().apply {
|
||||||
this.plantId = plantId
|
// this.plantId = plantId
|
||||||
this.plantName = EntityUtils.toString(r.entity)
|
// this.plantName = EntityUtils.toString(r.entity)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (e: Exception) {
|
// } catch (e: Exception) {
|
||||||
logger.warn("Exception in syncing plants", e)
|
// logger.warn("Exception in syncing plants", e)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return AuthUser(
|
return AuthUser(
|
||||||
userName = userId,
|
userName = userId,
|
||||||
@ -107,7 +107,9 @@ object Auth {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val userToTenant = ConcurrentHashMap<String, String>()
|
||||||
private fun getTenantWithCompany(userId: String, tenant: String): String {
|
private fun getTenantWithCompany(userId: String, tenant: String): String {
|
||||||
|
return userToTenant.computeIfAbsent(userId) {
|
||||||
try {
|
try {
|
||||||
HttpClients.createDefault().use { h ->
|
HttpClients.createDefault().use { h ->
|
||||||
//sync plant's from rmc to here, just name and id
|
//sync plant's from rmc to here, just name and id
|
||||||
@ -115,7 +117,7 @@ object Auth {
|
|||||||
h.execute(HttpGet("${appConfig.integrationRmc()}/tenant?id=${userId}")).use { r ->
|
h.execute(HttpGet("${appConfig.integrationRmc()}/tenant?id=${userId}")).use { r ->
|
||||||
if (r.statusLine.statusCode == 200) {
|
if (r.statusLine.statusCode == 200) {
|
||||||
|
|
||||||
return "$tenant${EntityUtils.toString(r.entity)}"
|
"$tenant${EntityUtils.toString(r.entity)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -123,7 +125,8 @@ object Auth {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.warn("Exception in syncing plants", e)
|
logger.warn("Exception in syncing plants", e)
|
||||||
}
|
}
|
||||||
return tenant
|
tenant
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keys(ctx: Context) {
|
fun keys(ctx: Context) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user