-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/remove duplicates from postgis due to multiple subscriptions (#…
…213)
- Loading branch information
1 parent
ee2daf1
commit 44c283d
Showing
4 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/de/app/fivegla/business/SubscriptionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.app.fivegla.business; | ||
|
||
import de.app.fivegla.integration.fiware.SubscriptionIntegrationService; | ||
import de.app.fivegla.persistence.entity.Tenant; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class SubscriptionService { | ||
|
||
private final SubscriptionIntegrationService subscriptionIntegrationService; | ||
|
||
/** | ||
* Delete all existing subscriptions. | ||
* | ||
* @param tenant the tenant | ||
*/ | ||
public void deleteAllSubscriptions(Tenant tenant) { | ||
log.info("Deleting all subscriptions"); | ||
subscriptionIntegrationService.removeAll(tenant); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/de/app/fivegla/controller/tenant/SubscriptionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package de.app.fivegla.controller.tenant; | ||
|
||
import de.app.fivegla.api.Response; | ||
import de.app.fivegla.business.SubscriptionService; | ||
import de.app.fivegla.business.TenantService; | ||
import de.app.fivegla.config.security.marker.TenantCredentialApiAccess; | ||
import de.app.fivegla.controller.api.BaseMappings; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.security.Principal; | ||
|
||
/** | ||
* The SubscriptionController class handles subscription-related operations. | ||
*/ | ||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(BaseMappings.SUBSCRIPTION) | ||
public class SubscriptionController implements TenantCredentialApiAccess { | ||
|
||
private final TenantService tenantService; | ||
private final SubscriptionService subscriptionService; | ||
|
||
@Operation( | ||
operationId = "delete.all.subscriptions", | ||
description = "Delete all subscriptions.", | ||
tags = BaseMappings.SUBSCRIPTION | ||
) | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "All subscriptions have been deleted.", | ||
content = @Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(implementation = Response.class) | ||
) | ||
) | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "The request is invalid.", | ||
content = @Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(implementation = Response.class) | ||
) | ||
) | ||
@DeleteMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<? extends Response> deleteAllSubscriptions(Principal principal) { | ||
var tenant = validateTenant(tenantService, principal); | ||
subscriptionService.deleteAllSubscriptions(tenant); | ||
return ResponseEntity.ok().body(new Response()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters