-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
250b6b1
commit a6e39db
Showing
19 changed files
with
355 additions
and
73 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
src/main/java/org/folio/circulationbff/client/feign/SearchClient.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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
package org.folio.circulationbff.client.feign; | ||
|
||
import org.folio.circulationbff.domain.dto.ConsortiumItem; | ||
import org.folio.circulationbff.domain.dto.SearchInstances; | ||
import org.folio.spring.config.FeignClientConfiguration; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@FeignClient(name = "search", url = "search", configuration = FeignClientConfiguration.class) | ||
public interface SearchClient { | ||
|
||
@GetMapping("/instances") | ||
SearchInstances findInstances(@RequestParam String query, @RequestParam boolean expandAll); | ||
|
||
@GetMapping("/consortium/item/{itemId}") | ||
ConsortiumItem searchItem(@PathVariable("itemId") String itemId); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/folio/circulationbff/config/TenantConfig.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,21 @@ | ||
package org.folio.circulationbff.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import lombok.Data; | ||
|
||
@Configuration | ||
@Data | ||
@ConfigurationProperties("folio.tenant") | ||
public class TenantConfig { | ||
private String secureTenantId; | ||
|
||
@PostConstruct | ||
private void postConstruct() { | ||
if ("${SECURE_TENANT_ID}".equals(secureTenantId)) { | ||
secureTenantId = null; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/folio/circulationbff/domain/EcsTenantConfiguration.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,13 @@ | ||
package org.folio.circulationbff.domain; | ||
|
||
public record EcsTenantConfiguration(boolean isConsortiaEnabled, String currentTenantId, | ||
String centralTenantId, String secureTenantId) { | ||
|
||
public boolean isCurrentTenantCentral() { | ||
return isConsortiaEnabled && currentTenantId != null && currentTenantId.equals(centralTenantId); | ||
} | ||
|
||
public boolean isCurrentTenantSecure() { | ||
return isConsortiaEnabled && currentTenantId != null && currentTenantId.equals(secureTenantId); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/folio/circulationbff/service/EcsTenantConfigurationService.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,7 @@ | ||
package org.folio.circulationbff.service; | ||
|
||
import org.folio.circulationbff.domain.EcsTenantConfiguration; | ||
|
||
public interface EcsTenantConfigurationService { | ||
EcsTenantConfiguration getTenantConfiguration(); | ||
} |
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
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
4 changes: 4 additions & 0 deletions
4
src/main/java/org/folio/circulationbff/service/UserTenantsService.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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package org.folio.circulationbff.service; | ||
|
||
import org.folio.circulationbff.domain.dto.UserTenant; | ||
|
||
public interface UserTenantsService { | ||
String getCentralTenant(); | ||
boolean isCentralTenant(); | ||
UserTenant getFirstUserTenant(); | ||
boolean isCentralTenant(String tenantId); | ||
boolean isCentralTenant(UserTenant userTenant); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/org/folio/circulationbff/service/impl/EcsTenantConfigurationServiceImpl.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,34 @@ | ||
package org.folio.circulationbff.service.impl; | ||
|
||
import org.folio.circulationbff.config.TenantConfig; | ||
import org.folio.circulationbff.domain.EcsTenantConfiguration; | ||
import org.folio.circulationbff.domain.dto.UserTenant; | ||
import org.folio.circulationbff.service.EcsTenantConfigurationService; | ||
import org.folio.circulationbff.service.UserTenantsService; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class EcsTenantConfigurationServiceImpl | ||
implements EcsTenantConfigurationService { | ||
|
||
private final UserTenantsService userTenantsService; | ||
private final TenantConfig tenantConfig; | ||
|
||
@Override | ||
public EcsTenantConfiguration getTenantConfiguration() { | ||
UserTenant userTenant = userTenantsService.getFirstUserTenant(); | ||
|
||
EcsTenantConfiguration tenantConfiguration = userTenant == null | ||
? new EcsTenantConfiguration(false, null, null, null) | ||
: new EcsTenantConfiguration(true, userTenant.getTenantId(), userTenant.getCentralTenantId(), | ||
tenantConfig.getSecureTenantId()); | ||
|
||
log.info("getTenantConfiguration:: {}", tenantConfiguration); | ||
return tenantConfiguration; | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.