diff --git a/pom.xml b/pom.xml index 0780e97..8c6e4c3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.example pfff - 4 + 5 jar pfff diff --git a/src/main/java/com/example/pfff/model/RecommendedList.java b/src/main/java/com/example/pfff/model/RecommendedList.java index f96c957..fdc8737 100644 --- a/src/main/java/com/example/pfff/model/RecommendedList.java +++ b/src/main/java/com/example/pfff/model/RecommendedList.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -16,8 +18,15 @@ public class RecommendedList { private String recommendationId; private List urns; - public RecommendedList(String recommendationId, List urns) { - this.recommendationId = recommendationId; + public RecommendedList(String host, String recommendationId, List urns) { + if (host != null && recommendationId != null) { + List components = Arrays.asList(host.split("\\.")); + Collections.reverse(components); + String domain = String.join(".", components.toArray(new String[0])); + this.recommendationId = domain + ":" + recommendationId; + } else { + this.recommendationId = recommendationId; + } this.urns = urns; } diff --git a/src/main/java/com/example/pfff/service/RecommendationService.java b/src/main/java/com/example/pfff/service/RecommendationService.java index 421a6c5..d4625a1 100644 --- a/src/main/java/com/example/pfff/service/RecommendationService.java +++ b/src/main/java/com/example/pfff/service/RecommendationService.java @@ -32,7 +32,7 @@ public RecommendedList getRecommendedUrns(String purpose, String urn, boolean st System.out.println(url.toUriString()); RecommendationResult recommendationResult = restTemplate.exchange(url.toUriString(), HttpMethod.GET, null, RecommendationResult.class).getBody(); - return new RecommendedList(recommendationResult.getRecommendationId(), recommendationResult.getUrns()); + return new RecommendedList(url.getHost(), recommendationResult.getRecommendationId(), recommendationResult.getUrns()); } else { return new RecommendedList(); diff --git a/src/test/java/com/example/pfff/controller/RecommendationServiceTests.java b/src/test/java/com/example/pfff/controller/RecommendationServiceTests.java index fb9dae0..d18ba13 100644 --- a/src/test/java/com/example/pfff/controller/RecommendationServiceTests.java +++ b/src/test/java/com/example/pfff/controller/RecommendationServiceTests.java @@ -26,6 +26,7 @@ public void getRecommendedUrnsContinuousplaybackRTSTest() { RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone); Assert.assertNotNull(recommendedList.getRecommendationId()); + Assert.assertTrue(recommendedList.getRecommendationId().startsWith("io.ebu.peach:")); Assert.assertNotNull(recommendedList.getUrns()); } @@ -37,6 +38,7 @@ public void getRecommendedUrnsContinuousplaybackStandaloneRTSTest() { RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone); Assert.assertNotNull(recommendedList.getRecommendationId()); + Assert.assertTrue(recommendedList.getRecommendationId().startsWith("io.ebu.peach:")); Assert.assertNotNull(recommendedList.getUrns()); }