本文整理汇总了Java中jetbrains.buildServer.users.SUser.getVcsUsernameProperties方法的典型用法代码示例。如果您正苦于以下问题:Java SUser.getVcsUsernameProperties方法的具体用法?Java SUser.getVcsUsernameProperties怎么用?Java SUser.getVcsUsernameProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jetbrains.buildServer.users.SUser
的用法示例。
在下文中一共展示了SUser.getVcsUsernameProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkForTfsMapping
import jetbrains.buildServer.users.SUser; //导入方法依赖的package包/类
/**
* Checks for the TFS domain mapping for the user account
* @param user The user account.
*/
private void checkForTfsMapping(User user) {
String localDomain = this.usernameMapperConfig.getDomainName();
if (localDomain == null || localDomain.isEmpty()) {
LOG.debug("Domain was not set by a setting, please set it in the main config.");
return;
}
SUser serverUser = this.server.getUserModel().findUserById(user.getId());
if (serverUser == null) {
LOG.warn(String.format("Could not find server user with ID: %d", user.getId()));
return;
}
List<VcsUsernamePropertyKey> vcsUsernameProperties = serverUser.getVcsUsernameProperties();
String userName = user.getUsername();
String domainUser = String.format("%s\\%s", localDomain, userName);
for (VcsUsernamePropertyKey vcsUsernameProperty : vcsUsernameProperties) {
if (vcsUsernameProperty.getVcsName().equals(TFS_ROOT_NAME)) {
String currentMapping = user.getPropertyValue(vcsUsernameProperty);
if (currentMapping == null) {
// Set the username and update
LOG.info(String.format("Updating TFS source mapping for user '%s' to domain mapping: %s", userName, domainUser));
serverUser.setUserProperty(vcsUsernameProperty, domainUser);
}
return;
}
}
// No mapping was found add it to the system
LOG.info(String.format("Adding TFS source mapping for user '%s' to domain mapping: %s", userName, domainUser));
VcsSupportConfig tfsRoot = this.server.getVcsManager().findVcsByName(TFS_ROOT_NAME);
if (tfsRoot != null) {
LOG.debug("Found TFS root config, setting property");
VcsUsernamePropertyKey key = new VcsUsernamePropertyKey(tfsRoot);
serverUser.setUserProperty(key, domainUser);
}
}