Skip to content

Commit

Permalink
Copy individual keys from default user profile when missing in specif…
Browse files Browse the repository at this point in the history
…ic user profile. Until now, the

default user profile settings were only used if the user name was completely absent in config.yml.
  • Loading branch information
janvanmansum committed May 23, 2024
1 parent 9fa0859 commit 985ab43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/main/java/nl/knaw/dans/sword2/config/UserConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ public class UserConfig {
private String name;
private String passwordHash;
private Boolean filepathMapping;
@NotNull
private List<String> collections;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package nl.knaw.dans.sword2.core.service;

import nl.knaw.dans.sword2.config.DefaultUserConfig;
import nl.knaw.dans.sword2.core.auth.Depositor;
import nl.knaw.dans.sword2.config.UserConfig;
import nl.knaw.dans.sword2.core.auth.Depositor;

import java.util.HashMap;
import java.util.List;
Expand All @@ -32,7 +32,9 @@ public class UserManagerImpl implements UserManager {
public UserManagerImpl(List<UserConfig> userConfigs, DefaultUserConfig defaultUserConfig) {
if (userConfigs != null) {
for (var user : userConfigs) {
var depositor = new Depositor(user.getName(), user.getFilepathMapping(), Set.copyOf(user.getCollections()));
var depositor = new Depositor(user.getName(),
user.getFilepathMapping() == null ? defaultUserConfig.getFilepathMapping() : user.getFilepathMapping(),
user.getCollections() == null ? Set.copyOf(defaultUserConfig.getCollections()) : Set.copyOf(user.getCollections()));
depositorMap.put(user.getName(), depositor);
}
}
Expand Down

0 comments on commit 985ab43

Please sign in to comment.