Skip to content

Commit

Permalink
Merge pull request #309 from catenax-ng/fix/Gate_Sharing-State_Endpoi…
Browse files Browse the repository at this point in the history
…nts_lead_to_500

Fix(Gate): Fix error 500 when calling sharing api
  • Loading branch information
nicoprow authored Jun 27, 2023
2 parents 971769a + c2bd1aa commit 1a0e0a1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse
import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties
import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties
import org.eclipse.tractusx.bpdm.gate.containsDuplicates
import org.eclipse.tractusx.bpdm.gate.service.AddressService
import org.springframework.http.HttpStatus
Expand All @@ -38,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
class AddressController(
private val addressService: AddressService,
private val apiConfigProperties: ApiConfigProperties,
val gateSecurityConfigProperties: GateSecurityConfigProperties
private val apiConfigProperties: ApiConfigProperties
) : GateAddressApi {


Expand All @@ -61,7 +59,7 @@ class AddressController(

@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())")
override fun getAddressByExternalId(externalId: String): AddressGateInputResponse {
gateSecurityConfigProperties.getReadCompanyOutputDataAsRole()

return addressService.getAddressByExternalId(externalId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi
import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse
import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties
import org.eclipse.tractusx.bpdm.gate.service.ChangelogService
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.validation.annotation.Validated
Expand All @@ -34,8 +33,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@Validated
class ChangelogController(
private val changelogService: ChangelogService,
val gateSecurityConfigProperties: GateSecurityConfigProperties
private val changelogService: ChangelogService
) : GateChangelogApi {

@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())")
Expand All @@ -48,7 +46,6 @@ class ChangelogController(
@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())")
override fun getOutputChangelog(paginationRequest: PaginationRequest,
searchRequest: ChangeLogSearchRequest): PageChangeLogResponse<ChangelogResponse> {

return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime,OutputInputEnum.Output, paginationRequest.page, paginationRequest.size)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse
import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties
import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties
import org.eclipse.tractusx.bpdm.gate.containsDuplicates
import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService
import org.springframework.http.HttpStatus
Expand All @@ -38,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
class LegalEntityController(
val legalEntityService: LegalEntityService,
val apiConfigProperties: ApiConfigProperties,
val gateSecurityConfigProperties: GateSecurityConfigProperties
val apiConfigProperties: ApiConfigProperties
) : GateLegalEntityApi {
@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())")
override fun upsertLegalEntities(legalEntities: Collection<LegalEntityGateInputRequest>): ResponseEntity<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.gate.api.GateSharingStateApi
import org.eclipse.tractusx.bpdm.gate.api.model.LsaType
import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto
import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties
import org.eclipse.tractusx.bpdm.gate.service.SharingStateService
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.RestController

@RestController
class SharingStateController(
val sharingStateService: SharingStateService,
val gateSecurityConfigProperties: GateSecurityConfigProperties
val sharingStateService: SharingStateService
) : GateSharingStateApi {

private val logger = KotlinLogging.logger { }

@PreAuthorize("hasAuthority(gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())")
@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())")
override fun getSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection<String>?): PageResponse<SharingStateDto> {
return sharingStateService.findSharingStates(paginationRequest, lsaType, externalIds)
}

@PreAuthorize("hasAuthority(gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())")
@PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())")
override fun upsertSharingState(request: SharingStateDto) {
logger.info { "upsertSharingState() called with $request" }
sharingStateService.upsertSharingState(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse
import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties
import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties
import org.eclipse.tractusx.bpdm.gate.containsDuplicates
import org.eclipse.tractusx.bpdm.gate.service.SiteService
import org.springframework.http.HttpStatus
Expand All @@ -38,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
class SiteController(
val siteService: SiteService,
val apiConfigProperties: ApiConfigProperties,
val gateSecurityConfigProperties: GateSecurityConfigProperties
val apiConfigProperties: ApiConfigProperties
) : GateSiteApi {


Expand Down

0 comments on commit 1a0e0a1

Please sign in to comment.