Skip to content

Commit

Permalink
Initial release. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades authored Aug 25, 2022
1 parent 197f1fa commit 8614778
Show file tree
Hide file tree
Showing 20 changed files with 1,100 additions and 0 deletions.
80 changes: 80 additions & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
plugins {
kotlin("jvm") version "1.7.0"
`maven-publish`
}

group = "org.veupathdb.lib"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withJavadocJar()
withSourcesJar()
}

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("stdlib-jdk7"))
implementation(kotlin("stdlib-jdk8"))

implementation("commons-fileupload:commons-fileupload:1.4")

implementation("org.glassfish.jersey.containers:jersey-container-grizzly2-http:3.0.5")
implementation("org.glassfish.jersey.containers:jersey-container-grizzly2-servlet:3.0.5")
runtimeOnly("org.glassfish.jersey.inject:jersey-hk2:3.0.5")
implementation("org.glassfish.hk2:hk2-api:3.0.3")

implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.13.3")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
}

publishing {
repositories {
maven {
name = "GitHub"
url = uri("https://maven.pkg.github.com/VEuPathDB/lib-jersey-multipart-jackson-pojo")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
}
}
}

publications {
create<MavenPublication>("gpr") {
from(components["java"])
pom {
name.set("JaxRS Multipart for Jackson POJOs")
description.set("Support for parsing Jackson POJOs from multipart/form-data request bodies.")
url.set("https://github.com/VEuPathDB/lib-jersey-multipart-jackson-pojo")
developers {
developer {
id.set("epharper")
name.set("Elizabeth Paige Harper")
email.set("[email protected]")
url.set("https://github.com/foxcapades")
organization.set("VEuPathDB")
}
}
scm {
connection.set("scm:git:git://github.com/VEuPathDB/lib-jersey-multipart-jackson-pojo.git")
developerConnection.set("scm:git:ssh://github.com/VEuPathDB/lib-jersey-multipart-jackson-pojo.git")
url.set("https://github.com/VEuPathDB/lib-jersey-multipart-jackson-pojo")
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.veupathdb.lib.jaxrs.raml.multipart

import jakarta.ws.rs.ext.Provider
import org.glassfish.jersey.server.monitoring.ApplicationEvent
import org.glassfish.jersey.server.monitoring.ApplicationEventListener
import org.glassfish.jersey.server.monitoring.RequestEvent
import org.veupathdb.lib.jaxrs.raml.multipart.utils.isMultipart

/**
* Application level event listener for the multipart plugin.
*
* This class must be registered with the container resources.
*
* This listener provides [MultipartRequestEventListener] instances for requests
* that are sent in with the `multipart/form-data` Content-Type header set.
*
* @author Elizabeth Paige Harper - https://github.com/foxcapades
* @since 1.0.0
*/
@Provider
class MultipartApplicationEventListener : ApplicationEventListener {

/**
* Does nothing.
*/
override fun onEvent(event: ApplicationEvent) {}

/**
* Returns a new [MultipartRequestEventListener] if the incoming request has
* a `multipart/form-data` Content-Type header set, otherwise returns `null`.
*
* @param requestEvent Request start event.
*
* @return Request event listener or `null`.
*/
override fun onRequest(requestEvent: RequestEvent) =
if (requestEvent.isMultipart())
MultipartRequestEventListener(requestEvent)
else
null
}
Loading

0 comments on commit 8614778

Please sign in to comment.