Skip to content

Commit

Permalink
Merge branch 'master' into j21tc9
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Sep 13, 2024
2 parents c10ffa2 + 1d2bf25 commit 5d3ab30
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
7 changes: 2 additions & 5 deletions Model/src/main/java/org/gusdb/wdk/model/user/UserCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public UserCache(UserFactory userFactory) {
*/
public UserCache(User user) {
put(user.getUserId(), user);
_userFactory = null;
_userFactory = user.getWdkModel().getUserFactory();
}

public void loadUsersByIds(List<Long> userIds) {
Expand All @@ -41,13 +41,10 @@ public User get(Object id) {
}
Long userId = (Long)id;
if (!containsKey(userId)) {
if (_userFactory != null) {
synchronized(this) {
put(userId, _userFactory.getUserById(userId)
.orElseThrow(() -> new WdkRuntimeException("User with ID " + userId + " does not exist.")));
}
else {
throw new WdkRuntimeException("No-lookup cache does not contain the requested user (" + userId + ").");
}
}
return super.get(userId);
}
Expand Down
13 changes: 12 additions & 1 deletion Model/src/main/java/org/gusdb/wdk/model/user/UserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,18 @@ public void resetPassword(String loginName) throws InvalidUsernameOrEmailExcepti
public Map<Long, User> getUsersById(List<Long> userIds) {
// ensure a unique list
userIds = new ArrayList<>(new HashSet<>(userIds));
return OAuthQuerier.getUsersById(_client, _config, userIds, json -> new BasicUser(_wdkModel, json));
Map<Long,User> userMap = OAuthQuerier.getUsersById(_client, _config, userIds, json -> new BasicUser(_wdkModel, json));
// FIXME: This is a temporary hack to account for guests created before the
// implementation of bearer tokens who still have WDK steps/strats. Eventually
// these guests should be removed during regular maintenance cleanup; once all
// guests created before spring 2024 are removed, this code can also be removed.
for (Long userId : userIds) {
if (userMap.get(userId) == null) {
// OAuth does not know about this user; trust that it is a guest
userMap.put(userId, new BasicUser(_wdkModel, userId, true, userId.toString(), userId.toString()));
}
}
return userMap;
}

public Map<String, User> getUsersByEmail(List<String> emails) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.gusdb.wdk.model.user;

import java.util.Optional;
import java.util.regex.Matcher;

import org.gusdb.wdk.model.Attachment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.gusdb.wdk.model.user;

import java.sql.Timestamp;
import java.sql.Types;
import java.util.Date;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.gusdb.wdk.model.fix.table.edaanalysis.plugins;

import org.gusdb.wdk.model.WdkModel;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;

import org.gusdb.wdk.model.fix.table.TableRowInterfaces;
import org.gusdb.wdk.model.fix.table.edaanalysis.AnalysisRow;
import org.json.JSONObject;
Expand All @@ -9,21 +14,14 @@
import org.junit.Test;
import org.mockito.Mockito;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;

public class VDIMigrationPluginTest {
private WdkModel mockedModel;

private ClassLoader classLoader;
private VDIEntityIdRetriever retriever;

@Before
public void setup() {
classLoader = getClass().getClassLoader();
mockedModel = Mockito.mock(WdkModel.class);
retriever = Mockito.mock(VDIEntityIdRetriever.class);
}

Expand Down

0 comments on commit 5d3ab30

Please sign in to comment.