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

io.vertx.tp.ke.refine.Ke Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.tp.ke.refine;

import io.vertx.core.Future;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Session;
import io.vertx.tp.ke.cv.KeField;
import io.vertx.up.commune.Envelop;
import io.vertx.up.log.Annal;

import java.util.function.Function;
import java.util.function.Supplier;

public class Ke {

    /*
     * Read jooq configuration database name `catalog`
     */
    public static String getDatabase() {
        return KeTool.getCatalog();
    }

    /*
     * Process image field.
     */
    public static Function> image(final String field) {
        return KeImage.image(field);
    }

    public static  Future poolAsync(final String name, final String key, final Supplier> supplier) {
        return KeTool.poolAsync(name, key, supplier);
    }

    public static void banner(final String module) {
        KeTool.banner(module);
    }

    public static void infoKe(final Annal logger, final String pattern, final Object... args) {
        KeLog.infoKe(logger, pattern, args);
    }

    /*
     * Session key generation
     */
    public static String keySession(final String method, final String uri) {
        return KeCache.keySession(method, uri);
    }

    public static String keySession(final Envelop envelop) {
        return KeCache.keyEnvelop(envelop, KeCache::keySession);
    }

    public static String keyAuthorized(final String method, final String uri) {
        return KeCache.keyAuthorized(method, uri);
    }

    public static String keyAuthorized(final Envelop envelop) {
        return KeCache.keyEnvelop(envelop, KeCache::keyAuthorized);
    }

    /*
     * Get keySession here for current logged user
     */
    public static Future session(final String id) {
        return KeCache.session(id);
    }

    public static  Future session(final Session session, final String sessionKey, final String dataKey, final T value) {
        return KeCache.session(session, sessionKey, dataKey, value);
    }

    /*
     * Result for response
     */
    public interface Result {

        static JsonObject bool(final boolean checked) {
            return KeResult.bool(KeField.RESULT, checked);
        }

        static JsonObject bool(final String key, final boolean checked) {
            return KeResult.bool(key, checked);
        }

        static JsonObject array(final JsonArray array) {
            return KeResult.array(array);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy