Skip to content

Commit 888f3e7

Browse files
committed
fix(api): send both read and write properties
Send both read and read-write properties on `/configurations/container/{}` endpoint with existing `changeable` parameter. Signed-off-by: Gaurav Mishra <[email protected]>
1 parent 8ce3bbc commit 888f3e7

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/configuration/SW360ConfigurationsController.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,18 @@ public ResponseEntity<Map<String, String>> getConfigForContainer(
189189
allowableValues = {"SW360_CONFIGURATION", "UI_CONFIGURATION"}
190190
)
191191
)
192-
@PathVariable(name = "configFor") ConfigFor configFor
192+
@PathVariable(name = "configFor") ConfigFor configFor,
193+
@RequestParam(required = false, name = "changeable") Boolean changeable
193194
) throws TException {
194-
return ResponseEntity.ok(sw360ConfigurationsService.getConfigForContainer(configFor));
195+
if (changeable == null) {
196+
return ResponseEntity.ok(sw360ConfigurationsService.getConfigForContainer(configFor));
197+
}
198+
199+
if (changeable) {
200+
return ResponseEntity.ok(sw360ConfigurationsService.getSW360ConfigFromDb(configFor));
201+
}
202+
203+
return ResponseEntity.ok(sw360ConfigurationsService.getSW360ConfigFromProperties());
195204
}
196205

197206
@PreAuthorize("hasAuthority('ADMIN')")
@@ -268,6 +277,11 @@ public ResponseEntity<?> updateSW360ConfigurationsForContainer(
268277
private void updateConfigInService(
269278
ConfigFor configFor, Map<String, String> configuration, User sw360User
270279
) throws TException {
280+
// Don't update readonly keys silently
281+
Map<String, String> readonlyConfigs = sw360ConfigurationsService.getSW360ConfigFromProperties();
282+
for (String key : readonlyConfigs.keySet()) {
283+
configuration.remove(key);
284+
}
271285
try {
272286
RequestStatus updateStatus;
273287
if (configFor == null) {

rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/configuration/SW360ConfigurationsService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ public RequestStatus updateSW360Configs(Map<String, String> updatedConfig, User
6767
}
6868

6969
public Map<String, String> getConfigForContainer(ConfigFor configFor) throws TException {
70-
SW360ConfigsService.Iface configsService = getThriftConfigsClient();
71-
return configsService.getConfigForContainer(configFor);
70+
Map<String, String> combinedConfig = getSW360ConfigFromDb(configFor);
71+
combinedConfig.putAll(getSW360ConfigFromProperties());
72+
return combinedConfig;
73+
}
74+
75+
public Map<String, String> getSW360ConfigFromDb(ConfigFor configFor) throws TException {
76+
SW360ConfigsService.Iface configService = getThriftConfigsClient();
77+
return configService.getConfigForContainer(configFor);
7278
}
7379

7480
public RequestStatus updateSW360ConfigForContainer(ConfigFor configFor, Map<String, String> updatedConfig, User user) throws TException, InvalidPropertiesFormatException {

0 commit comments

Comments
 (0)