diff --git a/application-files/products/1/test.avif b/application-files/products/1/test.avif new file mode 100644 index 00000000..e69de29b diff --git a/application-files/products/1/test.jpg b/application-files/products/1/test.jpg new file mode 100644 index 00000000..ae210092 Binary files /dev/null and b/application-files/products/1/test.jpg differ diff --git a/application-files/products/1/test.png b/application-files/products/1/test.png new file mode 100644 index 00000000..93c85a91 Binary files /dev/null and b/application-files/products/1/test.png differ diff --git a/application-files/products/1/test.webp b/application-files/products/1/test.webp new file mode 100644 index 00000000..b65a4396 Binary files /dev/null and b/application-files/products/1/test.webp differ diff --git a/compose.yaml b/compose.yaml index 11085e61..8ee198d8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,6 +15,7 @@ services: - POSTGRES_DB=ex-dock volumes: - ./database/ex-dock.sql:/docker-entrypoint-initdb.d/datadump.sql + - ./application-files:/app/application-files ports: - "8890:5432" networks: diff --git a/pom.xml b/pom.xml index b91b8fd4..21886e16 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,11 @@ kotlin-stdlib ${kotlin.version} + + io.vertx + vertx-launcher-application + ${vertx.version} + org.jetbrains.kotlin kotlin-reflect @@ -202,6 +207,11 @@ oshi-core 6.8.2 + + com.fasterxml.jackson.core + jackson-databind + 2.18.0 + diff --git a/src/main/kotlin/com/ex_dock/ex_dock/ExtensionsLauncher.kt b/src/main/kotlin/com/ex_dock/ex_dock/ExtensionsLauncher.kt index 573cf57b..dfc8b228 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/ExtensionsLauncher.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/ExtensionsLauncher.kt @@ -5,9 +5,7 @@ import com.ex_dock.ex_dock.frontend.FrontendVerticle import com.ex_dock.ex_dock.helper.deployVerticleHelper import com.ex_dock.ex_dock.helper.registerVerticleIds import io.github.oshai.kotlinlogging.KotlinLogging -import io.vertx.core.AbstractVerticle import io.vertx.core.Future -import io.vertx.core.Promise import io.vertx.core.VerticleBase import io.vertx.ext.web.client.WebClient import java.util.* diff --git a/src/main/kotlin/com/ex_dock/ex_dock/MainVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/MainVerticle.kt index 2c2ebf71..b3946348 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/MainVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/MainVerticle.kt @@ -11,7 +11,6 @@ import com.ex_dock.ex_dock.frontend.text_pages.router.initTextPages import com.ex_dock.ex_dock.helper.registerGenericCodec import com.ex_dock.ex_dock.helper.sendError import io.github.oshai.kotlinlogging.KotlinLogging -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.Promise import io.vertx.core.VerticleBase @@ -19,6 +18,7 @@ import io.vertx.core.eventbus.EventBus import io.vertx.core.http.CookieSameSite import io.vertx.core.http.HttpServerOptions import io.vertx.ext.web.Router +import io.vertx.ext.web.handler.CorsHandler import io.vertx.ext.web.handler.SessionHandler import io.vertx.ext.web.sstore.SessionStore import java.util.Properties @@ -51,10 +51,14 @@ class MainVerticle : VerticleBase() { logger.error { "Failed to start MainVerticle: $err" } } - val eventBus = vertx.eventBus() val mainRouter : Router = Router.router(vertx) val store = SessionStore.create(vertx) val sessionHandler = SessionHandler.create(store) + val eventBus: EventBus = vertx.eventBus() + + if (!areCodecsRegistered) { + eventBus.registerGenericCodec(ServerStartException::class) + } eventBus.registerGenericCodec(List::class) eventBus.consumer>("process.main.registerVerticleId").handler { message -> @@ -84,6 +88,7 @@ class MainVerticle : VerticleBase() { sessionHandler.setCookieSameSite(CookieSameSite.STRICT) mainRouter.route().handler(sessionHandler) + mainRouter.route().handler(CorsHandler.create()) mainRouter.enableBackendRouter(vertx, logger) diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/BackendRouter.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/BackendRouter.kt index 979d7ae8..e657959f 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/backend/BackendRouter.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/BackendRouter.kt @@ -4,6 +4,7 @@ import com.ex_dock.ex_dock.backend.v1.router.auth.AuthProvider import com.ex_dock.ex_dock.backend.v1.router.auth.enableAuthRouter import com.ex_dock.ex_dock.backend.v1.router.docker.initDocker import com.ex_dock.ex_dock.backend.v1.router.enableBackendV1Router +import com.ex_dock.ex_dock.backend.v1.router.file.initFileRouter import com.ex_dock.ex_dock.backend.v1.router.websocket.initWebsocket import com.ex_dock.ex_dock.helper.registerGenericCodec import io.github.oshai.kotlinlogging.KLogger @@ -45,8 +46,6 @@ fun Router.enableBackendRouter(vertx: Vertx, logger: KLogger) { pairDeliveryOptions ) - backendRouter.route().handler(CorsHandler.create()) - backendRouter.enableAuthRouter(vertx) // Only use these routers for websockets, because they use other authorization methods diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/BackendV1Router.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/BackendV1Router.kt index dbf41467..12ce9ff7 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/BackendV1Router.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/BackendV1Router.kt @@ -2,6 +2,7 @@ package com.ex_dock.ex_dock.backend.v1.router import com.ex_dock.ex_dock.backend.apiMountingPath import com.ex_dock.ex_dock.backend.v1.router.auth.AuthProvider +import com.ex_dock.ex_dock.backend.v1.router.file.initFileRouter import com.ex_dock.ex_dock.database.backend_block.FullBlockInfo import com.ex_dock.ex_dock.frontend.auth.ExDockAuthHandler import com.ex_dock.ex_dock.backend.v1.router.image.initImage @@ -76,6 +77,7 @@ fun Router.enableBackendV1Router(vertx: Vertx, absoluteMounting: Boolean = false "images", jsonElement.findValueByFieldName("images").convertJsonElement() ) + blockInformationJson.put("attributes", blockAttributesList) } else { blockInformationJson.put("attributes", blockAttributesList) } @@ -115,6 +117,7 @@ fun Router.enableBackendV1Router(vertx: Vertx, absoluteMounting: Boolean = false // TODO: routing backendV1Router.initImage(vertx) backendV1Router.enableSystemRouter(vertx) + backendV1Router.initFileRouter(vertx) this.route( if (absoluteMounting) "$apiMountingPath/v1*" else "/v1*" diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/auth/AuthProvider.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/auth/AuthProvider.kt index 4830ec79..1bb83f67 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/auth/AuthProvider.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/auth/AuthProvider.kt @@ -2,7 +2,7 @@ package com.ex_dock.ex_dock.backend.v1.router.auth import java.security.KeyPair import java.security.KeyPairGenerator -import java.util.Base64 +import java.util.* class AuthProvider { private val generator: KeyPairGenerator = KeyPairGenerator.getInstance("RSA") diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/file/fileRouter.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/file/fileRouter.kt new file mode 100644 index 00000000..71267285 --- /dev/null +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/file/fileRouter.kt @@ -0,0 +1,146 @@ +package com.ex_dock.ex_dock.backend.v1.router.file + +import com.ex_dock.ex_dock.database.backend_block.FullBlockInfo +import io.vertx.core.Vertx +import io.vertx.core.buffer.Buffer +import io.vertx.core.eventbus.DeliveryOptions +import io.vertx.core.json.JsonObject +import io.vertx.ext.web.Router +import kotlinx.serialization.Serializable +import java.nio.file.Paths +import kotlin.io.encoding.Base64 +import kotlin.io.encoding.ExperimentalEncodingApi +import kotlin.io.path.isDirectory + +@OptIn(ExperimentalEncodingApi::class) +fun Router.initFileRouter(vertx: Vertx) { + val fileRouter = Router.router(vertx) + + fileRouter["/getAll"].handler { ctx -> + val fullList = getRootFiles() + + ctx.response().putHeader("Content-Type", "application/json") + .end(JsonObject().put("files", fullList).encode()) + } + + fileRouter["/getAll/:path"].handler { ctx -> + val folders = emptyList().toMutableList() + val files = emptyList().toMutableList() + var path = ctx.pathParam("path") + path = path.replace("%2F", "/") + path = "application-files/$path" + val fullPath = Paths.get(path) + + if (!fullPath.toFile().exists()) { + ctx.fail(400, Error("Path does not exist")) + } + + if (fullPath.toFile().isDirectory) { + fullPath.toFile().listFiles()?.forEach { file -> + if (file.isDirectory) { + val engineFile = EngineFile(file.name, "folder", file.length().toInt()) + folders.add(engineFile) + } else { + val engineFile = EngineFile(file.name, file.extension, file.length().toInt()) + files.add(engineFile) + } + } + + val fullList = folders + files + ctx.response().putHeader("Content-Type", "application/json") + .end(JsonObject().put("files", fullList).encode()) + } else { + val contentType: String = when (fullPath.toFile().extension) { + "png" -> "image" + "jpg" -> "image" + "jpeg" -> "image" + "gif" -> "image" + "avif" -> "image" + "md" -> "markdown" + "mp4" -> "mp4" + "pdf" -> "pdf" + "txt" -> "plain" + "webp" -> "image" + else -> "unknown" + } + + ctx.response().putHeader("Content-Type", "application/octet-stream") + .end( + JsonObject() + .put("contentType", contentType) + .put("fileName", fullPath.toFile().name) + .put("fileSize", fullPath.toFile().length()) + .put("fileExtension", fullPath.toFile().extension) + .put("data", Base64.Default.encode(fullPath.toFile().readBytes())).encode() + ) + } + } + + fileRouter["/getBlockData/:blockName"].handler { ctx -> + val blockName = ctx.pathParam("blockName") + + vertx.eventBus().request>( + "process.backend_block.getAllFullInfoByBlockNames", + blockName, DeliveryOptions().setCodecName("ListCodec") + ).onFailure { + ctx.fail(500, it) + }.onSuccess { result -> + val blocks = result.body() + val jsonResponse = JsonObject() + blocks.forEach { block -> + val blockInformationJson = JsonObject() + val blockAttributesList = mutableListOf() + val fullList = getRootFiles() + + block.blockAttributes.forEach { blockAttribute -> + if (blockAttribute.attributeName == "Files") { + val attributeJson = JsonObject() + attributeJson.put("attribute_id", blockAttribute.attributeId) + attributeJson.put("attribute_name", blockAttribute.attributeName) + attributeJson.put("attribute_type", blockAttribute.attributeType) + attributeJson.put( + "current_attribute_value", + fullList + ) + blockAttributesList.add(attributeJson) + } + } + + blockInformationJson.put("block_type", block.backendBlock.blockType) + blockInformationJson.put("attributes", blockAttributesList) + jsonResponse.put(block.backendBlock.blockName, blockInformationJson) + } + + ctx.end(jsonResponse.encode()) + } + } + + this.route("/file*").subRouter(fileRouter) +} + +fun getRootFiles(): List { + val folders = emptyList().toMutableList() + val files = emptyList().toMutableList() + val path = "application-files" + val fullPath = Paths.get(path) + + fullPath.toFile().listFiles()?.forEach { file -> + if (file.isDirectory) { + val engineFile = EngineFile(file.name, "folder", file.length().toInt()) + folders.add(engineFile) + } else { + val engineFile = EngineFile(file.name, file.extension, file.length().toInt()) + files.add(engineFile) + } + } + + val fullList = folders + files + return fullList +} + +@Serializable +data class EngineFile( + val fileName: String, + val extension: String, + val fileSize: Int +) diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/image/imageRouter.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/image/imageRouter.kt index a14dd185..408ee560 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/image/imageRouter.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/image/imageRouter.kt @@ -1,25 +1,62 @@ package com.ex_dock.ex_dock.backend.v1.router.image +import com.ex_dock.ex_dock.MainVerticle import io.vertx.core.Vertx +import io.vertx.core.buffer.Buffer import io.vertx.ext.web.Router import io.vertx.ext.web.handler.BodyHandler import io.vertx.ext.web.handler.StaticHandler +import java.io.IOException +import java.nio.file.Files +import java.nio.file.Paths +import kotlin.io.path.extension fun Router.initImage(vertx: Vertx) { val imageRouter = Router.router(vertx) val eventBus = vertx.eventBus() imageRouter.post().handler(BodyHandler.create() - .setUploadsDirectory("src/main/resources/images") + .setUploadsDirectory("application-files/images") .setMergeFormAttributes(true)) - imageRouter.post("/").handler(StaticHandler.create("src/main/resources/images").setCachingEnabled(false)) + imageRouter.post("/").handler(StaticHandler.create("application-files/images").setCachingEnabled(false)) - imageRouter.post("/").handler { ctx -> - val path = ctx.request().getFormAttribute("path") + imageRouter.post("/:path").handler { ctx -> + var path = ctx.pathParam("path") + path = path.replace("%2F", "/") eventBus.send("process.service.convertImage", path) ctx.end("request to imageRouter successful") } + imageRouter.get("/get/:path").handler { ctx -> + var path = ctx.pathParam("path") + path = path.replace("%2F", "/") + path = "application-files/$path" + val imagePath = Paths.get(path) + + // Check if the requested image exists + if (!Files.exists(imagePath)) { + MainVerticle.logger.error { "Image not found: $path" } + ctx.response().setStatusCode(404).end("Image not found") + } + + try { + // Read the image file into a byte array + val imageData: ByteArray = Files.readAllBytes(imagePath) + + // Get the image extension type + var extension = imagePath.extension + if (extension == "jpg") extension = "jpeg" + val contentType = "image/$extension" + + ctx.response().putHeader("Content-Type", contentType) + ctx.response().end(Buffer.buffer(imageData)) + } catch (e: IOException) { + MainVerticle.logger.error { "Error reading image file: $path" } + ctx.response().setStatusCode(500).end("Error reading image file") + } + + } + this.route("/image*").subRouter(imageRouter) } diff --git a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/system/SystemVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/system/SystemVerticle.kt index 0c1fb0d3..85c4400b 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/system/SystemVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/backend/v1/router/system/SystemVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.backend.v1.router.system import com.ex_dock.ex_dock.helper.load import io.github.oshai.kotlinlogging.KotlinLogging -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/JDBCStarter.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/JDBCStarter.kt index 42ea50de..2555d428 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/JDBCStarter.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/JDBCStarter.kt @@ -32,9 +32,7 @@ import com.ex_dock.ex_dock.database.text_pages.TextPagesSeo import com.ex_dock.ex_dock.database.url.* import com.ex_dock.ex_dock.frontend.cache.CacheVerticle import com.ex_dock.ex_dock.helper.* -import io.vertx.core.AbstractVerticle import io.vertx.core.Future -import io.vertx.core.Promise import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/account/AccountJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/account/AccountJdbcVerticle.kt index a1d56d28..21114105 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/account/AccountJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/account/AccountJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.account import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/auth/AuthenticationVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/auth/AuthenticationVerticle.kt index 300d56bd..797c2e48 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/auth/AuthenticationVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/auth/AuthenticationVerticle.kt @@ -1,10 +1,8 @@ package com.ex_dock.ex_dock.database.auth -import com.ex_dock.ex_dock.database.account.BackendPermissions import com.ex_dock.ex_dock.database.account.FullUser import com.ex_dock.ex_dock.database.account.convertUser import com.ex_dock.ex_dock.frontend.auth.ExDockAuthHandler -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus @@ -15,8 +13,6 @@ import io.vertx.ext.auth.authentication.TokenCredentials import io.vertx.ext.auth.authentication.UsernamePasswordCredentials import io.vertx.ext.auth.jwt.JWTAuth import io.vertx.ext.auth.jwt.JWTAuthOptions -import java.security.KeyPair -import java.security.KeyPairGenerator import java.util.* class AuthenticationVerticle: VerticleBase() { diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/backend_block/BackendBlockJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/backend_block/BackendBlockJdbcVerticle.kt index a826be5c..f0ca2bcf 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/backend_block/BackendBlockJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/backend_block/BackendBlockJdbcVerticle.kt @@ -1,8 +1,6 @@ package com.ex_dock.ex_dock.database.backend_block import com.ex_dock.ex_dock.database.connection.getConnection -import io.vertx.core.AbstractVerticle -import io.vertx.core.CompositeFuture import io.vertx.core.Future import io.vertx.core.Promise import io.vertx.core.VerticleBase diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/category/CategoryJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/category/CategoryJdbcVerticle.kt index a73c1eaa..f6b0d774 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/category/CategoryJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/category/CategoryJdbcVerticle.kt @@ -3,7 +3,6 @@ package com.ex_dock.ex_dock.database.category import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.database.product.Products import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/image/ImageJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/image/ImageJdbcVerticle.kt index 753b4072..5399c80b 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/image/ImageJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/image/ImageJdbcVerticle.kt @@ -1,7 +1,6 @@ package com.ex_dock.ex_dock.database.image import com.ex_dock.ex_dock.database.connection.getConnection -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCompleteEavJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCompleteEavJdbcVerticle.kt index 1cc3a059..be028f45 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCompleteEavJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCompleteEavJdbcVerticle.kt @@ -1,7 +1,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus @@ -24,7 +23,6 @@ class ProductCompleteEavJdbcVerticle : VerticleBase() { eventBus = vertx.eventBus() getAllCompleteProductEavData() - getAllCompleteProductEavDataByProductIdOld() getAllCompleteProductEavDataByProductId() return Future.succeededFuture() @@ -123,101 +121,6 @@ class ProductCompleteEavJdbcVerticle : VerticleBase() { } } - @Deprecated("Use the newer function below") - private fun getAllCompleteProductEavDataByProductIdOld() { - val consumer = eventBus.consumer("process.completeEav.getByIdOld") - consumer.handler { message -> - val query = "SELECT " + - "products.product_id AS product_id, " + - "products.name AS product_name, " + - "products.short_name AS product_short_name, " + - "products.description AS product_description, " + - "products.short_description AS product_short_description, " + - "e.attribute_key AS attribute_key, " + - "egb.value AS global_bool, " + - "egf.value AS global_float, " + - "egs.value AS global_string, " + - "egi.value AS global_int, " + - "egm.value AS global_money, " + - "egms.value AS global_multi_select, " + - "esvb.value AS store_view_bool, " + - "esvf.value AS store_view_float, " + - "esvs.value AS store_view_string, " + - "esvi.value AS store_view_int, " + - "esvm.value AS store_view_money, " + - "esvms.value AS store_view_multi_select, " + - "ewb.value AS website_bool, " + - "ewf.value AS website_float, " + - "ews.value AS website_string, " + - "ewi.value AS website_int, " + - "ewm.value AS website_money, " + - "ewms.value AS website_multi_select," + - "msab.value AS multi_select_bool, " + - "msaf.value AS multi_select_float, " + - "msas.value AS multi_select_string, " + - "msai.value AS multi_select_int, " + - "msam.value AS multi_select_money, " + - "w.website_id AS website_id, " + - "sv.store_view_id AS store_view_id " + - "FROM products " + - "LEFT JOIN public.eav e on products.product_id = e.product_id " + - "LEFT JOIN public.custom_product_attributes cpa on cpa.attribute_key = e.attribute_key " + - "LEFT JOIN public.eav_global_bool egb on products.product_id = egb.product_id " + - "LEFT JOIN public.eav_global_float egf on products.product_id = egf.product_id " + - "LEFT JOIN public.eav_global_int egi on products.product_id = egi.product_id " + - "LEFT JOIN public.eav_global_money egm on products.product_id = egm.product_id " + - "LEFT JOIN public.eav_global_multi_select egms on products.product_id = egms.product_id " + - "LEFT JOIN public.eav_global_string egs on products.product_id = egs.product_id " + - "LEFT JOIN public.eav_website_bool ewb on products.product_id = ewb.product_id " + - "LEFT JOIN public.eav_website_float ewf on products.product_id = ewf.product_id " + - "LEFT JOIN public.eav_website_int ewi on products.product_id = ewi.product_id " + - "LEFT JOIN public.eav_website_money ewm on products.product_id = ewm.product_id " + - "LEFT JOIN public.eav_website_multi_select ewms on products.product_id = ewms.product_id " + - "LEFT JOIN public.eav_website_string ews on products.product_id = ews.product_id " + - "LEFT JOIN public.eav_store_view_bool esvb on products.product_id = esvb.product_id " + - "LEFT JOIN public.eav_store_view_float esvf on products.product_id = esvf.product_id " + - "LEFT JOIN public.eav_store_view_int esvi on products.product_id = esvi.product_id " + - "LEFT JOIN public.eav_store_view_money esvm on products.product_id = esvm.product_id " + - "LEFT JOIN public.eav_store_view_multi_select esvms on products.product_id = esvms.product_id " + - "LEFT JOIN public.eav_store_view_string esvs on products.product_id = esvs.product_id " + - "LEFT JOIN public.multi_select_attributes_bool msab on cpa.attribute_key = msab.attribute_key " + - "LEFT JOIN public.multi_select_attributes_float msaf on cpa.attribute_key = msaf.attribute_key " + - "LEFT JOIN public.multi_select_attributes_int msai on cpa.attribute_key = msai.attribute_key " + - "LEFT JOIN public.multi_select_attributes_string msas on cpa.attribute_key = msas.attribute_key " + - "LEFT JOIN public.multi_select_attributes_money msam on cpa.attribute_key = msam.attribute_key " + - "LEFT JOIN public.store_view sv on esvb.store_view_id = sv.store_view_id " + - "LEFT JOIN public.websites w on ewb.website_id = w.website_id " + - "WHERE products.product_id =?" - var json: JsonObject - - val rowsFuture = client.preparedQuery(query).execute(Tuple.of(message.body())) - - rowsFuture.onFailure { res -> - println("Failed to execute query: $res") - message.reply(failedMessage) - } - - rowsFuture.onComplete { res -> - val rows = res.result() - if (rows.size() > 0) { - json = io.vertx.kotlin.core.json.json { - obj( - "completeEav" to rows.map { row -> - obj( - row.makeCompleteEavDataJsonFields() - ) - } - ) - } - - message.reply(json) - } else { - message.reply("No complete product EAV data found!") - } - } - } - } - private fun getAllCompleteProductEavDataByProductId() { val consumer = eventBus.consumer("process.completeEav.getById") consumer.handler { message -> diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCustomAttributesJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCustomAttributesJdbcVerticle.kt index 0fa45b27..4d6a3e4b 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCustomAttributesJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductCustomAttributesJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductGlobalEavJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductGlobalEavJdbcVerticle.kt index 411851ec..cd582114 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductGlobalEavJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductGlobalEavJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductJdbcVerticle.kt index 10556351..ef362cf4 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductJdbcVerticle.kt @@ -1,12 +1,10 @@ package com.ex_dock.ex_dock.database.product -import com.ex_dock.ex_dock.database.category.PageIndex import com.ex_dock.ex_dock.database.category.convertToString import com.ex_dock.ex_dock.database.category.toPageIndex import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.database.image.Image import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductMultiSelectJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductMultiSelectJdbcVerticle.kt index 7efbbe2f..9aae4679 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductMultiSelectJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductMultiSelectJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductStoreViewEavJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductStoreViewEavJdbcVerticle.kt index d5b8c4eb..eb66aaea 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductStoreViewEavJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductStoreViewEavJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductWebsiteEavJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductWebsiteEavJdbcVerticle.kt index 73d94128..db384009 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductWebsiteEavJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/product/ProductWebsiteEavJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.product import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/scope/ScopeJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/scope/ScopeJdbcVerticle.kt index 060f8ca0..ae7fda46 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/scope/ScopeJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/scope/ScopeJdbcVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.scope import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/server/ServerJDBCVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/server/ServerJDBCVerticle.kt index 0d7f36f3..05affa41 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/server/ServerJDBCVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/server/ServerJDBCVerticle.kt @@ -2,7 +2,6 @@ package com.ex_dock.ex_dock.database.server import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/service/ServiceVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/service/ServiceVerticle.kt index f1a28203..128e2ba1 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/service/ServiceVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/service/ServiceVerticle.kt @@ -4,7 +4,6 @@ import com.ex_dock.ex_dock.database.account.Permission import com.ex_dock.ex_dock.database.account.hash import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.helper.convertImage -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/template/TemplateJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/template/TemplateJdbcVerticle.kt index 9de85274..a3fe8259 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/template/TemplateJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/template/TemplateJdbcVerticle.kt @@ -1,7 +1,6 @@ package com.ex_dock.ex_dock.database.template import com.ex_dock.ex_dock.database.connection.getConnection -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/text_pages/TextPagesJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/text_pages/TextPagesJdbcVerticle.kt index 37300a3b..d7cdb4ea 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/text_pages/TextPagesJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/text_pages/TextPagesJdbcVerticle.kt @@ -5,7 +5,6 @@ import com.ex_dock.ex_dock.database.category.convertToString import com.ex_dock.ex_dock.database.category.toPageIndex import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/database/url/UrlJdbcVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/database/url/UrlJdbcVerticle.kt index 65f24721..4f424dc4 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/database/url/UrlJdbcVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/database/url/UrlJdbcVerticle.kt @@ -1,14 +1,11 @@ package com.ex_dock.ex_dock.database.url import com.ex_dock.ex_dock.database.category.Categories -import com.ex_dock.ex_dock.database.category.toPageIndex import com.ex_dock.ex_dock.database.connection.getConnection import com.ex_dock.ex_dock.database.product.Products import com.ex_dock.ex_dock.database.text_pages.TextPages import com.ex_dock.ex_dock.frontend.cache.setCacheFlag -import io.vertx.core.AbstractVerticle import io.vertx.core.Future -import io.vertx.core.Verticle import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/frontend/FrontendVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/frontend/FrontendVerticle.kt index 9b6fc4e7..a6b0f670 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/frontend/FrontendVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/frontend/FrontendVerticle.kt @@ -8,7 +8,6 @@ import com.ex_dock.ex_dock.frontend.product.ProductFrontendVerticle import com.ex_dock.ex_dock.frontend.template_engine.TemplateEngineVerticle import com.ex_dock.ex_dock.frontend.text_pages.TextPagesFrontendVerticle import com.ex_dock.ex_dock.helper.deployVerticleHelper -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase diff --git a/src/main/kotlin/com/ex_dock/ex_dock/frontend/account/AccountFrontendVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/frontend/account/AccountFrontendVerticle.kt index 5966be80..bcb3653e 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/frontend/account/AccountFrontendVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/frontend/account/AccountFrontendVerticle.kt @@ -1,8 +1,6 @@ package com.ex_dock.ex_dock.frontend.account -import io.vertx.core.AbstractVerticle import io.vertx.core.Future -import io.vertx.core.Promise import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/frontend/cache/CacheVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/frontend/cache/CacheVerticle.kt index 2b549bcd..0f647b47 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/frontend/cache/CacheVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/frontend/cache/CacheVerticle.kt @@ -3,7 +3,6 @@ package com.ex_dock.ex_dock.frontend.cache import com.ex_dock.ex_dock.database.service.InvalidCacheKeyException import com.github.benmanes.caffeine.cache.Caffeine import com.github.benmanes.caffeine.cache.LoadingCache -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.DeliveryOptions diff --git a/src/main/kotlin/com/ex_dock/ex_dock/frontend/home/HomeFrontendVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/frontend/home/HomeFrontendVerticle.kt index 16439e40..5cc9a092 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/frontend/home/HomeFrontendVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/frontend/home/HomeFrontendVerticle.kt @@ -1,6 +1,5 @@ package com.ex_dock.ex_dock.frontend.home -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/frontend/template_engine/TemplateEngineVerticle.kt b/src/main/kotlin/com/ex_dock/ex_dock/frontend/template_engine/TemplateEngineVerticle.kt index dbf5a64f..ea9b643b 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/frontend/template_engine/TemplateEngineVerticle.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/frontend/template_engine/TemplateEngineVerticle.kt @@ -8,7 +8,6 @@ import com.github.benmanes.caffeine.cache.LoadingCache import io.pebbletemplates.pebble.PebbleEngine import io.pebbletemplates.pebble.loader.StringLoader import io.pebbletemplates.pebble.template.PebbleTemplate -import io.vertx.core.AbstractVerticle import io.vertx.core.Future import io.vertx.core.VerticleBase import io.vertx.core.eventbus.EventBus diff --git a/src/main/kotlin/com/ex_dock/ex_dock/helper/ImageConverter.kt b/src/main/kotlin/com/ex_dock/ex_dock/helper/ImageConverter.kt index 1e42058a..55f9f7eb 100644 --- a/src/main/kotlin/com/ex_dock/ex_dock/helper/ImageConverter.kt +++ b/src/main/kotlin/com/ex_dock/ex_dock/helper/ImageConverter.kt @@ -15,7 +15,7 @@ import javax.imageio.stream.ImageOutputStream fun convertImage(path: String) { // Set all the path locations val validExtensions = listOf("png", "jpg", "webp") - val imagePath = System.getProperty("user.dir") + "\\src\\main\\resources\\images\\" + val imagePath = System.getProperty("user.dir") + "\\application-files\\" val pathSplit = path.split(".") val directorySplit = pathSplit[0].split("\\") val fileName = directorySplit.last() diff --git a/src/main/resources/default.properties b/src/main/resources/default.properties index 226777ab..d73beb74 100644 --- a/src/main/resources/default.properties +++ b/src/main/resources/default.properties @@ -7,4 +7,4 @@ DATABASE_URL="test_url" DATABASE_PASSWORD="test_password" DATABASE_USERNAME=test_username -DOCKER_ID=test_docker_id \ No newline at end of file +DOCKER_ID=test_docker_id