Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/simplify error handling #1264

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import com.egm.stellio.shared.util.getAuthzContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.getSubFromSecurityContext
import com.egm.stellio.shared.util.parseRepresentations
import com.egm.stellio.shared.util.replaceDefaultContextToAuthzContext
import com.egm.stellio.shared.util.toErrorResponse
import com.egm.stellio.shared.web.BaseHandler
import kotlinx.coroutines.reactive.awaitFirst
import org.springframework.http.HttpHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.egm.stellio.shared.util.getContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.getSubFromSecurityContext
import com.egm.stellio.shared.util.parsePaginationParameters
import com.egm.stellio.shared.util.prepareGetSuccessResponseHeaders
import com.egm.stellio.shared.util.toErrorResponse
import com.egm.stellio.shared.web.BaseHandler
import kotlinx.coroutines.reactive.awaitFirst
import org.springframework.http.HttpHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.egm.stellio.shared.util.decode
import com.egm.stellio.shared.util.getApplicableMediaType
import com.egm.stellio.shared.util.getContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.prepareGetSuccessResponseHeaders
import com.egm.stellio.shared.util.toErrorResponse
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.egm.stellio.shared.util.decode
import com.egm.stellio.shared.util.getApplicableMediaType
import com.egm.stellio.shared.util.getContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.prepareGetSuccessResponseHeaders
import com.egm.stellio.shared.util.toErrorResponse
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import com.egm.stellio.shared.util.missingPathErrorResponse
import com.egm.stellio.shared.util.parseRepresentations
import com.egm.stellio.shared.util.parseTimeParameter
import com.egm.stellio.shared.util.prepareGetSuccessResponseHeaders
import com.egm.stellio.shared.util.toErrorResponse
import com.egm.stellio.shared.util.toUri
import com.egm.stellio.shared.web.BaseHandler
import org.springframework.http.HttpHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import com.egm.stellio.shared.util.getContextFromLinkHeader
import com.egm.stellio.shared.util.getContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.getSubFromSecurityContext
import com.egm.stellio.shared.util.parseRepresentations
import com.egm.stellio.shared.util.toErrorResponse
import com.egm.stellio.shared.util.toListOfUri
import kotlinx.coroutines.reactive.awaitFirst
import org.springframework.http.HttpHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.egm.stellio.shared.util.getSubFromSecurityContext
import com.egm.stellio.shared.util.invalidTemporalInstanceMessage
import com.egm.stellio.shared.util.missingPathErrorResponse
import com.egm.stellio.shared.util.parseRepresentations
import com.egm.stellio.shared.util.toErrorResponse
import com.egm.stellio.shared.util.toUri
import com.egm.stellio.shared.web.BaseHandler
import org.springframework.http.HttpHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.egm.stellio.shared.util.JsonLdUtils.compactEntities
import com.egm.stellio.shared.util.getApplicableMediaType
import com.egm.stellio.shared.util.getContextFromLinkHeaderOrDefault
import com.egm.stellio.shared.util.getSubFromSecurityContext
import com.egm.stellio.shared.util.toErrorResponse
import kotlinx.coroutines.reactive.awaitFirst
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.egm.stellio.search.common.config.SearchProperties
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.AccessDeniedException
import com.egm.stellio.shared.model.BadRequestDataException
import com.egm.stellio.shared.model.DEFAULT_DETAIL
import com.egm.stellio.shared.model.ExpandedEntity
import com.egm.stellio.shared.model.ExpandedTerm
import com.egm.stellio.shared.model.NgsiLdPropertyInstance
Expand Down Expand Up @@ -357,9 +358,9 @@ class EntityAccessControlHandlerTests {
.expectBody().json(
"""
{
"detail": "User forbidden to remove ownership of entity",
"title": "User forbidden to remove ownership of entity",
"type": "https://uri.etsi.org/ngsi-ld/errors/AccessDenied",
"title": "The request tried to access an unauthorized resource"
"detail": "$DEFAULT_DETAIL"
}
""".trimIndent()
)
Expand Down Expand Up @@ -400,9 +401,9 @@ class EntityAccessControlHandlerTests {
.expectBody().json(
"""
{
"detail": "No right found for urn:ngsi-ld:User:0123 on urn:ngsi-ld:Entity:entityId1",
"detail": "$DEFAULT_DETAIL",
"type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound",
"title": "The referred resource has not been found"
"title": "No right found for urn:ngsi-ld:User:0123 on urn:ngsi-ld:Entity:entityId1"
}
""".trimIndent()
)
Expand Down Expand Up @@ -503,9 +504,9 @@ class EntityAccessControlHandlerTests {
.expectBody().json(
"""
{
"detail": "$expectedAttr is not authorized property name",
"title": "$expectedAttr is not authorized property name",
"type":"https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
"title":"The request includes input data which does not meet the requirements of the operation"
"detail":"$DEFAULT_DETAIL"
}
""".trimIndent()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.egm.stellio.search.discovery.model.AttributeType
import com.egm.stellio.search.discovery.model.AttributeTypeInfo
import com.egm.stellio.search.discovery.service.AttributeService
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.DEFAULT_DETAIL
import com.egm.stellio.shared.model.ResourceNotFoundException
import com.egm.stellio.shared.util.APIC_COMPOUND_CONTEXTS
import com.egm.stellio.shared.util.APIC_HEADER_LINK
Expand Down Expand Up @@ -257,8 +258,8 @@ class AttributeHandlerTests {
"""
{
"type":"https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound",
"title":"The referred resource has not been found",
"detail":"${attributeNotFoundMessage(OUTGOING_PROPERTY)}"
"title":"${attributeNotFoundMessage(OUTGOING_PROPERTY)}",
"detail":"$DEFAULT_DETAIL"
}
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.egm.stellio.search.discovery.model.EntityTypeInfo
import com.egm.stellio.search.discovery.model.EntityTypeList
import com.egm.stellio.search.discovery.service.EntityTypeService
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.DEFAULT_DETAIL
import com.egm.stellio.shared.model.ResourceNotFoundException
import com.egm.stellio.shared.util.APIC_COMPOUND_CONTEXTS
import com.egm.stellio.shared.util.APIC_HEADER_LINK
Expand Down Expand Up @@ -309,9 +310,9 @@ class EntityTypeHandlerTests {
.expectBody().json(
"""
{
"type":"https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound",
"title":"The referred resource has not been found",
"detail":"${typeNotFoundMessage(BEEHIVE_TYPE)}"
"type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound",
"title": "${typeNotFoundMessage(BEEHIVE_TYPE)}",
"detail": "$DEFAULT_DETAIL"
}
"""
)
Expand Down
Loading
Loading