@Test public void differentGlobalWikiWithNoManagers() throws Exception { final DocumentReference admin = new DocumentReference("test", this.userSpace, this.adminUsername); when(this.cm.getInstanceMap(UserManager.class)).thenReturn(Collections.<String, Object>emptyMap()); when(this.modelConfiguration.getDefaultReferenceValue(EntityType.WIKI)).thenReturn("test"); when(this.configuration.getProperty("users.defaultWiki", "test")).thenReturn("test"); when(this.resolver.resolve(this.adminUsername, EntityType.DOCUMENT, new EntityReference(this.userSpace, EntityType.SPACE, new WikiReference("test")))).thenReturn(admin); when(this.serializer.serialize(admin, new Object[0])).thenReturn("test:XWiki.Admin"); User u = this.userManager.getUser(this.adminUsername); Assert.assertEquals("test:XWiki.Admin", u.getId()); Assert.assertTrue(u instanceof InvalidUser); }
@Override public User getUser(String identifier, boolean force) { if (StringUtils.isBlank(identifier)) { return new InvalidUser(null, this.serializer); } User result = null; try { Map<String, UserManager> managers = this.componentManager.getInstanceMap(UserManager.class); managers.remove("default"); for (UserManager manager : managers.values()) { result = manager.getUser(identifier); if (result != null) { return result; } } } catch (ComponentLookupException ex) { } if (force) { try { UserManager defaultManager = this.componentManager.getInstance(UserManager.class, this.configuration.getProperty("users.defaultUserManager", "wiki")); return defaultManager.getUser(identifier, true); } catch (ComponentLookupException ex) { } } return new InvalidUser(getDefaultReference(identifier), this.serializer); }
MetaUserManager extends AbstractUserManager { @Override public User getUser(String identifier, boolean force) { if (StringUtils.isBlank(identifier)) { return new InvalidUser(null, this.serializer); } User result = null; try { Map<String, UserManager> managers = this.componentManager.getInstanceMap(UserManager.class); managers.remove("default"); for (UserManager manager : managers.values()) { result = manager.getUser(identifier); if (result != null) { return result; } } } catch (ComponentLookupException ex) { } if (force) { try { UserManager defaultManager = this.componentManager.getInstance(UserManager.class, this.configuration.getProperty("users.defaultUserManager", "wiki")); return defaultManager.getUser(identifier, true); } catch (ComponentLookupException ex) { } } return new InvalidUser(getDefaultReference(identifier), this.serializer); } }
MetaUserManager extends AbstractUserManager { @Override public User getUser(String identifier, boolean force) { if (StringUtils.isBlank(identifier)) { return new InvalidUser(null, this.serializer); } User result = null; try { Map<String, UserManager> managers = this.componentManager.getInstanceMap(UserManager.class); managers.remove("default"); for (UserManager manager : managers.values()) { result = manager.getUser(identifier); if (result != null) { return result; } } } catch (ComponentLookupException ex) { } if (force) { try { UserManager defaultManager = this.componentManager.getInstance(UserManager.class, this.configuration.getProperty("users.defaultUserManager", "wiki")); return defaultManager.getUser(identifier, true); } catch (ComponentLookupException ex) { } } return new InvalidUser(getDefaultReference(identifier), this.serializer); }  }
MetaUserManager extends AbstractUserManager { @Override public User getUser(String identifier, boolean force) { if (StringUtils.isBlank(identifier)) { return new InvalidUser(null, this.serializer); } User result = null; try { Map<String, UserManager> managers = this.componentManager.getInstanceMap(UserManager.class); managers.remove("default"); for (UserManager manager : managers.values()) { result = manager.getUser(identifier); if (result != null) { return result; } } } catch (ComponentLookupException ex) { } if (force) { try { UserManager defaultManager = this.componentManager.getInstance(UserManager.class, this.configuration.getProperty("users.defaultUserManager", "wiki")); return defaultManager.getUser(identifier, true); } catch (ComponentLookupException ex) { } } return new InvalidUser(getDefaultReference(identifier), this.serializer); }  @Override User getUser(String identifier, boolean force); @Override User getCurrentUser(); }
MetaUserManager extends AbstractUserManager { @Override public User getUser(String identifier, boolean force) { if (StringUtils.isBlank(identifier)) { return new InvalidUser(null, this.serializer); } User result = null; try { Map<String, UserManager> managers = this.componentManager.getInstanceMap(UserManager.class); managers.remove("default"); for (UserManager manager : managers.values()) { result = manager.getUser(identifier); if (result != null) { return result; } } } catch (ComponentLookupException ex) { } if (force) { try { UserManager defaultManager = this.componentManager.getInstance(UserManager.class, this.configuration.getProperty("users.defaultUserManager", "wiki")); return defaultManager.getUser(identifier, true); } catch (ComponentLookupException ex) { } } return new InvalidUser(getDefaultReference(identifier), this.serializer); }  @Override User getUser(String identifier, boolean force); @Override User getCurrentUser();  }