Skip to content

Commit 00d2aeb

Browse files
committed
UY-971 add system theme information to service editors
without it images from system theme were not resolved
1 parent ccfb778 commit 00d2aeb

File tree

10 files changed

+54
-70
lines changed

10 files changed

+54
-70
lines changed

oauth/src/main/java/pl/edu/icm/unity/oauth/as/console/OAuthServiceEditor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public ServiceEditorComponent getEditor(ServiceDefinition endpoint)
122122
allAttributes);
123123

124124
editor = new OAuthServiceEditorComponent(msg, generalTab, clientsTab, usersTab, webAuthTab,
125-
fileStorageService, imageService, endpoint, allGroups, systemClientsSupplier);
125+
fileStorageService, imageService, endpoint, allGroups, systemClientsSupplier,
126+
serverConfig.getValue(UnityServerConfiguration.THEME));
126127
return editor;
127128
}
128129

oauth/src/main/java/pl/edu/icm/unity/oauth/as/console/OAuthServiceEditorComponent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class OAuthServiceEditorComponent extends ServiceEditorBase
5353
OAuthEditorClientsTab clientsTab, IdpEditorUsersTab usersTab,
5454
WebServiceAuthenticationTab webAuthTab, FileStorageService fileStorageService,
5555
ImageAccessService imageAccessService, ServiceDefinition toEdit, List<Group> allGroups,
56-
Function<String, List<OAuthClient>> systemClientsSupplier)
56+
Function<String, List<OAuthClient>> systemClientsSupplier,
57+
String systemTheme)
5758
{
5859
super(msg);
5960
this.fileStorageService = fileStorageService;
@@ -118,7 +119,7 @@ class OAuthServiceEditorComponent extends ServiceEditorBase
118119
if (webAuthzService != null && webAuthzService.getConfiguration() != null)
119120
{
120121
oauthConfig.fromProperties(webAuthzService.getConfiguration(), allGroups);
121-
webConfig.fromProperties(webAuthzService.getConfiguration(), msg, imageAccessService);
122+
webConfig.fromProperties(webAuthzService.getConfiguration(), msg, imageAccessService, systemTheme);
122123
}
123124
clientsBean.setClients(cloneClients(
124125
systemClientsSupplier.apply(oauthConfig.getClientGroup().group.toString())));

saml/src/main/java/pl/edu/icm/unity/saml/idp/console/SAMLServiceEditor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public ServiceEditorComponent getEditor(ServiceDefinition endpoint)
121121
type.getSupportedBinding(), msg.getMessage("IdpServiceEditorBase.authentication"));
122122

123123
editor = new SAMLServiceEditorComponent(msg, samlEditorGeneralTab, clientsTab, usersTab, webServiceAuthenticationTab,
124-
type, pkiMan, uriAccessService, imageAccessService, fileStorageService, endpoint, allGroups);
124+
type, pkiMan, uriAccessService, imageAccessService, fileStorageService, endpoint, allGroups,
125+
serverConfig.getValue(UnityServerConfiguration.THEME));
125126
return editor;
126127
}
127128

