All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enodeframework.mysql.handler.MySQLFindPublishedVersionHandler.kt Maven / Gradle / Ivy

package org.enodeframework.mysql.handler

import io.vertx.core.AsyncResult
import io.vertx.core.Handler
import io.vertx.mysqlclient.MySQLException
import io.vertx.sqlclient.Row
import io.vertx.sqlclient.RowSet
import org.enodeframework.common.exception.IORuntimeException
import org.enodeframework.common.exception.PublishedVersionStoreException
import org.slf4j.LoggerFactory
import java.util.concurrent.CompletableFuture

class MySQLFindPublishedVersionHandler(private val msg: String) : Handler>> {

    companion object {
        private val logger = LoggerFactory.getLogger(MySQLFindPublishedVersionHandler::class.java)
    }

    var future = CompletableFuture()

    override fun handle(ar: AsyncResult>) {
        if (ar.succeeded()) {
            future.complete(ar.result().firstOrNull()?.getInteger(0) ?: 0);
            return
        }
        val throwable = ar.cause()
        if (throwable is MySQLException) {
            logger.error(
                "Get aggregate published version has sql exception. msg: {}", msg, throwable
            )
            future.completeExceptionally(IORuntimeException(msg, throwable))
            return
        }
        logger.error(
            "Get aggregate published version has unknown exception. msg: {}", msg, throwable
        )
        future.completeExceptionally(PublishedVersionStoreException(msg, throwable))
        return
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy