Skip to content

Commit b55ad5a

Browse files
committed
WIP - version 1.2.1
1 parent f564948 commit b55ad5a

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

RELEASE_NOTE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
**Release Notes** of the *Billing Proxy* software:
44

5+
### <code>1.2.1</code> :calendar: 09/06/2025 (WIP)
6+
**Improvements**
7+
* Update of the `basePath` for building TMForum API URLs with or without **envoy** usage.
8+
9+
510
### <code>1.2.0</code> :calendar: 03/06/2025
611
**Improvements**
712
* Set of `[2.1.0, 2.2.0)` version of `Brokerage Utils`.

src/main/java/it/eng/dome/billing/proxy/tmf/TmfApiFactory.java

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import org.springframework.stereotype.Component;
1111
import org.springframework.util.Assert;
1212

13+
import it.eng.dome.brokerage.billing.utils.UrlPathUtils;
14+
1315
@Component(value = "tmfApiFactory")
1416
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
1517
public final class TmfApiFactory implements InitializingBean {
@@ -38,14 +40,15 @@ public final class TmfApiFactory implements InitializingBean {
3840

3941
public it.eng.dome.tmforum.tmf620.v4.ApiClient getTMF620CatalogApiClient() {
4042
final it.eng.dome.tmforum.tmf620.v4.ApiClient apiClient = it.eng.dome.tmforum.tmf620.v4.Configuration.getDefaultApiClient();
41-
if (tmfEnvoy) {
42-
// usage of envoyProxy to access on TMForum APIs
43-
apiClient.setBasePath(tmfEndpoint + "/" + tmf620CatalogPath);
44-
}else {
45-
// use direct access on specific TMForum APIs software
46-
apiClient.setBasePath(tmfEndpoint + TMF_ENDPOINT_CONCAT_PATH + "product-catalog" + "." + tmfNamespace + "." + tmfPostfix + ":" + tmfPort + "/" + tmf620CatalogPath);
47-
}
43+
44+
String basePath = tmfEndpoint;
45+
if (!tmfEnvoy) { // no envoy specific path
46+
basePath += TMF_ENDPOINT_CONCAT_PATH + "product-catalog" + "." + tmfNamespace + "." + tmfPostfix + ":" + tmfPort;
47+
}
48+
49+
apiClient.setBasePath(basePath + "/" + tmf620CatalogPath);
4850
log.debug("Invoke Catalog API at endpoint: " + apiClient.getBasePath());
51+
4952
return apiClient;
5053
}
5154

@@ -63,29 +66,13 @@ public void afterPropertiesSet() throws Exception {
6366
Assert.state(!StringUtils.isBlank(tmf620CatalogPath), "Billing Scheduler not properly configured. The tmf620_catalog_path property has no value.");
6467

6568
if (tmfEndpoint.endsWith("/")) {
66-
tmfEndpoint = removeFinalSlash(tmfEndpoint);
69+
tmfEndpoint = UrlPathUtils.removeFinalSlash(tmfEndpoint);
6770
}
6871

6972
if (tmf620CatalogPath.startsWith("/")) {
70-
tmf620CatalogPath = removeInitialSlash(tmf620CatalogPath);
73+
tmf620CatalogPath = UrlPathUtils.removeInitialSlash(tmf620CatalogPath);
7174
}
7275

7376
}
74-
75-
private String removeFinalSlash(String s) {
76-
String path = s;
77-
while (path.endsWith("/"))
78-
path = path.substring(0, path.length() - 1);
79-
80-
return path;
81-
}
82-
83-
private String removeInitialSlash(String s) {
84-
String path = s;
85-
while (path.startsWith("/")) {
86-
path = path.substring(1);
87-
}
88-
return path;
89-
}
9077

9178
}

0 commit comments

Comments
 (0)