saml/src/main/java/pl/edu/icm/unity/saml/idp/console/SAMLServiceEditorComponent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class SAMLServiceEditorComponent extends ServiceEditorBase
4747
URIAccessService uriAccessService,
4848
ImageAccessService imageAccessService,
4949
FileStorageService fileStorageService,
50-
ServiceDefinition toEdit, List<Group> allGroups)
50+
ServiceDefinition toEdit, List<Group> allGroups,
51+
String systemTheme)
5152
{
5253
super(msg);
5354
this.fileStorageService = fileStorageService;
@@ -77,7 +78,7 @@ class SAMLServiceEditorComponent extends ServiceEditorBase
7778
serviceBean = (DefaultServiceDefinition) toEdit;
7879
if (serviceBean.getConfiguration() != null)
7980
{
80-
webConfig.fromProperties(serviceBean.getConfiguration(), msg, imageAccessService);
81+
webConfig.fromProperties(serviceBean.getConfiguration(), msg, imageAccessService, systemTheme);
8182
samlConfig.fromProperties(serviceBean.getConfiguration(), msg, uriAccessService,
8283
imageAccessService, pkiMan, allGroups);
8384
}

web-admin/src/main/java/pl/edu/icm/unity/home/console/HomeServiceEditorComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class HomeServiceEditorComponent extends ServiceEditorBase
5858
if (editMode && toEdit.getConfiguration() != null)
5959
{
6060
config.fromProperties(toEdit.getConfiguration(), msg, extraTab, allGroups);
61-
webConfig.fromProperties(toEdit.getConfiguration(), msg, imageAccessService);
61+
webConfig.fromProperties(toEdit.getConfiguration(), msg, imageAccessService,
62+
serverConfig.getValue(UnityServerConfiguration.THEME));
6263
}
6364
homeBinder.setBean(config);
6465
webConfigBinder.setBean(webConfig);

web-common/src/main/java/pl/edu/icm/unity/webui/VaadinEndpointProperties.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,14 @@ public Properties getProperties()
238238

239239
public String getEffectiveMainTheme()
240240
{
241-
return getConfiguredTheme(VaadinEndpointProperties.THEME) != null
242-
? getConfiguredTheme(VaadinEndpointProperties.THEME)
243-
: VaadinEndpoint.DEFAULT_THEME;
241+
String configuredTheme = getConfiguredTheme(VaadinEndpointProperties.THEME);
242+
return configuredTheme != null ? configuredTheme : VaadinEndpoint.DEFAULT_THEME;
244243
}
245244

246245
public String getEffectiveAuthenticationTheme()
247246
{
248-
return getConfiguredTheme(VaadinEndpointProperties.AUTHN_THEME) != null
249-
? getConfiguredTheme(VaadinEndpointProperties.AUTHN_THEME)
250-
: VaadinEndpoint.DEFAULT_THEME;
247+
String configuredTheme = getConfiguredTheme(VaadinEndpointProperties.AUTHN_THEME);
248+
return configuredTheme != null ? configuredTheme : VaadinEndpoint.DEFAULT_THEME;
251249
}
252250

253251
public EndpointRegistrationConfiguration getRegistrationConfiguration()

web-common/src/main/java/pl/edu/icm/unity/webui/console/services/WebServiceEditorComponent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ public WebServiceEditorComponent(UnityMessageSource msg, GeneralTab generalTab,
5151
{
5252
service = (DefaultServiceDefinition) toEdit;
5353
if (service.getConfiguration() != null)
54-
{
55-
webConfig.fromProperties(service.getConfiguration(), msg, imageAccessService);
56-
}
54+
webConfig.fromProperties(service.getConfiguration(), msg, imageAccessService, null);
5755
}
5856
serviceBinder.setBean(service);
5957
webConfigBinder.setBean(webConfig);

web-common/src/main/java/pl/edu/icm/unity/webui/console/services/authnlayout/ServiceWebConfiguration.java

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package pl.edu.icm.unity.webui.console.services.authnlayout;
77

8+
import static pl.edu.icm.unity.webui.VaadinEndpointProperties.PREFIX;
9+
810
import java.io.IOException;
911
import java.io.StringReader;
1012
import java.util.ArrayList;
@@ -85,78 +87,61 @@ public Properties toProperties(UnityMessageSource msg, FileStorageService fileSt
8587
{
8688
Properties raw = new Properties();
8789

88-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_SHOW_SEARCH,
89-
String.valueOf(showSearch));
90-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_ADD_ALL,
91-
String.valueOf(addAllAuthnOptions));
92-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_SHOW_CANCEL,
93-
String.valueOf(showCancel));
94-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_SHOW_LAST_OPTION_ONLY,
95-
String.valueOf(showLastUsedAuthnOption));
96-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTO_LOGIN,
97-
String.valueOf(autoLogin));
98-
99-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.ENABLE_REGISTRATION,
100-
String.valueOf(enableRegistration));
101-
102-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.SHOW_REGISTRATION_FORMS_IN_HEADER,
90+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_SHOW_SEARCH, String.valueOf(showSearch));
91+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_ADD_ALL, String.valueOf(addAllAuthnOptions));
92+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_SHOW_CANCEL, String.valueOf(showCancel));
93+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_SHOW_LAST_OPTION_ONLY, String.valueOf(showLastUsedAuthnOption));
94+
raw.put(PREFIX + VaadinEndpointProperties.AUTO_LOGIN, String.valueOf(autoLogin));
95+
96+
raw.put(PREFIX + VaadinEndpointProperties.ENABLE_REGISTRATION, String.valueOf(enableRegistration));
97+
98+
raw.put(PREFIX + VaadinEndpointProperties.SHOW_REGISTRATION_FORMS_IN_HEADER,
10399
String.valueOf(showRegistrationFormsInHeader));
104100

105-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.PRODUCTION_MODE,
106-
String.valueOf(productionMode));
101+
raw.put(PREFIX + VaadinEndpointProperties.PRODUCTION_MODE, String.valueOf(productionMode));
107102
if (webContentDir != null)
108-
{
109-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.WEB_CONTENT_PATH,
110-
webContentDir);
111-
}
103+
raw.put(PREFIX + VaadinEndpointProperties.WEB_CONTENT_PATH, webContentDir);
112104

113-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.TEMPLATE, template);
105+
raw.put(PREFIX + VaadinEndpointProperties.TEMPLATE, template);
114106

115-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.CRED_RESET_COMPACT,
116-
String.valueOf(compactCredentialReset));
107+
raw.put(PREFIX + VaadinEndpointProperties.CRED_RESET_COMPACT, String.valueOf(compactCredentialReset));
117108

118109
if (externalRegistrationURL != null)
119-
{
120-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.EXTERNAL_REGISTRATION_URL,
121-
externalRegistrationURL);
122-
}
110+
raw.put(PREFIX + VaadinEndpointProperties.EXTERNAL_REGISTRATION_URL, externalRegistrationURL);
111+
123112
if (registrationForms != null && !registrationForms.isEmpty())
124113
{
125-
registrationForms.forEach(c -> raw.put(VaadinEndpointProperties.PREFIX
114+
registrationForms.forEach(c -> raw.put(PREFIX
126115
+ VaadinEndpointProperties.ENABLED_REGISTRATION_FORMS
127116
+ (registrationForms.indexOf(c) + 1), c));
128117
}
129118

130119
if (title != null)
131-
{
132-
title.toProperties(raw, VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_TITLE,
133-
msg);
134-
}
120+
title.toProperties(raw, PREFIX + VaadinEndpointProperties.AUTHN_TITLE, msg);
135121

136122
if (logo != null)
137123
{
138124
FileFieldUtils.saveInProperties(getLogo(),
139-
VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_LOGO, raw,
125+
PREFIX + VaadinEndpointProperties.AUTHN_LOGO, raw,
140126
fileStorageService, StandardOwner.SERVICE.toString(), serviceName);
141127
} else
142128
{
143-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_LOGO, "");
129+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_LOGO, "");
144130
}
145131

146132
if (defaultMainTheme != null)
147-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.THEME, defaultMainTheme);
133+
raw.put(PREFIX + VaadinEndpointProperties.THEME, defaultMainTheme);
148134
if (defaultAuthnTheme != null)
149-
raw.put(VaadinEndpointProperties.PREFIX + VaadinEndpointProperties.AUTHN_THEME, defaultAuthnTheme);
150-
135+
raw.put(PREFIX + VaadinEndpointProperties.AUTHN_THEME, defaultAuthnTheme);
151136
AuthnLayoutPropertiesParser parser = new AuthnLayoutPropertiesParser(msg);
152137
raw.putAll(parser.toProperties(authenticationLayoutConfiguration));
153-
raw.putAll(parser.returningUserColumnElementToProperties(
154-
retUserLayoutConfiguration));
138+
raw.putAll(parser.returningUserColumnElementToProperties(retUserLayoutConfiguration));
155139

156140
return raw;
157141
}
158142

