use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method getUserDisplayNamesByKey.
@Override
public Map<Long, String> getUserDisplayNamesByKey(Collection<Long> identityKeys) {
if (identityKeys == null || identityKeys.isEmpty()) {
return Collections.emptyMap();
}
Map<Long, String> fullNames = new HashMap<>();
List<Long> newIdentityKeys = new ArrayList<>();
for (Long identityKey : identityKeys) {
String fullName = userToFullnameCache.get(identityKey);
if (fullName != null) {
fullNames.put(identityKey, fullName);
} else {
newIdentityKeys.add(identityKey);
}
}
List<IdentityShort> identities = securityManager.loadIdentityShortByKeys(newIdentityKeys);
for (IdentityShort identity : identities) {
String fullName = getUserDisplayName(identity);
updateUsernameCache(identity.getKey(), identity.getName(), fullName);
fullNames.put(identity.getKey(), fullName);
}
return fullNames;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method getUserDisplayNamesByUserName.
@Override
public Map<String, String> getUserDisplayNamesByUserName(Collection<String> usernames) {
if (usernames == null || usernames.isEmpty()) {
return Collections.emptyMap();
}
Map<String, String> fullNames = new HashMap<>();
List<String> newUsernames = new ArrayList<>();
for (String username : usernames) {
String fullName = userToFullnameCache.get(username);
if (fullName != null) {
fullNames.put(username, fullName);
} else {
newUsernames.add(username);
}
}
List<IdentityShort> identities = securityManager.findShortIdentitiesByName(newUsernames);
for (IdentityShort identity : identities) {
String fullName = getUserDisplayName(identity);
fullNames.put(identity.getName(), fullName);
newUsernames.remove(identity.getName());
}
// not found
for (String notFound : newUsernames) {
userToFullnameCache.put(notFound, notFound);
}
return fullNames;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method getUserDisplayName.
@Override
public String getUserDisplayName(Long identityKey) {
if (identityKey == null || identityKey.longValue() <= 0) {
return "";
}
String fullName = userToFullnameCache.get(identityKey);
if (fullName == null) {
IdentityShort identity = securityManager.loadIdentityShortByKey(identityKey);
fullName = getUserDisplayName(identity);
}
return fullName;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class SearchControllerFactory method getBusinessPathLabel.
@Override
public String getBusinessPathLabel(String token, List<String> allTokens, Locale locale) {
try {
String[] splitted = token.split("[:]");
if (splitted != null && splitted.length == 2) {
String tokenType = splitted[0];
String tokenKey = splitted[1];
if ("RepositoryEntry".equals(tokenType)) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(tokenKey));
return re.getDisplayname();
}
if ("CourseNode".equals(tokenType)) {
String repoKey = allTokens.get(0).split("[:]")[1];
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(Long.parseLong(repoKey));
if (re != null) {
ICourse course = CourseFactory.loadCourse(re);
CourseNode courseNode = course.getRunStructure().getNode(tokenKey);
return courseNode.getShortTitle();
}
}
if ("Identity".equals(tokenType)) {
IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(Long.parseLong(tokenKey));
return UserManager.getInstance().getUserDisplayName(identity);
}
if ("BusinessGroup".equals(tokenType)) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(Long.parseLong(tokenKey));
return bg == null ? "" : bg.getName();
}
if ("Taxonomy".equals(tokenType)) {
Taxonomy taxonomy = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomy(new TaxonomyRefImpl(Long.parseLong(tokenKey)));
return taxonomy == null ? "" : taxonomy.getDisplayName();
}
if ("TaxonomyLevel".equals(tokenType)) {
TaxonomyLevel level = CoreSpringFactory.getImpl(TaxonomyService.class).getTaxonomyLevel(new TaxonomyLevelRefImpl(Long.parseLong(tokenKey)));
return level == null ? "" : level.getDisplayName();
}
Translator translator = Util.createPackageTranslator(this.getClass(), locale);
if ("DocumentPool".equals(tokenType)) {
return translator.translate("DocumentPool");
}
if ("Templates".equals(tokenType)) {
return translator.translate("Templates");
}
if ("userfolder".equals(tokenType)) {
return translator.translate("type.identity.publicfolder");
}
String translated = translator.translate(tokenType);
if (translated == null || translated.length() > 64) {
// no translation, translator return an error
return token;
}
return translated;
}
} catch (Exception ex) {
log.warn("Problem to decipher business path token: " + token, ex);
}
return token;
}
use of org.olat.basesecurity.IdentityShort in project OpenOLAT by OpenOLAT.
the class StandardResultController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer formLayoutCont = (FormLayoutContainer) formLayout;
formLayoutCont.contextPut("result", document);
formLayoutCont.contextPut("id", hashCode());
formLayoutCont.contextPut("formatter", Formatter.getInstance(getLocale()));
String author = document.getAuthor();
if (StringHelper.containsNonWhitespace(author)) {
List<IdentityShort> identities = BaseSecurityManager.getInstance().findShortIdentitiesByName(Collections.singleton(author));
if (identities.size() > 0) {
author = UserManager.getInstance().getUserDisplayName(identities.get(0));
}
}
formLayoutCont.contextPut("author", author);
if (StringHelper.containsNonWhitespace(document.getLicenseTypeKey())) {
LicenseType licenseType = licenseService.loadLicenseTypeByKey(document.getLicenseTypeKey());
if (!licenseService.isNoLicense(licenseType)) {
formLayoutCont.contextPut("licenseIcon", LicenseUIFactory.getCssOrDefault(licenseType));
formLayoutCont.contextPut("license", LicenseUIFactory.translate(licenseType, getLocale()));
}
}
}
String icon = document.getCssIcon();
if (!StringHelper.containsNonWhitespace(icon)) {
icon = "o_sp_icon";
}
String label = document.getTitle();
if (label != null) {
label = label.trim();
}
if (label.length() > 128) {
label = FilterFactory.getHtmlTagsFilter().filter(label);
label = Formatter.truncate(label, 128);
}
label = StringHelper.escapeHtml(label);
docLink = uifactory.addFormLink("open_doc", label, label, formLayout, Link.NONTRANSLATED);
docLink.setIconLeftCSS("o_icon o_icon-fw " + icon);
String highlightLabel = document.getHighlightTitle();
if (!StringHelper.containsNonWhitespace(highlightLabel)) {
highlightLabel = label;
}
docHighlightLink = uifactory.addFormLink("open_doc_highlight", highlightLabel, highlightLabel, formLayout, Link.NONTRANSLATED);
docHighlightLink.setIconLeftCSS("o_icon o_icon-fw " + icon);
}
Aggregations