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

TODOs für UserProfile / ModelBuilder

parent 1780ef7a
No related branches found
No related tags found
No related merge requests found
...@@ -159,7 +159,7 @@ public class ModelBuilder<T> { ...@@ -159,7 +159,7 @@ public class ModelBuilder<T> {
private List<Field> getFields(Class<? extends Annotation> annotationClass) { private List<Field> getFields(Class<? extends Annotation> annotationClass) {
var fields = Optional.ofNullable(ANNOTATED_FIELDS_BY_ANNOTATION.get(getEntity().getClass())) var fields = Optional.ofNullable(ANNOTATED_FIELDS_BY_ANNOTATION.get(getEntity().getClass()))
.map(fieldsByAnnotation -> fieldsByAnnotation.get(annotationClass)) .map(fieldsByAnnotation -> fieldsByAnnotation.get(annotationClass))
.orElseGet(() -> Collections.emptyList()); .orElseGet(Collections::emptyList);
if (CollectionUtils.isEmpty(fields)) { if (CollectionUtils.isEmpty(fields)) {
fields = FieldUtils.getFieldsListWithAnnotation(getEntity().getClass(), annotationClass); fields = FieldUtils.getFieldsListWithAnnotation(getEntity().getClass(), annotationClass);
......
...@@ -32,7 +32,10 @@ import com.google.common.base.Preconditions; ...@@ -32,7 +32,10 @@ import com.google.common.base.Preconditions;
@Component @Component
public class UserProfileUrlProvider implements ApplicationContextAware { public class UserProfileUrlProvider implements ApplicationContextAware {
// TODO auf javax.validation umstellen
private static final String ERROR_MESSAGE = "Key %s missing, please add it to the application.yml"; private static final String ERROR_MESSAGE = "Key %s missing, please add it to the application.yml";
// TODO applicationContext darf nicht static abgelegt werden - es sollte möglich
// sein, dass eine andere Konfiguration in der jvm läuft.
private static ApplicationContext applicationContext; private static ApplicationContext applicationContext;
static final String URL_ROOT_KEY = "kop.user-manager.url"; static final String URL_ROOT_KEY = "kop.user-manager.url";
static final String USER_PROFILES_TEMPLATE_KEY = "kop.user-manager.profile-template"; static final String USER_PROFILES_TEMPLATE_KEY = "kop.user-manager.profile-template";
...@@ -47,14 +50,17 @@ public class UserProfileUrlProvider implements ApplicationContextAware { ...@@ -47,14 +50,17 @@ public class UserProfileUrlProvider implements ApplicationContextAware {
} }
public static String getUrl(Object val) { public static String getUrl(Object val) {
// TODO Abhängingkeit zu com.google.common ausbauen
Preconditions.checkNotNull(applicationContext, "ApplicationContext not initialized"); Preconditions.checkNotNull(applicationContext, "ApplicationContext not initialized");
// TODO parameter lieber injezieren und validation verwenden
var rootUrl = applicationContext.getEnvironment().getProperty(URL_ROOT_KEY); var rootUrl = applicationContext.getEnvironment().getProperty(URL_ROOT_KEY);
Preconditions.checkNotNull(rootUrl, ERROR_MESSAGE, URL_ROOT_KEY); Preconditions.checkNotNull(rootUrl, ERROR_MESSAGE, URL_ROOT_KEY);
var template = applicationContext.getEnvironment().getProperty(USER_PROFILES_TEMPLATE_KEY); var template = applicationContext.getEnvironment().getProperty(USER_PROFILES_TEMPLATE_KEY);
Preconditions.checkNotNull(template, ERROR_MESSAGE, USER_PROFILES_TEMPLATE_KEY); Preconditions.checkNotNull(template, ERROR_MESSAGE, USER_PROFILES_TEMPLATE_KEY);
// TODO UriComponent Builder verwenden
var profilesUrl = rootUrl + template; var profilesUrl = rootUrl + template;
return String.format(profilesUrl, val); return String.format(profilesUrl, val);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment