remove locationgroup

This commit is contained in:
gowthaman 2024-06-11 08:28:53 +05:30
parent 2ee82a2eed
commit 68107ca7f0

View File

@ -86,13 +86,13 @@ object Auth {
//sync plant's from rmc to here, just name and id
for (plantId in plantIds) {
val existing = Session.database.find(Plant::class.java).where().eq("plantId", plantId).findOne()
val existing = database.find(Plant::class.java).where().eq("plantId", plantId).findOne()
h.execute(HttpGet("${appConfig.integrationRmc()}/plant?id=${plantId}")).use { r ->
if (r.statusLine.statusCode == 200) {
val response = EntityUtils.toString(r.entity)
if (existing == null) {
Session.database.save(Plant().apply {
database.save(Plant().apply {
this.plantId = plantId
this.plantName = response
})
@ -112,7 +112,7 @@ object Auth {
return AuthUser(
userName = userId,
tenant = getTenantWithCompany(userId, tenant),
tenant = tenant,
roles = roles,
token = authToken,
expiry = LocalDateTime.from(date.toInstant().atZone(ZoneId.systemDefault())),
@ -121,26 +121,6 @@ object Auth {
}
private val userToTenant = ConcurrentHashMap<String, String>()
private fun getTenantWithCompany(userId: String, tenant: String): String {
return userToTenant.computeIfAbsent(userId) {
try {
HttpClients.createDefault().use { h ->
//sync plant's from rmc to here, just name and id
h.execute(HttpGet("${appConfig.integrationRmc()}/tenant?id=${userId}")).use { r ->
if (r.statusLine.statusCode == 200) {
"$tenant${EntityUtils.toString(r.entity)}"
}
}
}
} catch (e: Exception) {
logger.warn("Exception in syncing plants", e)
}
tenant
}
}
fun keys(ctx: Context) {
ctx.json(Session.jwk())