Skip to content
Snippets Groups Projects
Commit e38ffafd authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2737 fix user search url in RootController. Added user-url-template

parent 6b4bb9df
No related branches found
No related tags found
No related merge requests found
...@@ -38,8 +38,6 @@ public class RootController { ...@@ -38,8 +38,6 @@ public class RootController {
public BuildProperties buildProperties; public BuildProperties buildProperties;
@Autowired @Autowired
private CurrentUserService currentUserService; private CurrentUserService currentUserService;
@Value("${kop.user-manager.search-url-template}")
private String userSearchUrl;
@Value("${kop.user-manager.url:}") @Value("${kop.user-manager.url:}")
private String userManagerUrl; private String userManagerUrl;
...@@ -47,13 +45,17 @@ public class RootController { ...@@ -47,13 +45,17 @@ public class RootController {
@Value("${kop.user-manager.profile-template:}") @Value("${kop.user-manager.profile-template:}")
private String userProfileTemplate; private String userProfileTemplate;
@Value("${kop.user-manager.search-template:}")
private String userSearchTemplate;
@GetMapping @GetMapping
public EntityModel<RootResource> getRootResource() { public EntityModel<RootResource> getRootResource() {
var userManagerSearchUrl = userManagerUrl + userSearchTemplate;
var model = ModelBuilder.fromEntity(new RootResource()) var model = ModelBuilder.fromEntity(new RootResource())
.ifMatch(this::hasRole).addLinks( .ifMatch(this::hasRole).addLinks(
linkTo(RootController.class).withSelfRel(), linkTo(RootController.class).withSelfRel(),
linkTo(VorgangController.class).withRel(REL_VORGAENGE), linkTo(VorgangController.class).withRel(REL_VORGAENGE),
Link.of(userSearchUrl, REL_SEARCH_USER), Link.of(userManagerSearchUrl, REL_SEARCH_USER),
linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN), linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN),
buildVorgangListByPageLink(REL_SEARCH, Optional.empty())) buildVorgangListByPageLink(REL_SEARCH, Optional.empty()))
.ifMatch(this::hasVerwaltungRole).addLinks( .ifMatch(this::hasVerwaltungRole).addLinks(
......
...@@ -24,7 +24,7 @@ public class UrlProvider implements ApplicationContextAware { ...@@ -24,7 +24,7 @@ public class UrlProvider implements ApplicationContextAware {
Preconditions.checkNotNull(applicationContext, "ApplicationContext not initialized"); Preconditions.checkNotNull(applicationContext, "ApplicationContext not initialized");
var template = applicationContext.getEnvironment().getProperty(key); var template = applicationContext.getEnvironment().getProperty(key);
Preconditions.checkNotNull(template, "URl template is not configured, please add it to the application.yml using the key %s", key); Preconditions.checkNotNull(template, "Url template is not configured, please add it to the application.yml using the key %s", key);
return String.format(template, val); return String.format(template, val);
} }
......
...@@ -8,3 +8,4 @@ kop: ...@@ -8,3 +8,4 @@ kop:
url: classpath:files/LandesnetzInfo.html url: classpath:files/LandesnetzInfo.html
user-manager: user-manager:
url: http://localhost:9092 url: http://localhost:9092
user-url-template: http://localhost:9092/api/userProfiles/%s
\ No newline at end of file
...@@ -74,5 +74,5 @@ kop: ...@@ -74,5 +74,5 @@ kop:
postfachNachrichtAttachment: 3MB postfachNachrichtAttachment: 3MB
wiedervorlageAttachment: 40MB wiedervorlageAttachment: 40MB
user-manager: user-manager:
search-url-template: /api/userProfiles/?searchBy={searchBy} search-template: /api/userProfiles/?searchBy={searchBy}
profile-template: /api/userProfiles/%s profile-template: /api/userProfiles/%s
\ No newline at end of file
...@@ -33,6 +33,7 @@ import de.itvsh.goofy.common.user.UserTestFactory; ...@@ -33,6 +33,7 @@ import de.itvsh.goofy.common.user.UserTestFactory;
class RootControllerTest { class RootControllerTest {
private static final String SEARCH_BY = "/test?searchBy={searchBy}"; private static final String SEARCH_BY = "/test?searchBy={searchBy}";
private static final String USERMANAGER_URL = "http://localhost:8080";
private final String PATH = "/api"; private final String PATH = "/api";
...@@ -52,7 +53,8 @@ class RootControllerTest { ...@@ -52,7 +53,8 @@ class RootControllerTest {
when(currentUserService.getUserId()).thenReturn(UserTestFactory.ID); when(currentUserService.getUserId()).thenReturn(UserTestFactory.ID);
ReflectionTestUtils.setField(controller, "userSearchUrl", SEARCH_BY); ReflectionTestUtils.setField(controller, "userSearchTemplate", SEARCH_BY);
ReflectionTestUtils.setField(controller, "userManagerUrl", USERMANAGER_URL);
} }
@DisplayName("Links for user") @DisplayName("Links for user")
...@@ -96,7 +98,7 @@ class RootControllerTest { ...@@ -96,7 +98,7 @@ class RootControllerTest {
var model = controller.getRootResource(); var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_USER)).isPresent().get().extracting(Link::getHref) assertThat(model.getLink(RootController.REL_SEARCH_USER)).isPresent().get().extracting(Link::getHref)
.isEqualTo(SEARCH_BY); .isEqualTo(USERMANAGER_URL + SEARCH_BY);
} }
@Test @Test
......
...@@ -3,6 +3,11 @@ logging: ...@@ -3,6 +3,11 @@ logging:
ROOT: ERROR ROOT: ERROR
kop: kop:
user-manager:
url: http://localhost:9091
search-template: /api/userProfiles/?searchBy={searchBy}
profile-template: /api/userProfiles/%s
user-url-template: http://localhost:9091/api/userProfiles/%s
upload: upload:
maxFileSize: maxFileSize:
postfachNachrichtAttachment: 3MB postfachNachrichtAttachment: 3MB
...@@ -13,8 +13,10 @@ kop: ...@@ -13,8 +13,10 @@ kop:
secret: quatsch secret: quatsch
validity: 60000 validity: 60000
user-manager: user-manager:
url: http://localhost:9091
search-template: /api/userProfiles/?searchBy={searchBy}
profile-template: /api/userProfiles/%s
user-url-template: http://localhost:9091/api/userProfiles/%s user-url-template: http://localhost:9091/api/userProfiles/%s
search-url-template: http://localhost:9091/api/userProfiles/?searchBy={searchBy}
goofy: goofy:
production: false production: false
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment