Skip to content

Commit 501e006

Browse files
Updated Compose, Javalin, Ktor and Micronaut samples to use GroupDocs.Comparison for Java v22.11
1 parent c8e9bc5 commit 501e006

File tree

13 files changed

+65
-15
lines changed

13 files changed

+65
-15
lines changed

Demos/Compose/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = "22.11"
1212

1313
repositories {
1414
google()
15+
mavenLocal()
1516
mavenCentral()
1617
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
1718
maven("https://repository.groupdocs.com/repo/")
@@ -20,7 +21,7 @@ repositories {
2021
dependencies {
2122
implementation(compose.desktop.currentOs)
2223
implementation("commons-io:commons-io:2.11.0")
23-
implementation("com.groupdocs:groupdocs-comparison:22.11")
24+
implementation("com.groupdocs:groupdocs-comparison:$version")
2425
}
2526

2627
tasks.withType<KotlinCompile> {
@@ -33,7 +34,7 @@ compose.desktop {
3334
nativeDistributions {
3435
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
3536
packageName = "groupdocs-comparison-compose"
36-
packageVersion = "22.11.0"
37+
packageVersion = "$version.0"
3738

3839
windows {
3940
shortcut = true

Demos/Javalin/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ group = "com.groupdocs.ui"
1212
version = "22.11"
1313

1414
repositories {
15+
mavenLocal()
1516
mavenCentral()
1617
maven("https://repository.groupdocs.com/repo/")
1718
}

Demos/Javalin/src/main/kotlin/com/groupdocs/ui/Application.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.groupdocs.ui
33
import com.groupdocs.comparison.license.License
44
import com.groupdocs.ui.config.ApplicationConfig
55
import com.groupdocs.ui.di.ModulesInjection
6+
import com.groupdocs.ui.model.ErrorResponse
67
import com.groupdocs.ui.modules.compare.compareModule
78
import com.groupdocs.ui.modules.config.configModule
89
import com.groupdocs.ui.modules.description.descriptionModule
@@ -65,6 +66,19 @@ fun main(args: Array<String>) {
6566
downloadModule()
6667
uploadModule()
6768
}
69+
app.exception(Exception::class.java) { e, ctx ->
70+
e.printStackTrace()
71+
ctx.json(
72+
ErrorResponse(
73+
message = if (e.message?.equals("File's types are different or are not supported") == true) {
74+
"Document types are not supported in sample app, anyway, it is still supported by GroupDocs.Comparison itself. Other probable reason of the error - documents types are different."
75+
76+
} else {
77+
e.message ?: "Internal server error"
78+
}
79+
)
80+
).status(500)
81+
}
6882
}
6983

7084
fun setGroupdocsLicense(licensePath: String) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.groupdocs.ui.model
2+
3+
data class ErrorResponse(
4+
val message: String,
5+
val exception: Exception? = null
6+
)

Demos/Javalin/src/main/kotlin/com/groupdocs/ui/modules/compare/CompareController.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@ class CompareControllerImpl(
9292
comparisonAction = changeInfo.comparisonAction,
9393
sourceText = changeInfo.sourceText,
9494
targetText = changeInfo.targetText,
95-
text = changeInfo.text,
95+
text = changeInfo.text ?: "",
9696
componentType = changeInfo.componentType,
9797
box = ChangeBox(
9898
x = changeInfo.box.x,
9999
y = changeInfo.box.y,
100100
width = changeInfo.box.width,
101101
height = changeInfo.box.height
102102
),
103-
authors = changeInfo.authors,
103+
authors = changeInfo.authors ?: emptyList(),
104104
pageInfo = PageInfo(
105105
pageNumber = changeInfo.pageInfo.pageNumber,
106106
width = changeInfo.pageInfo.width,
107107
height = changeInfo.pageInfo.height
108108
),
109-
styleChanges = changeInfo.styleChanges.map { styleChangeInfo ->
109+
styleChanges = (changeInfo.styleChanges ?: emptyList()).map { styleChangeInfo ->
110110
StyleChange(
111111
propertyName = styleChangeInfo.propertyName,
112112
oldValue = styleChangeInfo.oldValue,

Demos/Ktor/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ group = "com.groupdocs.ui"
1313
version = "22.11"
1414

1515
repositories {
16+
mavenLocal()
1617
mavenCentral()
1718
maven("https://repository.groupdocs.com/repo/")
1819
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.groupdocs.ui.model
2+
3+
data class ErrorResponse(
4+
val message: String,
5+
val exception: Exception? = null
6+
)

Demos/Ktor/src/main/kotlin/com/groupdocs/ui/modules/compare/CompareModule.kt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.groupdocs.ui.modules.compare
22

33
import com.groupdocs.ui.model.CompareRequest
4+
import com.groupdocs.ui.model.ErrorResponse
5+
import com.groupdocs.ui.status.InternalServerException
46
import io.ktor.http.*
57
import io.ktor.server.application.*
68
import io.ktor.server.request.*
@@ -13,8 +15,21 @@ fun Route.compareModule() {
1315
val compareController by inject<CompareController>()
1416

1517
post("/compare") {
16-
val request = call.receive<CompareRequest>()
17-
val response = compareController.compare(request)
18-
call.respond(HttpStatusCode.OK, response)
18+
try {
19+
val request = call.receive<CompareRequest>()
20+
val response = compareController.compare(request)
21+
call.respond(HttpStatusCode.OK, response)
22+
} catch (e: InternalServerException) {
23+
call.respond(
24+
status = HttpStatusCode.InternalServerError,
25+
message = ErrorResponse(
26+
message = if (e.message == "File's types are different or are not supported") {
27+
"Document types are not supported in sample app, anyway, it is still supported by GroupDocs.Comparison itself. Other probable reason of the error - documents types are different."
28+
} else {
29+
e.message
30+
}
31+
)
32+
)
33+
}
1934
}
2035
}

Demos/Micronaut/DocumentSamples/.gitkeep

Whitespace-only changes.

Demos/Micronaut/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version = "22.11"
1111

1212
val kotlinVersion = project.properties["kotlinVersion"]
1313
repositories {
14+
mavenLocal()
1415
mavenCentral()
1516
maven("https://repository.groupdocs.com/repo/")
1617
}
@@ -59,6 +60,10 @@ tasks {
5960
jvmTarget = "11"
6061
}
6162
}
63+
64+
shadowJar {
65+
isZip64 = true
66+
}
6267
}
6368
graalvmNative.toolchainDetection.set(false)
6469
micronaut {

0 commit comments

Comments
 (0)