Skip to content

Commit cedcfe3

Browse files
authored
Merge pull request #14 from linked-planet/feature/ZITIS-845_core_common
Feature/zitis 845 core common
2 parents 9405215 + a40241b commit cedcfe3

File tree

34 files changed

+193
-103
lines changed

34 files changed

+193
-103
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.linked-planet.client</groupId>
8+
<artifactId>kotlin-atlassian-client</artifactId>
9+
<version>0.12.10-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>kotlin-atlassian-client-core-common</artifactId>
13+
<name>kotlin-atlassian-client-core-common</name>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>javax.validation</groupId>
18+
<artifactId>validation-api</artifactId>
19+
<version>2.0.1.Final</version>
20+
<scope>provided</scope>
21+
</dependency>
22+
</dependencies>
23+
24+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2022 - 2023 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class JiraUser(
25+
@field:NotNull val key: String,
26+
@field:NotNull val name: String,
27+
@field:NotNull val emailAddress: String,
28+
@field:NotNull val avatarUrl: String? = null,
29+
@field:NotNull val displayName: String
30+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2022 - 2023 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.linkedplanet.kotlinatlassianclientcore.common.api
21+
22+
import javax.validation.constraints.NotNull
23+
24+
data class Page<T> (
25+
@field:NotNull val items: List<T>,
26+
@field:NotNull val totalItems: Int,
27+
@field:NotNull val totalPages: Int,
28+
@field:NotNull val currentPageIndex: Int,
29+
@field:NotNull val pageSize: Int
30+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*-
2+
* #%L
3+
* kotlin-atlassian-client-core-common
4+
* %%
5+
* Copyright (C) 2022 - 2023 linked-planet GmbH
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
@file:Suppress("CanBeParameter", "unused") // we want clients to access the additional information
21+
22+
package com.linkedplanet.kotlinatlassianclientcore.common.error
23+
24+
import arrow.core.Either
25+
import javax.validation.constraints.NotNull
26+
27+
open class AtlassianClientError(
28+
@field:NotNull val error: String,
29+
@field:NotNull val message: String,
30+
@field:NotNull val stacktrace: String = ""
31+
) {
32+
companion object
33+
}
34+
35+
fun <ERROR : AtlassianClientError, T> ERROR.asEither(): Either<ERROR, T> = Either.Left(this)
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,4 @@
1919
*/
2020
package com.linkedplanet.kotlinhttpclient.error
2121

22-
import com.linkedplanet.kotlinhttpclient.api.http.GSON
23-
24-
data class DomainErrorObject(
25-
val error: String,
26-
val message: String
27-
)
28-
29-
open class DomainError(val error: String, val message: String) {
30-
fun toJson(): String =
31-
GSON.toJson(DomainErrorObject(error, message))
32-
}
33-
34-
class HttpDomainError(val statusCode: Int, error: String, message: String) : DomainError(error, message)
35-
class ResponseError(message: String) : DomainError("Schnittstellen-Fehler", message)
22+
class HttpDomainError(val statusCode: Int, val error: String, val message: String)

kotlin-insight-client/kotlin-insight-client-api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@
3434
<version>2.2.2-atlassian-1</version>
3535
<scope>provided</scope>
3636
</dependency>
37+
<dependency>
38+
<groupId>com.linked-planet.client</groupId>
39+
<artifactId>kotlin-atlassian-client-core-common</artifactId>
40+
<version>${project.version}</version>
41+
</dependency>
3742
</dependencies>
3843
</project>

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/error/InsightClientError.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
package com.linkedplanet.kotlininsightclient.api.error
2323

2424
import arrow.core.Either
25+
import com.linkedplanet.kotlinatlassianclientcore.common.error.AtlassianClientError
26+
import com.linkedplanet.kotlinatlassianclientcore.common.error.asEither
2527
import com.linkedplanet.kotlininsightclient.api.model.InsightAttribute
2628
import com.linkedplanet.kotlininsightclient.api.model.InsightObjectId
2729
import com.linkedplanet.kotlininsightclient.api.model.InsightObjectTypeId
@@ -43,10 +45,10 @@ import io.swagger.v3.oas.annotations.media.Schema
4345

4446
@Suppress("unused")
4547
sealed class InsightClientError(
46-
val error: String,
47-
val message: String,
48-
val stacktrace: String = ""
49-
) {
48+
error: String,
49+
message: String,
50+
stacktrace: String = ""
51+
) : AtlassianClientError(error, message, stacktrace) {
5052

5153
companion object {
5254
private const val internalErrorString = "Jira/Insight hat ein internes Problem festgestellt"
@@ -58,7 +60,6 @@ sealed class InsightClientError(
5860

5961
}
6062
}
61-
fun <T> InsightClientError.asEither(): Either<InsightClientError, T> = Either.Left(this)
6263

6364
class InvalidArgumentInsightClientError(message: String) : InsightClientError("Unerwarteter Parameter", message)
6465

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/impl/AbstractInsightObjectRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.linkedplanet.kotlininsightclient.api.impl
2222
import arrow.core.Either
2323
import arrow.core.computations.either
2424
import arrow.core.rightIfNotNull
25+
import com.linkedplanet.kotlinatlassianclientcore.common.api.Page
2526
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
2627
import com.linkedplanet.kotlininsightclient.api.error.OtherNotFoundError
2728
import com.linkedplanet.kotlininsightclient.api.interfaces.InsightObjectRepository
@@ -30,7 +31,6 @@ import com.linkedplanet.kotlininsightclient.api.model.InsightAttribute
3031
import com.linkedplanet.kotlininsightclient.api.model.InsightObject
3132
import com.linkedplanet.kotlininsightclient.api.model.InsightObjectId
3233
import com.linkedplanet.kotlininsightclient.api.model.InsightObjectTypeId
33-
import com.linkedplanet.kotlininsightclient.api.model.Page
3434
import kotlin.math.ceil
3535

3636
abstract class AbstractInsightObjectRepository<DomainType> : InsightObjectRepository<DomainType> {

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/impl/AbstractNameMappedRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import arrow.core.Either
2323
import arrow.core.computations.either
2424
import arrow.core.right
2525
import arrow.core.sequenceEither
26+
import com.linkedplanet.kotlinatlassianclientcore.common.error.asEither
2627
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
2728
import com.linkedplanet.kotlininsightclient.api.error.InvalidArgumentInsightClientError
28-
import com.linkedplanet.kotlininsightclient.api.error.asEither
2929
import com.linkedplanet.kotlininsightclient.api.interfaces.InsightObjectTypeOperator
3030
import com.linkedplanet.kotlininsightclient.api.interfaces.InsightSchemaOperator
3131
import com.linkedplanet.kotlininsightclient.api.model.InsightAttribute.Companion.toReferences
@@ -169,7 +169,7 @@ abstract class AbstractNameMappedRepository<DomainType : Any>(
169169
is InsightAttribute.Select -> attribute.values// List<String>
170170
else -> InvalidArgumentInsightClientError(
171171
"kType.classifier ${kType.classifier} is not supported."
172-
).asEither<DomainType?>(
172+
).asEither<InsightClientError, DomainType?>(
173173
).bind()
174174
}
175175
}

kotlin-insight-client/kotlin-insight-client-api/src/main/kotlin/com/linkedplanet/kotlininsightclient/api/interfaces/InsightObjectRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package com.linkedplanet.kotlininsightclient.api.interfaces
2222
import arrow.core.Either
2323
import com.linkedplanet.kotlininsightclient.api.error.InsightClientError
2424
import com.linkedplanet.kotlininsightclient.api.model.InsightObjectId
25-
import com.linkedplanet.kotlininsightclient.api.model.Page
25+
import com.linkedplanet.kotlinatlassianclientcore.common.api.Page
2626

2727
/**
2828
* Generic Interface to CRUD one type of domain object, like a customer, to Insight.

0 commit comments

Comments
 (0)