159-
public void fromProperties(String vaadinProperties, UnityMessageSource msg, ImageAccessService imageAccessService)
143+
public void fromProperties(String vaadinProperties, UnityMessageSource msg, ImageAccessService imageAccessService,
144+
String systemDefaultTheme)
160145
{
161146
Properties raw = new Properties();
162147
try
@@ -168,19 +153,20 @@ public void fromProperties(String vaadinProperties, UnityMessageSource msg, Imag
168153
}
169154

170155
VaadinEndpointProperties vProperties = new VaadinEndpointProperties(raw);
171-
fromProperties(vProperties, msg, imageAccessService);
156+
fromProperties(vProperties, msg, imageAccessService, systemDefaultTheme);
172157
}
173158

174-
public void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessageSource msg,
175-
ImageAccessService imageAccessService)
159+
private void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessageSource msg,
160+
ImageAccessService imageAccessService, String systemDefaultTheme)
176161
{
177-
178-
162+
//this is set for effective endpoint configuration at endpoint loading - we copy this here
163+
//to have consistent setup. However this property is not persisted.
164+
if (systemDefaultTheme != null)
165+
vaadinProperties.setProperty(VaadinEndpointProperties.DEF_THEME, systemDefaultTheme);
179166

180167
if (vaadinProperties.isSet(VaadinEndpointProperties.WEB_CONTENT_PATH))
181-
{
182168
webContentDir = vaadinProperties.getValue(VaadinEndpointProperties.WEB_CONTENT_PATH);
183-
}
169+
184170
productionMode = vaadinProperties.getBooleanValue(VaadinEndpointProperties.PRODUCTION_MODE);
185171
template = vaadinProperties.getValue(VaadinEndpointProperties.TEMPLATE);
186172
compactCredentialReset = vaadinProperties.getBooleanValue(VaadinEndpointProperties.CRED_RESET_COMPACT);
@@ -201,6 +187,7 @@ public void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessa
201187
.getListOfValues(VaadinEndpointProperties.ENABLED_REGISTRATION_FORMS);
202188

203189
String logoUri = vaadinProperties.getValue(VaadinEndpointProperties.AUTHN_LOGO);
190+
204191
logo = imageAccessService.getEditableImageResourceFromUriOrNull(logoUri, Optional
205192
.of(vaadinProperties.getEffectiveAuthenticationTheme())).orElse(null);
206193

@@ -214,13 +201,9 @@ public void fromProperties(VaadinEndpointProperties vaadinProperties, UnityMessa
214201
retUserLayoutConfiguration = parser.getReturingUserColumnElementsFromProperties(vaadinProperties);
215202

216203
if (vaadinProperties.isSet(VaadinEndpointProperties.THEME))
217-
{
218204
defaultMainTheme = vaadinProperties.getValue(VaadinEndpointProperties.THEME);
219-
}
220205
if (vaadinProperties.isSet(VaadinEndpointProperties.AUTHN_THEME))
221-
{
222206
defaultAuthnTheme = vaadinProperties.getValue(VaadinEndpointProperties.AUTHN_THEME);
223-
}
224207
}
225208

226209
public boolean isShowSearch()

web-common/src/test/java/pl/edu/icm/unity/webui/common/file/ImageAccessServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void shouldReturnNullWhenUriIsCorrupted()
4444
}
4545

4646
@Test
47-
public void shouldReturnRemoteResource()
47+
public void shouldReturnRemoteResourceIntact()
4848
{
4949
ImageAccessService imageAccessService = new ImageAccessService(uriAccessService);
5050
assertThat(imageAccessService.getEditableImageResourceFromUriOrNull("http:ok", Optional.empty())

web-common/src/test/java/pl/edu/icm/unity/webui/console/services/authnlayout/TestServiceWebConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private Properties parseAndBackAll(Properties sourceCfg, String defTheme)
188188
{
189189
ServiceWebConfiguration processor = new ServiceWebConfiguration(defTheme);
190190

191-
processor.fromProperties(ConfigurationComparator.getAsString(sourceCfg), msg, imageAccessSrv);
191+
processor.fromProperties(ConfigurationComparator.getAsString(sourceCfg), msg, imageAccessSrv, "systemTheme");
192192
return processor.toProperties(msg, fileStorageSrv, "authName");
193193
}
194194

0 commit comments

Comments
 (0)