Skip to content

Commit 378c7ee

Browse files
committed
fix attachment url pattern
1 parent c81a31c commit 378c7ee

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

kotlin-insight-client/kotlin-insight-client-sdk/src/main/kotlin/com/linkedplanet/kotlininsightclient/sdk/SdkInsightAttachmentOperator.kt

+2-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.linkedplanet.kotlininsightclient.sdk
2222
import arrow.core.Either
2323
import arrow.core.raise.either
2424
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
25+
import com.linkedplanet.kotlininsightclient.api.error.OtherNotFoundError
2526
import com.linkedplanet.kotlininsightclient.api.interfaces.InsightAttachmentOperator
2627
import com.linkedplanet.kotlininsightclient.api.model.AttachmentId
2728
import com.linkedplanet.kotlininsightclient.api.model.InsightAttachment
@@ -66,13 +67,7 @@ object SdkInsightAttachmentOperator : InsightAttachmentOperator {
6667
val attachmentId = attachmentUrlResolver.parseAttachmentIdFromPathInformation(url)
6768
val attachmentBean = objectFacade.loadAttachmentBeanById(attachmentId)
6869
fileManager.getObjectAttachmentContent(attachmentBean.objectId, attachmentBean.nameInFileSystem)
69-
}
70-
71-
suspend fun downloadAttachmentById(attachmentId: AttachmentId): Either<InsightClientError, InputStream> =
72-
catchAsInsightClientError {
73-
val attachmentBean = objectFacade.loadAttachmentBeanById(attachmentId.raw)
74-
fileManager.getObjectAttachmentContent(attachmentBean.objectId, attachmentBean.nameInFileSystem)
75-
}
70+
}.mapLeft { OtherNotFoundError("Attachment download failed for url:$url") }
7671

7772
override suspend fun downloadAttachmentZip(objectId: InsightObjectId): Either<InsightClientError, InputStream> =
7873
either {

kotlin-insight-client/kotlin-insight-client-sdk/src/main/kotlin/com/linkedplanet/kotlininsightclient/sdk/services/ReverseEngineeredAttachmentUrlResolver.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class ReverseEngineeredAttachmentUrlResolver {
3434

3535
private val applicationProperties: ApplicationProperties by getComponent()
3636

37-
private val pattern = Pattern.compile(".*/(\\d+)/?")
37+
private val pattern = Pattern.compile(".*/(\\d+)(/[^/]*)?$")
3838
private val INSIGHT_REST_BASE_URL = "/rest/insight/1.0"
3939

4040
private fun baseUrl(): String = applicationProperties.jiraBaseUrl

0 commit comments

Comments
 (0)